Module:RfD and Module:RfD/sandbox: Difference between pages
(Difference between pages)
imported>Wbm1058 case matters – make this string ":Rfd" consistent with the string produced by Template:Rfd-NPF to make it easier for Template:R from move/except to detect uses of both |
imported>Awesome Aasim No edit summary |
||
Line 3: | Line 3: | ||
local p = {} | local p = {} | ||
local getArgs = require('Module:Arguments').getArgs | |||
local getTargetFromText = require('Module:Redirect').getTargetFromText | local getTargetFromText = require('Module:Redirect').getTargetFromText | ||
local messageBox | local messageBox | ||
Line 86: | Line 87: | ||
p[''] = function(frame) | p[''] = function(frame) | ||
local args = frame | local args = getArgs(frame) | ||
if not args.content or mw.text.trim(args.content) == '' then | if not args.content or mw.text.trim(args.content) == '' then | ||
return '<span class="error">Error: No content was provided. The original text of the page (the #REDIRECT line and any templates) must be placed inside of the content parameter.[[Category:RfD errors]]</span>' | return '<span class="error">Error: No content was provided. The original text of the page (the #REDIRECT line and any templates) must be placed inside of the content parameter.[[Category:RfD errors]]</span>' | ||
Line 125: | Line 126: | ||
text = "'''This title is currently a redirect ''' to [[" .. target .. "]]; click there to go to the current target. The full content of this redirect page, including all [[Wikipedia:Categorizing redirects|redirect categories]], is displayed below." | text = "'''This title is currently a redirect ''' to [[" .. target .. "]]; click there to go to the current target. The full content of this redirect page, including all [[Wikipedia:Categorizing redirects|redirect categories]], is displayed below." | ||
}) | }) | ||
mw.log(target) | |||
else | else | ||
redirbox = messageBox.main('mbox', { | redirbox = messageBox.main('mbox', { | ||
Line 138: | Line 140: | ||
local substText = "{{<includeonly>safesubst:</includeonly>#invoke:RfD||%s%s|%s%s\n" | local substText = "{{<includeonly>safesubst:</includeonly>#invoke:RfD||%s%s|%s%s\n" | ||
.. "<!-- The above content is generated by {{subst: | .. "<!-- The above content is generated by {{subst:rfd}}. -->\n<!-- End of RFD message. Don't edit anything above here. Feel free to edit below here, but do NOT change the redirect's target. -->|content=\n%s\n" | ||
.. "<!-- Don't add anything after this line unless you're drafting a disambiguation page or article to replace the redirect. -->\n}}" | .. "<!-- Don't add anything after this line unless you're drafting a disambiguation page or article to replace the redirect. -->\n}}" | ||
local dateText = 'month = %B\n|day = %e\n|year = %Y\n|time = %R\n|timestamp = %Y%m%d%H%M%S' | local dateText = 'month = %B\n|day = %e\n|year = %Y\n|time = %R\n|timestamp = %Y%m%d%H%M%S' | ||
Line 145: | Line 147: | ||
function p.main(frame) | function p.main(frame) | ||
local titleText | local titleText | ||
local | local pargs = getArgs(frame) | ||
local Date | local Date | ||
if pargs.days then | if pargs.days then | ||
Line 153: | Line 154: | ||
Date = os.date(dateText) | Date = os.date(dateText) | ||
end | end | ||
local retval = string.format(substText, pargs.FULLPAGENAME or pargs[1] or '', pargs.showontransclusion and '|showontransclusion=1' or '', Date, | local retval = string.format(substText, pargs.FULLPAGENAME or pargs[1] or '', pargs.showontransclusion and '|showontransclusion=1' or '', Date, frame:getParent():getTitle() == mw.title.getCurrentTitle().prefixedText and '|category=' or '', pargs.content or '') | ||
if mw.isSubsting() then | if mw.isSubsting() then | ||
return retval | return retval |