Content deleted Content added
use style variable for status, ending time and time left fields |
update from /sandbox. Implements support for RRfAs |
||
(15 intermediate revisions by 10 users not shown) | |||
Line 5:
local p = {}
local function getTableLength(tbl)
for _ in pairs(tbl) do
length = length + 1
return length
end
local function getRfxes()
Line 21 ⟶ 29:
-- which are always transcluded there.
local t = {}
local exceptions = { 'Front matter', 'Header', 'bureaucratship' }
for rfxPage, rfxSubpage in mw.ustring.gmatch( rfaText, '{{[ _]*([wW]ikipedia:[rR]equests for %w+/([^{}]-))[ _]*}}' ) do
local isException = false
Line 40 ⟶ 48:
return nil
end
▲ local style = ''
local styleInline = ''▼
local status = rfxObject:getStatus()
if status == 'pending closure' then▼
▲ end
local page = rfxObject:getTitleObject().prefixedText
local user = rfxObject.user or rfxObject:getTitleObject().subpageText
Line 58 ⟶ 60:
end
colour = colour or ''
if percent == 0 and supports == 0 and opposes == 0 and neutrals == 0 then
percentStr = 'N/A'
elseif percent == 100 and opposes ~= 0 then
percentStr = '>99'
local votes
if supports and opposes and neutrals and percent then
votes = mw.ustring.format( [==[
|
|
|
|
colour,
)
else
votes = '\n| colspan="4"
end
if status then
Line 79 ⟶ 89:
status = 'Pending closure...'
end
status =
else
status = '\n|
end
local endTime = rfxObject.endTime
Line 88 ⟶ 98:
local time
if endTime and timeLeft then
time = mw.ustring.format( '\n|
else
time = '\n| colspan="2"
end
local dupes = rfxObject:dupesExist()
if dupes then
dupes = '<span class="
elseif dupes == false then
dupes = 'no'
Line 102 ⟶ 112:
local report = rfxObject:getReport()
if report then
report = mw.ustring.format( '\n|
else
report = '\n|
end
local pending_class = ''
▲ if status == 'pending closure' then
pending_class = 'class="rfx-report-pending"'
end
return mw.ustring.format(
'\n|-%s\n|
)
end
local function makeHeading( rfxType )
local frame = mw.getCurrentFrame()
local rfxCaps
if rfxType == 'rfa' then
Line 118 ⟶ 133:
elseif rfxType == 'rfb' then
rfxCaps = 'RfB'
elseif rfxType == 'rrfa' then
rfxCaps = 'RRfA'
else
return nil
end
return mw.ustring.format(
'\n|-\n! scope="col" | %s candidate !! scope="col" | <abbr title="Support">S</abbr> !! scope="col" | <abbr title="Oppose">O</abbr> !! scope="col" | <abbr title="Neutral">N</abbr> !! scope="col" | <abbr title="Support percentage (%%)">S %%</abbr> !! scope="col" | Status !! scope="col" | Ending (UTC) !! scope="col" | Time left !!
rfxCaps
)
end
local function
if not rfxes then
return nil
Line 135 ⟶ 152:
local rfas = {}
local rfbs = {}
local rrfas = {}
for i, rfxPage in ipairs( rfxes ) do
local rfxObject = rfx.new( rfxPage )
Line 142 ⟶ 160:
elseif rfxObject.type == 'rfb' then
table.insert( rfbs, rfxObject )
elseif rfxObject.type == 'rrfa' then
table.insert( rrfas, rfxObject)
end
end
end
return rfas, rfbs, rrfas
end
local function makeReportRows()
local rfas, rfbs, rrfas = getRfasRfbsSeparate()
local ret = {}
if #rfas + #rrfas > 0 then
table.insert( ret, makeHeading( 'rfa' ) )
for i, rfaObject in ipairs( rfas ) do
table.insert( ret, makeRow( rfaObject ) )
for i, rrfaObject in ipairs( rrfas ) do
table.insert( ret, makeRow( rrfaObject ) )
end
end
if #rfbs > 0 then
table.insert( ret, makeHeading( 'rfb' ) )
Line 164 ⟶ 195:
local purgeLink = mw.title.getCurrentTitle():fullUrl( 'action=purge' )
local header = mw.ustring.format(
'\n|
purgeLink
)
local rows = makeReportRows() or ''
if rows == '' then
rows = '\n|-\n| colspan="10" | No current discussions. <
end
local style = args.style▼
if not style then▼
if
float = nil
▲ local clear = args.clear or 'left'
▲ style = mw.ustring.format(
▲ clear, float
▲ )
end
return mw.ustring.format( '\n{| class="wikitable" %s%s%s\n|-\n|}', style, header, rows )▼
if not clear or mw.text.trim(clear) == '' then
clear = nil
end
style = string.format(
'style="%s%s"',
clear and ('clear: ' .. clear .. ';') or '',
float and ('float: ' .. float .. ';') or ''
)
end
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:RFX report/styles.css' }
} .. mw.ustring.format(
▲
style,
header,
rows
)
end
function p.countRfas()
local rfas, rfbs, rrfas = getRfasRfbsSeparate()
return getTableLength(rfas)
end
|