Module:RfD: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
rework to not need rfd/core
Jackmcbarn (talk | contribs)
let this do the subst part too
Line 13:
if not messageBox then
messageBox = require('Module:Message box')
end
local discussionPage = args.name and mw.text.trim(args.name)
if discussionPage == '' then
discussionPage = nil
end
return string.format('%s<span id="delete-reason" style="display:none;">%%5B%%5BWikipedia%%3ARedirects+for+discussion%%5D%%5D+debate+closed+as+delete</span>%s',
Line 18 ⟶ 22:
type = 'delete',
image = 'none',
text = string.format(rfdText, args.year, args.month, args.day, args[1]discussionPage or currentTitle.prefixedText, currentTitle.prefixedText)
}),
args.category or string.format('[[Category:Redirects for discussion|%s]]', currentTitle.text)
Line 29 ⟶ 33:
getTargetFromText = require('Module:Redirect').getTargetFromText
end
return frame:getParent():preprocess(mw.title.new(getTargetFromText(frame.args.content[1])):getContent())
end
 
Line 35 ⟶ 39:
p[''] = function(frame)
return makeRfdNotice(frame.args) .. frame.args.content
end
 
local substText = '{{#invoke:RfD|<includeonly>1</includeonly>|name = %s|%s\n'
.. '<!-- Do not use the "Rfd/core" template directly; the above line is generated by {{subst:Rfd}}. -->\n<!-- End of RFD message. Feel free to edit beyond this point. -->|\n%s\n}}'
 
-- called during subst when the template is initially placed on the page
function p.main(frame)
local titleText
if frame.args.name then
titleText = mw.title.new(frame.args.name).prefixedText
else
titleText = mw.title.getCurrentTitle().prefixedText
end
local date = os.date('*t')
local retval = string.format(substText, titleText, os.date('month = %B\n|day = %e\n|year = %Y\n|time = %R\n|timestamp = %Y%m%d%H%M%S'), frame.args[1])
if mw.isSubsting() then
return retval
end
return frame:expandTemplate{title = 'Template:Error:must be substituted', args = {'Rfd'}} .. frame:preprocess(retval)
end