Module:ArbComOpenTasks/sandbox: Difference between revisions
Appearance
Content deleted Content added
Dreamy Jazz (talk | contribs) fix? Tag: Reverted |
Dreamy Jazz (talk | contribs) maybe? Tag: Reverted |
||
Line 4: | Line 4: | ||
local find = mw.ustring.find |
local find = mw.ustring.find |
||
local gmatch = mw.ustring.gmatch |
local gmatch = mw.ustring.gmatch |
||
local gsub = mw.ustring.gsub |
|||
local match = mw.ustring.match |
local match = mw.ustring.match |
||
local trim = mw.text.trim |
local trim = mw.text.trim |
||
Line 97: | Line 98: | ||
end |
end |
||
local |
local rehat = '{{hat%s*\|[^\n]-}}' |
||
local new_content = gsub(content, rehat) |
|||
local redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]' |
|||
sec.date = match(new_content, redate) |
|||
local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?' |
local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?' |
Revision as of 00:53, 11 January 2022
![]() | This is the module sandbox page for Module:ArbComOpenTasks (diff). |
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This Lua module is used on approximately 120 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Usage
- Use
{{#invoke:ArbComOpenTasks|caserequests}}
to get a list of open case requests - Use
{{#invoke:ArbComOpenTasks|arca}}
to get a list of open amendment and clarification requests - Use
{{#invoke:ArbComOpenTasks|motions}}
to get a list of open arbitrator motions
local p = {}
local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local trim = mw.text.trim
local insert = table.insert
local concat = table.concat
function 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, 0
repeat
loc = find(page, re, loc+1)
if (loc) then
count = count + 1
sections[count] = {
id = count,
start = loc,
title = trim(match(page, re, loc))
}
end
until not loc
for i=1, count, 1 do
local sec = sections[i]
local content = ''
if sections[i+1] then
content = sub( page, sec.start, sections[i+1].start )
else
content = sub( page, sec.start )
end
local 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)
end
local revotes = '\n===[^\n]*<(%d+/%d+/%d+)>%s*==='
sec.votes = match(content, revotes)
end
local result = {}
for i=1, count, 1 do
local 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)
end
return concat(result, '\n')
end
function 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, 0
repeat
loc = find(page, re, loc+1)
if (loc) then
count = count + 1
sections[count] = {
id = count,
start = loc,
title = trim(match(page, re, loc))
}
end
until not loc
for i=1, count, 1 do
local sec = sections[i]
local content = ''
if sections[i+1] then
content = sub( page, sec.start, sections[i+1].start )
else
content = sub( page, sec.start )
end
local rehat = '{{hat%s*\|[^\n]-}}'
local new_content = gsub(content, rehat)
local redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'
sec.date = match(new_content, redate)
local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?'
local m = match(content, remotion)
if (m) then
sec.motion = trim(m)
end
local relink = '{{RFARlinks%|(.-)}}'
sec.link = match(content, relink)
end
local result = {}
for i=1, count, 1 do
local 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)
end
return concat(result, '\n')
end
function 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, 0
repeat
loc = find(page, re, loc+1)
if (loc) then
count = count + 1
sections[count] = {
id = count,
start = loc,
title = trim(match(page, re, loc))
}
end
until not loc
for i=1, count, 1 do
local sec = sections[i]
local content = ''
if sections[i+1] then
content = sub( page, sec.start, sections[i+1].start )
else
content = sub( page, sec.start )
end
local redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'
sec.date = match(content, redate)
end
local result = {}
for i=1, count, 1 do
local sec = sections[i]
local s = frame:expandTemplate{
title = 'ArbComOpenTasks/line',
args = {
mode = 'motion',
name = sec.title,
date = sec.date,
}
}
insert(result, s)
end
return concat(result, '\n')
end
return p