Module:Deletion sorting/sandbox: Difference between revisions
Appearance
Content deleted Content added
remove unnecessary assignment |
Make rootpage variable |
||
Line 7: | Line 7: | ||
function p.delsort(frame) |
function p.delsort(frame) |
||
local args = {} |
local args = {} |
||
local rootpage = '[[Wikipedia:WikiProject Deletion sorting' |
|||
local sig = os.date("!%H:%M, %e %B %Y (UTC)") |
local sig = os.date("!%H:%M, %e %B %Y (UTC)") |
||
for k, v in pairs(frame:getParent().args) do |
for k, v in pairs(frame:getParent().args) do |
||
if mw.ustring.match(v,'%S') then |
if mw.ustring.match(v,'%S') then |
||
Line 28: | Line 30: | ||
local outStr = 'Note: This discussion has been included in the ' |
local outStr = 'Note: This discussion has been included in the ' |
||
if #args == 1 then |
if #args == 1 then |
||
outStr = outStr..' |
outStr = outStr..rootpage..'/'..args[1]..'|list of '..args[1]..'-related deletion discussions]]' |
||
else |
else |
||
outStr = outStr |
outStr = outStr..rootpage..'|deletion sorting]] lists for the following topics: ' |
||
for i = 1, #args do |
for i = 1, #args do |
||
if i > 1 then |
if i > 1 then |
||
Line 36: | Line 38: | ||
if i == #args then outStr = outStr..' and ' end |
if i == #args then outStr = outStr..' and ' end |
||
end |
end |
||
outStr = outStr..' |
outStr = outStr..rootpage..'/'..args[i]..'|'..args[i]..']]' |
||
end |
end |
||
end |
end |
Revision as of 18:41, 18 February 2022
![]() | This is the module sandbox page for Module:Deletion sorting (diff). |
Implements {{Deletion sorting/multi}}.
local p = {}
local function makeError(msg)
return mw.text.tag('strong', {['class']='error'}, 'Error in [[Template:Deletion sorting]]: ' .. msg)
end
function p.delsort(frame)
local args = {}
local rootpage = '[[Wikipedia:WikiProject Deletion sorting'
local sig = os.date("!%H:%M, %e %B %Y (UTC)")
for k, v in pairs(frame:getParent().args) do
if mw.ustring.match(v,'%S') then
if type(k) == 'number' then
local title = mw.title.new(v)
if title and title.rootText then
table.insert(args, title.rootText)
else
return makeError('Input contains forbidden characters.')
end
elseif k:sub(0,3) == 'sig' then
sig = v
end
end
end
if #args == 0 then
if frame.args.example then args[1] = frame.args.example else return makeError('Category not specified.') end
end
local outStr = 'Note: This discussion has been included in the '
if #args == 1 then
outStr = outStr..rootpage..'/'..args[1]..'|list of '..args[1]..'-related deletion discussions]]'
else
outStr = outStr..rootpage..'|deletion sorting]] lists for the following topics: '
for i = 1, #args do
if i > 1 then
if #args > 2 then outStr = outStr..', ' end
if i == #args then outStr = outStr..' and ' end
end
outStr = outStr..rootpage..'/'..args[i]..'|'..args[i]..']]'
end
end
return mw.text.tag('small', {['class']='delsort-notice'}, outStr..'. '..sig)
end
return p