Module:RfD close: Difference between revisions

Content deleted Content added
build it all up...
m Protected "Module:RfD close": Highly visible module ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
 
(10 intermediate revisions by one other user not shown)
Line 1:
local rfd = {}
 
function rfd.rfdt_collapseboxrfdt_before_result(frame) --this bit creates the "closed discussion" notice
--define function to check whether arguments are defined
local args = frame.args
 
local function argIsSet(key)
if args[key] and args[key]:find('%S') then
return true
else
return false
end
end
local message_string1 = '<includeonly>[[File:Symbol move vote.svg|16px|link=|alt=]] '
.. "'''Closed discussion''', see [["
local timestamp_string = os.time()
local link_string = tostring(mw.title.getCurrentTitle()) .. '#' .. timestamp_string
local message_string2 = '|full discussion]].'
local result_string = ''
if (argIsSet('result')) then
result_string = ' Result was: ' .. frame.args['result']
end
local end_string = '</includeonly><noinclude><span id="' .. timestamp_string .. '"></span>'
 
return message_string1 .. link_string .. message_string2 .. result_string .. end_string
end
 
function rfd.rfdt_collapsebox_sandbox(frame) --this bit creates the "closed discussion" notice
--define function to check whether arguments are defined
local args = frame.args
Line 57 ⟶ 25:
--sufficiently complicated (there is no built-in "or" in Lua string
--patterns) so I'll just lay it flat.
if (parameter_lower:find('keep') or parameter_lower:find('withdraw') or parameter_lower:find('refine')) then
result_match = 'Keep'
icon_filename = 'File:White check mark in dark green rounded square.svg'
Line 69 ⟶ 37:
end
if (parameter_lower:find('retarget')) or parameter_lower:find('soft redirect'))then
result_match = 'Retarget'
icon_filename = 'File:Right-pointing white arrow in blue rounded square.svg'
Line 75 ⟶ 43:
end
if (parameter_lower:find('disambiguatedisambig') or parameter_lower:find('dab') or parameter_lower:find('sia') or parameter_lower:find('set index')) then
result_match = 'Disambiguate'
icon_filename = 'File:DisambiguationThree disambiguation arrows icon in rounded blue square.svg'
find_count = find_count + 1
end
if (parameter_lower:find('no consensus') and find_count >== 20) then
--This catches instances of "no consensus" that isn't qualified by "default to [keep/delete]"
result_match = 'Multiple decisions'
result_match = 'No consensus'
icon_filename = 'File:White equals sign on grey rounded square.svg'
find_count = 1
end
if find_count >= 2 or (argIsSet('result') and find_count == 0) then
result_match = 'MultipleSplit or bespoke decisions'
icon_filename = 'File:White i in purple rounded square.svg'
elseif find_count <= 0 then
result_match = 'No decision or bespoke decision'
icon_filename = 'File:50% grey rounded square.svg'
end
Line 92 ⟶ 67:
end
--Detect result first, default to "no or bespokedecision" if arg not set
local result_match = 'No decision or bespoke decision'
local icon_filename = 'File:50% grey rounded square.svg'
local result_string = ''
if (argIsSet('result')) then
result_string = ' Result was: ' .. args['result']
result_match, icon_filename = match_result(args['result'])
end
--Build wikitext for result icon
local message_string1 = '<includeonly>[[' ..--includeonly icon_filenametag
--then dump the icon
.. '[[' .. icon_filename
.. '|16px|link=|alt=' .. result_match .. "]] '''Closed discussion''', see [["
Line 116 ⟶ 93:
--Put it all together and return from Lua
return message_string1 .. link_string .. message_string2 .. result_string .. end_string
end
 
function rfd.rfdt_show_result(frame)
return '</noinclude>' .. frame.args['result'] .. '<includeonly></div></includeonly><noinclude>'
end