Module:RfD

From Sarkarverse
Jump to navigation Jump to search

require('Module:No globals')

local p = {}

local getTargetFromText = require('Module:Redirect').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 deletion policy.
"
.. " Please share your thoughts on the matter at this redirect's entry on the Redirects for discussion page.
" .. " Click on the link below to go to the current destination page.
" .. "Please notify the good-faith creator and any main contributors of the redirect by placing {{subst:RFDNote|%s}} ~~~~ on their talk page." 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 local target = getTargetFromText(args.content) return string.format('%s%s%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(, currentTitle.text), target and mw.title.new(target) and or ) end

-- called if the redirect up for discussion is being transcluded p['1'] = function(frame) 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 local pframe = frame:getParent() -- We should actually be calling expandTemplate on the grandparent rather than on the parent, but we can't do that yet -- Since we don't have grandparent access, though, it means the thing we're calling doesn't either, so it doesn't really matter yet return pframe:expandTemplate{title = target.prefixedText, args = pframe.args} 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 = "Lua error at line 29: bad argument #2 to 'format' (string expected, got nil)." 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