Jump to content

Module:Tfd links: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Undid revision 1141747794 by Plastikspork (talk) Yes, it worked, but need to get consensus :)
Another possible option, see if this works :)
Tag: Reverted
Line 22: Line 22:
local fname = ns .. ':' .. tname
local fname = ns .. ':' .. tname
local fullpagename = frame:preprocess('{{FULLPAGENAME}}')
local fullpagename = frame:preprocess('{{FULLPAGENAME}}')
local sep = '&nbsp;<b>·</b> '
local sep = '&nbsp; '
local res = '<span id="' .. ns .. ':' .. tname
local res = '<span id="' .. ns .. ':' .. tname

Revision as of 16:12, 26 February 2023

-- This module implements [[Template:Tfd links]]
local p = {}

local function urlencode(text)
	-- Return equivalent of {{urlencode:text}}.
	local function byte(char)
		return string.format('%%%02X', string.byte(char))
	end
	return text:gsub('[^ %w%-._]', byte):gsub(' ', '+')
end

local function fullurllink(t, a, s)
	return '[//en.wikipedia.org/w/index.php?title=' .. urlencode(t) .. '&' .. a .. ' ' .. s .. ']'
end

function p.main(frame)
	local args = frame:getParent().args
	local ns = (((args['catfd'] and args['catfd'] ~= '') and 'Category') or
		(args['module'] and args['module'] ~= '') and 'Module')
		or  'Template'
	local tname = mw.getContentLanguage():ucfirst(args['1'])
	local fname = ns .. ':' .. tname
	local fullpagename = frame:preprocess('{{FULLPAGENAME}}')
	local sep = '&nbsp;• '
	
	local res = '<span id="' .. ns .. ':' .. tname 
	.. '" class="plainlinks nourlexpansion 1x">'
	.. '[[:' .. ns .. ':' .. tname .. ']]&nbsp;('
	.. '[[' .. ns .. ' talk:' .. tname .. '|talk]]' .. sep
	.. fullurllink(fname, 'action=history', 'history') .. sep
	.. fullurllink('Special:Whatlinkshere/' .. fname, 'limit=5000&hidelinks=1&hideredirs=1', 'transclusions') .. sep
	.. fullurllink('Special:Log', 'page=' .. urlencode(fname), 'logs') .. sep
	.. '[[Special:PrefixIndex/' .. fname .. '/|subpages]]<span class="sysop-show">' .. sep 
	.. fullurllink(fname, 'action=delete&wpReason=' .. urlencode('[[' .. fullpagename .. '#' .. fname .. ']]'), 'delete') .. '</span>)</span>'
	
	return res
end

return p