Module:RfD: Difference between revisions

Content deleted Content added
merge changes from sandbox. simplifies standard transclusion message and adds a `tiny` variant
NOINDEX only if actually displaying the RfD notice
 
(16 intermediate revisions by 10 users not shown)
Line 1:
require('Module:No globalsstrict')
 
local p = {}
Line 8:
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|Redirectsredirects 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:Rfd notice|Rfd notice]]&#124;%s&#125;&#125; &#126;&#126;&#126;&#126;</code> on their talk page.</small>__EXPECTUNUSEDTEMPLATE__"
local deleteReason = '[[Wikipedia:Redirects for discussion]] debate closed as delete'
local messageOnTransclusionsStandard = '<div&lsaquo;The class="boilerplatetemplate metadatabelow plainlinks"is id="rfd-t"included style="via a redirect'
.. '&lsaquo; (%s) that is under discussion. See [[Wikipedia:Redirects for discussion/Log/%s %s %s#%s|Seeredirects RfDfor discussion]]&rsaquo;</span> '
.. 'background-color: transparent; padding: 0; font-size:xx-small; color:#000000; text-align:'
.. ' to help reach a consensus.&rsaquo;</div >'
.. 'left; border-bottom:1px solid #AAAAAA;">&lsaquo;The template below is included via a redirect'
local messageOnTransclusionsTiny ..= ' ([[%s]]) that is under discussion. See &lsaquo;[[Wikipedia:Redirects for discussion/Log/%s %s %s#%s|redirectsSee for discussionRfD]]&rsaquo;'
 
.. ' to help reach a consensus.&rsaquo;</div >'
local function makeTransclusionTag(args, redirect)
local messageOnTransclusionsTiny = ' <span class="boilerplate metadata plainlinks" id="rfd-t" style="'
local discussionPage = args[1] and mw.text.trim(args[1])
.. 'background-color: transparent; padding: 0; font-size:xx-small; color:#000000; text-align:left;">'
if not discussionPage or discussionPage == '' then
.. '&lsaquo;[[Wikipedia:Redirects for discussion/Log/%s %s %s#%s|See RfD]]&rsaquo;</span> '
discussionPage = redirect
end
local visClasses = {
['autoconfirmed']='autoconfirmed-show',
['extendedconfirmed']='extendedconfirmed-show sysop-show'
} -- More can be added if justified by situation
local sizeAttrs = {
['standard'] = {
['tags'] = {'<div ', '</div>'},
['style'] = ' border-bottom: 1px solid #AAAAAA;',
return['message'] = messageOnTransclusionsStandard:format(redirect, args.year, args.month, args.day, discussionPage) .. parsedTarget
},
['tiny'] = {
['tags'] = {'<span ', '</span> '},
['style'] = '',
return['message'] = messageOnTransclusionsTiny:format(args.year, args.month, args.day, discussionPage) .. parsedTarget
},
}
local size = sizeAttrs[args.showontransclusion] and args.showontransclusion or 'standard'
local tags = sizeAttrs[size]['tags']
local visibility = visClasses[args.transclusiontagvisibility] or ''
local messageOnTransclusionsTinyclasses = ' <span class="boilerplate metadata plainlinks" id="rfd-t' .. visibility .. '" style="'
local id = 'id="rfd-t" '
local style = 'style="font-size: 85%; 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()
Line 43 ⟶ 70:
category = string.format('[[Category:Redirects for discussion|%s]][[Category:All redirects for discussion|%s]]', currentTitle.text, currentTitle.text)
end
if category then category = category..'[[Category:Temporary maintenance holdings/RFD]]' end
local noindex = mw.getCurrentFrame():expandTemplate{title="NOINDEX"}
return string.format('%s%s<span id="delete-reason" style="display: none;">%s</span>%s%s',
noindex,
messageBox.main('mbox', {
type = 'delete',
Line 74 ⟶ 103:
-- 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{title = ':' .. target.prefixedText, args = pframe.args}
iflocal showontransclusion = frame.args.showontransclusion and not mw.isSubsting() then
showontransclusion = require('Module:Yesno')(showontransclusion, showontransclusion)
local discussionPage = args[1] and mw.text.trim(args[1])
if notshowontransclusion discussionPageand ornot discussionPage(showontransclusion == '' or mw.isSubsting()) then
return makeTransclusionTag(args, redirect) .. parsedTarget
discussionPage = redirect
end
if frame.args.showontransclusion == 'tiny' then
return messageOnTransclusionsTiny:format(args.year, args.month, args.day, discussionPage) .. parsedTarget
else
return messageOnTransclusionsStandard:format(redirect, args.year, args.month, args.day, discussionPage) .. parsedTarget
end
else
return parsedTarget
end
return parsedTarget
end
end
Line 95 ⟶ 117:
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', {
type = 'notice',
name = 'RedirectBox',
image = '[[File:Symbol redirect blue.svg|40px]]',
text = "'''This title is currently a redirect ''' to [[:" .. getTargetFromText(args.content)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."
})
else
Line 114 ⟶ 140:
 
local substText = "{{<includeonly>safesubst:</includeonly>#invoke:RfD||%s%s|%s%s\n"
.. "<!-- The above content is generated by {{subst:rfdRfd}}. -->\n<!-- End of RFD message. Don't edit anything above here,. but feelFeel 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}}"
local dateText = 'month = %B\n|day = %e\n|year = %Y\n|time = %R\n|timestamp = %Y%m%d%H%M%S'
Line 120 ⟶ 146:
-- 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