Module:Sandbox/Bradv/Case Explained

local p =

local sub = mw.ustring.sublocal find = mw.ustring.findlocal gmatch = mw.ustring.gmatchlocal trim = mw.text.trim

local prefix = 'Wikipedia:Arbitration/Requests/Case/'local ptalk = 'Wikipedia talk:Arbitration/Requests/Case/'

function render (tbl, count) local output = if (count > 0) then local div = mw.html.create('div') div :css('text-align', 'left') :wikitext('

\n' .. table.concat(tbl, '

\n') .. '

\n') output = tostring(div) else output = "none" end return outputend

function p.dates(frame) local case = frame.args[1] or frame.args.case return p._dates(case)endfunction p._dates(case) local page = prefix .. case local pagecontent = mw.title.new(page):getContent local result = local re = '\n(.-)' for str in gmatch (pagecontent, re) do table.insert(result, trim(str)) end return render(result, 1)end

function p.decision(frame) local case = frame.args[1] or frame.args.case return p._decision(case)endfunction p._decision(case) local page = prefix .. case local pagecontent = mw.title.new(page):getContent local fdstart = find(pagecontent, '\n=%s*Final decision') local fd = sub(pagecontent, fdstart) local result = local count = 0 local re = '\n

(.-)

' for str in gmatch(fd, re) do if find(str, '^%s*Enforcement') then --ignore else if find(str, '^=') then s = trim(sub(str, 2)) table.insert(result, ':' .. s .. '') else table.insert(result, "" .. str .. "") end count = count + 1 end end return render (result, count)end

function p.arca(frame) local case = frame.args[1] or frame.args.case return p._arca(case)endfunction p._arca(case) local page = ptalk .. case local pagecontent = mw.title.new(page):getContent local result = local count = 0 local re = '\n

(.-)

' for str in gmatch (pagecontent, re) do str = trim(str) if find(str, '^Amendment request') or find(str, '^Clarification request') then table.insert(result, '' .. str .. '') count = count + 1 end end return render (result, count)end

function p.sections(frame) local case = frame.args[1] or frame.args.case return p._sections(case)endfunction p._sections(case) local page = prefix .. case local talkpage = ptalk .. case local result = function add (name) local path = if name then path = '/' .. name else name = 'Case' end local title = mw.title.new(page .. path) if (title.exists) then table.insert(result, '' .. name .. '' .. ' (' .. '' .. 'talk)' ) end end add add('Evidence') add('Workshop') add('Proposed decision')

return table.concat(result, ' • ')end

return p