Module:Sandbox/ProcrastinatingReader: Difference between revisions

Content deleted Content added
neater titles for xfd
quick spin with param replacement
Line 8:
local function getDeletionDiscussions()
local namespaceMap = {
[""] = "Articles for deletion",
["Category"] = "Categories for discussion",
["File"] = "Files for discussion",
["Template"] = "Templates for discussion",
["Module"] = "Templates for discussion",
 
}
--local current_page = mw.title.getCurrentTitle()
Line 14 ⟶ 19:
local n = 1
local current_page = mw.title.new("Premadasa Hegoda")
local namespacensPrefix = namespaceMap[current_page.nsText] or "Miscellany for deletion"
while true do -- possibly expensive if lots of noms
page = mw.title.makeTitle('Wikipedia', namespaceMap[namespace]nsPrefix..'/'..current_page.text..(n > 1 and " ("..n.."nd nomination)" or ""))
if page.exists then
output = output ..(n > 1 and ", " or "").."[["..page.prefixedText.."|XfD"..(n > 1 and " ("..n..")" or "").."]]"
Line 41 ⟶ 46:
end
 
local function buildMsgParams(criterion, key, data, args)
local msg = substituteMsgParams(criterion..'.'..key, data[key])
local appendMsg = ""
local extraParams = data['params']
 
if extraParams then
for k,param in pairs(extraParams) do
local keys = param.keys
for j,paramkey in pairs(keys) do
if args[paramkey] and param['append'][key] then -- check if we have a defined param given, and it matches what we're processing
-- assign to msg if we have appends
appendMsg = substitute(param['append'][key], args[paramkey])
end
end
end
end
 
return msg .. appendMsg
end
 
-- Returns
function p.build(frame, args)
local criterion = args['criterion']
Line 56 ⟶ 82:
template = frame:expandTemplate{ title = 'db-meta', args = {
-- Required
' '..frame:preprocess(substituteMsgParamsbuildMsgParams(criterion:lower().., '.message', tag['message'], args)), -- Main text, in bold
frame:preprocess(substituteMsgParamsbuildMsgParams(criterion:lower().., '.extra', tag['extra'], args)) or '', -- Main text, in italics
criterion = criterion, -- Criteron
 
Line 91 ⟶ 117:
 
function p.main(frame)
local args = getArgs(frame, {)
wrappers = {
--'Template:Sandbox/ProcrastinatingReader'
}
})
return p.build(frame, args)
end