Module:RfD: Difference between revisions
Appearance
m Steel1943 moved page Module:RfD to Module:Rfd without leaving a redirect: To match name of template |
m Steel1943 moved page Module:Rfd to Module:RfD without leaving a redirect: Reverting for ... no idea. Lua is odd... |
(No difference)
|
Revision as of 21:47, 23 June 2014
![]() | This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is currently protected from editing. See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected. |
![]() | If you plan to make breaking changes to this module, move it, change scope, or nominate it for deletion or deprecation, please notify the Article Alerts project at Wikipedia talk:Article alerts as a courtesy, as this page is used by the AAlertBot bot to detect and report pages. Thank you! |
![]() | Any breaking changes to this template, including moving it or nominating it for deletion, must be communicated in advance to Twinkle's users and maintainers at Wikipedia talk:Twinkle. The standard installation of Twinkle relies on this template. Thank you. |
![]() | This module depends on the following other modules: |
Background
Implements {{Redirect for discussion}}.
Usage
{{#invoke:RfD|function_name}}
local p = {}
local getTargetFromText
local messageBox
local mboxText = "'''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>{{[[Wikipedia:Substitution|subst]]:[[Template:RFDNote|RFDNote]]|%s}} ~~~~</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()
if not messageBox then
messageBox = require('Module:Message box')
end
local discussionPage = args[1] and mw.text.trim(args[1])
if discussionPage == '' then
discussionPage = nil
end
return string.format('%s<span id="delete-reason" style="display:none;">%s</span>%s',
messageBox.main('mbox', {
type = 'delete',
image = 'none',
text = string.format(mboxText, args.year, args.month, args.day, discussionPage or currentTitle.prefixedText, currentTitle.prefixedText)
}),
mw.uri.encode(deleteReason),
args.category or string.format('[[Category:Redirects for discussion|%s]]', currentTitle.text)
)
end
-- called if the redirect up for discussion is being transcluded
p['1'] = function(frame)
if not getTargetFromText then
getTargetFromText = require('Module:Redirect').getTargetFromText
end
local target = getTargetFromText(frame.args.content)
if target then
target = mw.title.new(target)
end
if target and not target.isRedirect and target ~= mw.title.getCurrentTitle() then
return frame:getParent():preprocess(target:getContent())
else
return p[''](frame)
end
end
-- called if the redirect up for discussion is being viewed
p[''] = function(frame)
return makeRfdNotice(frame.args) .. '\n' .. frame.args.content
end
local substText = "{{ {{{|safesubst:}}}#invoke:RfD|<includeonly>1</includeonly>|%s|%s%s\n"
.. "<!-- The above content is generated by {{subst:rfd}}. -->\n<!-- End of RFD message. Don't edit anything above here, but feel free to edit below here. -->|content=\n%s\n"
.. "<!-- Don't add anything after this line. -->\n}}"
local dateText = 'month = %B\n|day = %e\n|year = %Y\n|time = %R\n|timestamp = %Y%m%d%H%M%S'
-- called during subst when the template is initially placed on the page
function p.main(frame)
local titleText
local pframe = frame:getParent()
local pargs = pframe.args
local retval = string.format(substText, pargs.FULLPAGENAME or pargs[1] or '', os.date(dateText), pframe:getTitle() == mw.title.getCurrentTitle().prefixedText and '|category=' or '', pargs.content or '')
if mw.isSubsting() then
return retval
else
return frame:expandTemplate{title = 'Template:Error:must be substituted', args = {'rfd'}} .. frame:preprocess(retval)
end
end
return p