Module:RfD: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
fix error and use safesubst
Jackmcbarn (talk | contribs)
rm dead code, add newline, change format again, other fixes
Line 4:
local messageBox
 
local rfdTextmboxText = "'''The purpose of this redirect is currently being discussed by the Wikipedia community."
.. " The outcome of the discussion may result in a change of this page, or possibly its deletion in accordance with Wikipedia's [[Wikipedia:Deletion policy|deletion policy]].''' <br />"
.. " Please share your thoughts on the matter at '''[[Wikipedia:Redirects for discussion/Log/%s %s %s#%s|this redirect's entry]]''' on the [[Wikipedia:Redirects for discussion|Redirects for discussion]] page.<br />"
.. " '''Click on the link below''' to go to the current destination page.<br /><small>Please notify the good-faith creator and any main contributors of the redirect by placing <code>&#123;&#123;[[Wikipedia:Substitution|subst]]:[[Template:RFDNote|RFDNote]]&#124;%s&#125;&#125; &#126;&#126;&#126;&#126;</code> on their talk page.</small>"
local deleteReason = '[[Wikipedia:Redirects for discussion]] debate closed as delete'
 
local function makeRfdNotice(args)
local currentTitle = mw.title.getCurrentTitle()
Line 14 ⟶ 15:
messageBox = require('Module:Message box')
end
local discussionPage = args.name[1] and mw.text.trim(args.name[1])
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+deletes</span>%s',
messageBox.main('mbox', {
type = 'delete',
image = 'none',
text = string.format(rfdTextmboxText, args.year, args.month, args.day, discussionPage or currentTitle.prefixedText, currentTitle.prefixedText)
}),
args.category or string.format('[[Category:Redirects for discussion|%s]]', mw.uri.encode(deleteReason), currentTitle.text)
)
end
Line 33 ⟶ 34:
getTargetFromText = require('Module:Redirect').getTargetFromText
end
return frame:getParent():preprocess(mw.title.new(getTargetFromText(frame.args[1].content)):getContent())
end
 
-- called if the redirect up for discussion is being viewed
p[''] = function(frame)
return makeRfdNotice(frame.args) .. '\n' .. frame.args[1].content
end
 
local substText = '{{ {{{|safesubst:}}}#invoke:RfD|<includeonly>1</includeonly>|name = %s|%s\n'
.. '<!-- Do not use the "Rfd/core" template directly; theThe above linecontent is generated by {{subst:Rfdrfd}}. -->\n<!-- End of RFD message. FeelDon\'t edit anything above here, but feel free to edit beyondbelow this pointhere. -->|content=\n%s\n}}'
.. '<!-- Don\'t add anything after this line. -->\n}}'
local retvaldateText = 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])
 
-- called during subst when the template is initially placed on the page
function p.main(frame)
local titleText
iflocal pargs = frame:getParent().args.name then
if pargs[1] then
titleText = mw.title.new(frame.args.namepargs[1]).prefixedText
else
titleText = mw.title.getCurrentTitle().prefixedText
end
local dateretval = string.format(substText, titleText, os.date('*t'dateText), pargs.content)
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
else
return frame:expandTemplate{title = 'Template:Error:must be substituted', args = {'Rfdrfd'}} .. frame:preprocess(retval)
end
return frame:expandTemplate{title = 'Template:Error:must be substituted', args = {'Rfd'}} .. frame:preprocess(retval)
end