Icona de documentació de mòdul Documentació del mòdul [ mostra ] [ modifica el codi ] [ mostra l'historial ] [ refresca ]

Mòdul RfD (codi · ús · discussió · proves · tests · casos prova | subpàgines · enllaços)

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Implementa {{Redirecció a discutir}}.

Cridat des de Mòdul:Redirect-distinguish.

Sintaxi

modifica

{{#invoke:RfD|function_name}}</includeonly

require('strict')

local p = {}

local getTargetFromText = require('Module:Redirect').getTargetFromText
local messageBox

local mboxText = "'''El propòsit d'aquesta redirecció està sent discutit actualment per la comunitat de la Viquipèdia."
  .. " El resultat de la discussió pot provocar un canvi d'aquesta pàgina, o possiblement la seva supressió d'acord amb la [[Viquipèdia:Esborrar pàgines|política d'eliminació]] de la Viquipèdia.''' <br />"
  .. " Si us plau, comparteix els teus pensaments sobre el tema a l''''[[:en:Wikipedia:Redirects for discussion/Log/%s %s %s#%s|entrada d'aquesta redirecció]]''' a la [[:en:Wikipedia:Redirects for discussion|Redireccions per a la discussió]] pàgina.<br />"
  .. " '''Feu clic a l'enllaç de sota''' per anar a la pàgina de destinació actual.<br />"
  .. "<small>Si us plau, aviseu el creador de bona fe i els col·laboradors principals de la redirecció col·locant <code>&#123;&#123;[[Wikipedia:Substitution|subst]]:[[Template:Rfd notice| Avís de Rfd]]&#124;%s&#125;&#125; &#126;&#126;&#126;&#126;</code> a la seva pàgina de discussió.</small>"
local deleteReason = '[[:en:Wikipedia:Redirects for discussion]] debat tancat com a suprimit'
local messageOnTransclusionsStandard = "&lsaquo;La plantilla següent s'inclou mitjançant una redirecció"
    .. ' (%s) que està en discussió. Vegeu [[:en:Wikipedia:Redirects for discussion/Log/%s %s %s#%s|redireccions a discutir]]'
    .. ' per ajudar a arribar a un consens.&rsaquo;'
local messageOnTransclusionsTiny = '&lsaquo;[[:en:Wikipedia:Redirects for discussion/Log/%s %s %s#%s|Vegeu RaD]]&rsaquo;'

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 = {
		['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;',
			['message'] = messageOnTransclusionsStandard:format(redirect, args.year, args.month, args.day, discussionPage)
		},
		['tiny'] = {
			['tags'] = {' <span ', '</span> '},
			['style'] = '',
			['message'] = messageOnTransclusionsTiny:format(args.year, args.month, args.day, discussionPage)
		}
	}
	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 [[Special:Diff/896302321]])
                local lang = mw.language.getContentLanguage()
                local catMonth = lang:formatDate('F', args.timestamp)
                local catYear = lang:formatDate('Y', args.timestamp)
		category = string.format('[[Categoria:Redireccions a discustir des de %s %s|%s]][[Categoria:Totes les redireccions a discustir|%s]]', catMonth, catYear, currentTitle.text, currentTitle.text)
	else
		category = string.format('[[Categoria:Redireccions a discustir|%s]][[Categoria:Totes les redireccions a discustir|%s]]', currentTitle.text, currentTitle.text)
	end
	if category then category = category..'[[Categoria:Explotacions de manteniment temporal]]' end
	return string.format('%s<span id="delete-reason" style="display: none;">%s</span>%s%s',
		messageBox.main('mbox', {
			type = 'delete',
			name = 'RfD',
			image = 'none',
			text = string.format(mboxText, args.year, args.month, args.day, discussionPage or currentTitle.prefixedText, mw.text.nowiki(currentTitle.prefixedText))
		}),
		mw.uri.encode(deleteReason),
		category,
		isError and '[[Categoria:Errors RaD]]' or ''
	)
end

p[''] = function(frame)
	local args = frame.args
	if not args.content or mw.text.trim(args.content) == '' then
		return '<span class="error">Error:'.." No s'ha proporcionat cap contingut. El text original de la pàgina (la línia #REDIRECT i qualsevol plantilla) s'ha de col·locar dins del paràmetre de contingut.[[Categoria:Errors RaD]]</span>"
	end
	local pframe = frame:getParent()
	if pframe:preprocess('<includeonly>1</includeonly>') == '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{title = ':' .. target.prefixedText, args = pframe.args}
			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', {
			type = 'notice',
			name = 'RedirectBox',
			image = '[[File:Symbol redirect blue.svg|40px]]',
			text = "'''Aquest títol és actualment una redirecció ''' a [[" .. target .. "]]; feu clic allà per anar a l'objectiu actual. El contingut complet d'aquesta pàgina de redirecció, incloses totes les [[Wikipedia:Categorizing redirects|categories de redirecció]], es mostra a continuació."
		})
	else
		redirbox = messageBox.main('mbox', {
			type = 'notice',
			name = 'RedirectBox',
			image = '[[File:Symbol redirect vote 4.svg|40px]]',
			text = "'''No s'ha pogut determinar l'objectiu d'aquesta redirecció.''' Aquesta pàgina pot ser una [[:en:Wikipedia:Soft redirect|redirecció suau]], o no ser una redirecció. El contingut de la pàgina es mostra a continuació."
		})
	end
	-- Display the RfD banner.
	return makeRfdNotice(frame.args) .. '\n' .. redirbox .. frame.args.content
end

local substText = "{{<includeonly>safesubst:</includeonly>#invoke:RfD||%s%s|%s%s\n"
	.. "<!-- The above content is generated by {{subst:Rfd}}. -->\n<!-- End of RFD message. Don't edit anything above here. Feel 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'

-- 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 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, pframe:getTitle() == mw.title.getCurrentTitle().prefixedText and '|category=' or '', pargs.content or '')
	if mw.isSubsting() then
		return retval
	else
		return frame:expandTemplate{title = 'Plantilla:Error:must be substituted', args = {'rfd'}} .. frame:preprocess(retval)
	end
end

return p