Jump to content

Module:Deletion sorting and Module:Deletion sorting/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
 
test multi-purpose module
 
Line 1: Line 1:
local p = {}
local p = {}


local introText = 'Note: This discussion has been included in the '
local function makeError(msg)
local delsortRoot = '[[Wikipedia:WikiProject Deletion sorting'
local dateTime = os.date("!%H:%M, %e %B %Y (UTC)")

local function _error(msg)
return mw.text.tag('strong', {['class']='error'}, 'Error in [[Template:Deletion sorting]]: ' .. msg)
return mw.text.tag('strong', {['class']='error'}, 'Error in [[Template:Deletion sorting]]: ' .. msg)
end

local function _small(s)
return mw.text.tag('small', {['class']='delsort-notice'}, s)
end

local function _single(cat, sig)
return _small(introText..delsortRoot..'/'..cat..'|list of '..cat..'-related deletion discussions]]. '..sig)
end

function p.single(frame)
local args = frame:getParent().args
if not mw.ustring.match(args[1],'%S') then
if frame.args.example then args[1] = frame.args.example else return _error('Category not specified.') end
end
return _single(args[1], args.sig or args[2] or dateTime)
end
end


function p.multi(frame)
function p.multi(frame)
local args = {}
local args = {}
local sig=dateTime
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
for k, v in pairs(frame:getParent().args) do
if mw.ustring.match(v,'%S') then
if mw.ustring.match(v,'%S') then
Line 17: Line 35:
table.insert(args, title.rootText)
table.insert(args, title.rootText)
else
else
return makeError('Input contains forbidden characters.')
return _error('Input contains forbidden characters.')
end
end
elseif k:sub(0,3) == 'sig' then
elseif k:sub(0,3) == 'sig' then
Line 26: Line 44:


if #args == 0 then
if #args == 0 then
if frame.args.example then args[1] = frame.args.example else return makeError('Category not specified.') end
if frame.args.example then args[1] = frame.args.example else return _error('Category not specified.') end
end
end
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
return _single(args[1], sig)
outStr = outStr..rootpage..'/'..args[1]..'|list of '..args[1]..'-related deletion discussions]]'
else
else
outStr = outStr..rootpage..'|deletion sorting]] lists for the following topics: '
outStr = outStr..delsortRoot..'|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 38: Line 56:
if i == #args then outStr = outStr..' and ' end
if i == #args then outStr = outStr..' and ' end
end
end
outStr = outStr..rootpage..'/'..args[i]..'|'..args[i]..']]'
outStr = outStr..delsortRoot..'/'..args[i]..'|'..args[i]..']]'
end
end
return _small(outStr..'. '..sig)
end
end
return mw.text.tag('small', {['class']='delsort-notice'}, outStr..'. '..sig)
end
end