local p = local Frame
local casePath local people, dates
function p.main (frame) Frame = frame or mw.getCurrentFrame local title = mw.title.getCurrentTitle local base = mw.title.new(frame:callParserFunction('#titleparts',)) local casename = frame:callParserFunction('#titleparts',) if title.isTalkPage then casePath = base.subjectPageTitle.fullText else casePath = base.fullText end
local casenav = mw.title.new(casePath .. '/Casenav') retrieveArgs(casenav, frame:getParent.args)
local output = table.insert(output, makeShortcut(casename)) table.insert(output, makeCaseNav(casenav)) table.insert(output, frame:expandTemplate) if title
'Proposed decision' then table.insert(output, makeArbList) end else --on PD page if title.subpageText
return table.concat(output)end
function retrieveArgs(casenav, frameArgs) --load local args local args = for k, v in pairs(frameArgs) do args[k] = v end --casenav args override local args if casenav.exists then local content = casenav:getContent local temp = mw.ustring.match(content, '%') for str in mw.text.gsplit(temp, '|') do local pair = mw.text.split(str, '=') if #pair
--support legacy arguments if #people.clerks
1 and is_set(v) then table.insert(people.clerks, link('User:' .. v, v)) end end end if #people.drafters
1 and is_set(v) then table.insert(people.drafters, link('User:' .. v, v)) end end endend
function makeShortcut(casename) return Frame:preprocess("")end
function makeCaseNav(casenav) local div = mw.html.create('div') div :css('width', '100%') :css('background', 'ivory') :css('border', '1px solid #AAA') :css('margin-bottom', '1em') :css('padding', '1em 0') :wikitext(caselinks) :wikitext(casedates) :wikitext(casepeople) :tag('span') :wikitext('[' .. casenav:fullUrl('action=edit&preload=User:Bradv/sandbox/casenav/preload') .. ' edit]') :addClass('plainlinks') :cssText('float: right; font-variant: small-caps; font-size: .8em') :done :done return tostring(div)end
function makePD return Frame:expandTemplateend
function makeTalk return Frame:expandTemplateend
function makeArbList local output = table.insert(output, "\n
\n") table.insert(output, "Active:\n") for i = 1, #people.active do table.insert(output, ':#' .. people.active[i] .. '\n') end table.insert(output, "\nInactive:\n") for i = 1, #people.inactive do table.insert(output, ':#' .. people.inactive[i] .. '\n') end table.insert(output, "\nRecused:\n") for i = 1, #people.recused do table.insert(output, ':#' .. people.recused[i] .. '\n') end table.insert(output, "\n\n") return table.concat(output)end
function listAllArbs local result = local acm = mw.title.new('Wikipedia:Arbitration Committee/Members') local content = acm:getContent for str in mw.ustring.gmatch(content, '%') do table.insert(result, str) end table.sort(result) return Frame:expandTemplateend
function caselinks local result = table.insert(result, link(casePath, 'Main case page')) table.insert(result, link(casePath .. '/Evidence', 'Evidence')) table.insert(result, link(casePath .. '/Workshop', 'Workshop')) table.insert(result, link(casePath .. '/Proposed decision', 'Proposed decision')) local div = mw.html.create('div') :css('text-align', 'center') :wikitext(table.concat(result, ' — ')) return tostring(div)end
function casedates (opened, evidence, workshop, pd, suspended, closed) local result if is_set(dates.closed) then result = "Dates: " .. 'Opened ' .. dates.opened .. ' • ' .. 'Closed ' .. dates.closed elseif is_set(dates.suspended) then result = "Case suspended" elseif is_set(dates.opened) then local t = table.insert(t, "Target dates: " .. 'Opened ' .. dates.opened) if is_set(dates.evidence) then table.insert(t, 'Evidence due ' .. dates.evidence) end if is_set(dates.workshop) then table.insert(t, 'Workshop closes ' .. dates.workshop) end if is_set(dates.pd) then table.insert(t, 'Proposed decision expected ' .. dates.pd) end result = table.concat(t, ' • ') else return "" end local div = mw.html.create('div') :css('text-align', 'center') :wikitext(result) return tostring(div)end
function casepeople local s = if #people.clerks
1 then table.insert(s, "Case clerk: " .. table.concat(people.clerks)) else table.insert(s, "Case clerks: " .. table.concat(people.clerks, ' & ')) end if #people.drafters
1 then table.insert(s, "Drafting arbitrator: " .. table.concat(people.drafters)) else table.insert(s, "Drafting arbitrators: " .. table.concat(people.drafters, ' & ')) end local div = mw.html.create('div') :css('text-align', 'center') :wikitext(table.concat(s, ' — ')) return tostring(div)end
function users (list) local result = if list then local tbl = mw.text.split(list, '\n') for i = 1, #tbl do local user = tbl[i] user = mw.text.trim(user) if is_set(user) then table.insert(result, link('User:' .. user, user)) end end end return resultend
function link (path, label) local title = mw.title.new(path) local small = mw.html.create('small') small :wikitext(' (Talk)') return '' .. label .. '' .. tostring(small)end
function is_set(var) return not (var
)end
return p