local p = {}local sub = mw.ustring.sublocal find = mw.ustring.findlocal gmatch = mw.ustring.gmatchlocal match = mw.ustring.matchlocal trim = mw.text.trimlocal insert = table.insertlocal concat = table.concatfunction p.caserequests ( frame )frame = frame or mw.getCurrentFrame()local page = mw.title.new('Wikipedia:Arbitration/Requests/Case'):getContent()local re = '\n==%f[^=](.-)=='local sections = {}local count, loc = 0, 0repeatloc = find(page, re, loc+1)if (loc) thencount = count + 1sections[count] = {id = count, start = loc,title = trim(match(page, re, loc))}enduntil not locfor i=1, count, 1 dolocal sec = sections[i]local content = ''if sections[i+1] thencontent = sub( page, sec.start, sections[i+1].start )elsecontent = sub( page, sec.start )endlocal redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'sec.date = match(content, redate)local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?'local m = match(content, remotion)if (m) then sec.motion = trim(m)endlocal revotes = '\n===[^\n]*<(%d+/%d+/%d+)>%s*==='sec.votes = match(content, revotes)endlocal result = {}for i=1, count, 1 dolocal sec = sections[i]local s = frame:expandTemplate{title = 'ArbComOpenTasks/line',args = {mode = 'caserequest',name = sec.title,date = sec.date,motion = sec.motion,votes = sec.votes}}insert(result, s)endreturn concat(result, '\n')endfunction p.arca ( frame )frame = frame or mw.getCurrentFrame()local page = mw.title.new('Wikipedia:Arbitration/Requests/Clarification and Amendment'):getContent()local re = '\n==%f[^=](.-)=='local sections = {}local count, loc = 0, 0repeatloc = find(page, re, loc+1)if (loc) thencount = count + 1sections[count] = {id = count, start = loc,title = trim(match(page, re, loc))}enduntil not locfor i=1, count, 1 dolocal sec = sections[i]local content = ''if sections[i+1] thencontent = sub( page, sec.start, sections[i+1].start )elsecontent = sub( page, sec.start )endlocal redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'sec.date = match(content, redate)local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?'local m = match(content, remotion)if (m) then sec.motion = trim(m)endlocal relink = '{{RFARlinks%|(.-)}}'sec.link = match(content, relink)endlocal result = {}for i=1, count, 1 dolocal sec = sections[i]local s = frame:expandTemplate{title = 'ArbComOpenTasks/line',args = {mode = 'amendment',name = sec.title,date = sec.date,motion = sec.motion,link = sec.link}}insert(result, s)endreturn concat(result, '\n')endfunction p.motions ( frame )frame = frame or mw.getCurrentFrame()local page = mw.title.new('Wikipedia:Arbitration/Requests/Motions'):getContent()local re = '\n==%f[^=](.-)=='local sections = {}local count, loc = 0, 0repeatloc = find(page, re, loc+1)if (loc) thencount = count + 1sections[count] = {id = count, start = loc,title = trim(match(page, re, loc))}enduntil not locfor i=1, count, 1 dolocal sec = sections[i]local content = ''if sections[i+1] thencontent = sub( page, sec.start, sections[i+1].start )elsecontent = sub( page, sec.start )endlocal redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'sec.date = match(content, redate)endlocal result = {}for i=1, count, 1 dolocal sec = sections[i]local s = frame:expandTemplate{title = 'ArbComOpenTasks/line',args = {mode = 'motion',name = sec.title,date = sec.date,}}insert(result, s)endreturn concat(result, '\n')endreturn p