Module:RfD/sandbox explained

require('strict')

local p =

local getArgs = require('Module:Arguments').getArgslocal getTargetFromText = require('Module:Redirect').getTargetFromTextlocal 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 {{[[Wikipedia:Substitution|subst]]:[[Template:Rfd notice|Rfd notice]]|%s}} ~~~~ on their talk page."local deleteReason = ' debate closed as delete'local messageOnTransclusionsStandard = '‹The template below is included via a redirect' .. ' (%s) that is under discussion. See redirects for discussion' .. ' to help reach a consensus.›'local messageOnTransclusionsTiny = '‹See RfD›'

local function makeTransclusionTag(args, redirect) local discussionPage = args[1] and mw.text.trim(args[1]) if not discussionPage or discussionPage

then discussionPage = redirect end local visClasses = -- More can be added if justified by situation local sizeAttrs = local size = sizeAttrs[args.showontransclusion] and args.showontransclusion or 'standard' local tags = sizeAttrs[size]['tags'] local visibility = visClasses[args.transclusiontagvisibility] or local classes = 'class="boilerplate metadata plainlinks ' .. visibility .. '" ' local id = 'id="rfd-t" ' local style = 'style="background-color: transparent; padding: 0; font-size: xx-small; color: #000000;' .. 'text-align: left;' .. sizeAttrs[size]['style'] .. '" ' return tags[1] .. classes .. id .. style .. '>' .. sizeAttrs[size]['message'] .. tags[2]end

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) local isError = not target or not mw.title.new(target) local category if args.category then category = args.category elseif args.timestamp then -- Extract stable year and month from timestamp; args.month and args.year can change if the discussion is relisted (see) local lang = mw.language.getContentLanguage local catMonth = lang:formatDate('F', args.timestamp) local catYear = lang:formatDate('Y', args.timestamp) category = string.format('', catMonth, catYear, currentTitle.text, currentTitle.text) else category = string.format('', currentTitle.text, currentTitle.text) end if category then category = category..'' end return string.format('%s

%s%s%s', messageBox.main('mbox',), mw.uri.encode(deleteReason), category, isError and '' or )end

p[''] = function(frame) local args = getArgs(frame) if not args.content or mw.text.trim(args.content)

then return '

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.' end local pframe = frame:getParent if pframe:preprocess('1')

'1' then -- We're being transcluded, so display the content of our target. local target = getTargetFromText(args.content) if target then target = mw.title.new(target) end local redirect = pframe:getTitle if target and not target.isRedirect and target ~= redirect then -- 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 local parsedTarget = pframe:expandTemplate if frame.args.showontransclusion and not mw.isSubsting then return makeTransclusionTag(args, redirect) .. parsedTarget else return parsedTarget end end end -- We're not being transcluded, or we can't figure out how to display our target. -- Check if we can find the target. local target = getTargetFromText(args.content) messageBox = require('Module:Message box') local redirbox if target then -- target isn't nil local firstChar = string.sub(target, 1, 1) if firstChar ~= ":" then target = ":" .. target end redirbox = messageBox.main('mbox',) mw.log(target) else redirbox = messageBox.main('mbox',) end -- Display the RfD banner. return makeRfdNotice(frame.args) .. '\n' .. redirbox .. frame.args.contentend

local substText = ""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 pagefunction p.main(frame) local titleText local pargs = getArgs(frame) local Date if pargs.days then Date = os.date(dateText, os.time - 86400*pargs.days) else Date = os.date(dateText) end 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 return retval else return frame:expandTemplate .. frame:preprocess(retval) endend

return p