Module:Tfd links/sandbox: Difference between revisions
Appearance
Content deleted Content added
fix |
Trialpears (talk | contribs) Trying to reduce peis size |
||
Line 15: | Line 15: | ||
function p.main(frame) |
function p.main(frame) |
||
local args = frame.args |
local args = frame:getParent().args |
||
local ns = ((args[ |
local ns = ((args['module'] and args['module'] ~= '') and 'Module') |
||
or ((args[3] and args[3] ~= '') and 'Module') |
|||
or 'Template' |
or 'Template' |
||
local tname = ' |
local tname = mw.getContentLanguage():ucfirst(args['1']) |
||
if (args[1] ~= nil and args[1] ~= '') then |
|||
tname = mw.getContentLanguage():ucfirst(args[1]) |
|||
end |
|||
local fname = ns .. ':' .. tname |
local fname = ns .. ':' .. tname |
||
local ymd = args[2] or '' |
local ymd = args['2'] or '' |
||
local fullpagename = (ymd ~= '') |
local fullpagename = (ymd ~= '') |
||
and 'WP:Templates for discussion/Log/' .. ymd |
and 'WP:Templates for discussion/Log/' .. ymd |
||
Line 40: | Line 36: | ||
end |
end |
||
res = res .. fullurllink(fname, 'action=edit', 'edit') .. sep |
res = res .. fullurllink(fname, 'action=edit', 'edit') .. sep |
||
.. '[[' .. ns .. ' talk:' .. tname .. '|talk]]' .. sep |
|||
.. fullurllink(fname, 'action=history', 'history') .. sep |
|||
⚫ | |||
if ns ~= 'Category' then |
|||
.. fullurllink('Special:Log', 'page=' .. urlencode(fname), 'logs') .. sep |
|||
⚫ | |||
⚫ | |||
res = res .. fullurllink('Special:Whatlinkshere/' |
|||
.. fname, 'limit=5000&hidelinks=1', 'transclusions') .. sep |
|||
end |
|||
res = res .. fullurllink('Special:Log', 'page=' |
|||
.. urlencode(fname), 'logs') .. sep |
|||
⚫ | |||
res = res .. '<span class="sysop-show">' .. sep .. fullurllink(fname, 'action=delete&wpReason=' |
|||
.. urlencode('[[' .. fullpagename .. '#' .. fname .. ']]'), 'delete') .. '</span>' |
|||
res = res .. ')</span>' |
|||
return res |
return res |
Revision as of 17:31, 27 July 2021
![]() | This is the module sandbox page for Module:Tfd links (diff). |
![]() | This Lua module is used on approximately 6,400 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Implements {{Tfd links}}
-- 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['module'] and args['module'] ~= '') and 'Module')
or 'Template'
local tname = mw.getContentLanguage():ucfirst(args['1'])
local fname = ns .. ':' .. tname
local ymd = args['2'] or ''
local fullpagename = (ymd ~= '')
and 'WP:Templates for discussion/Log/' .. ymd
or frame:preprocess('{{FULLPAGENAME}}')
local sep = ' <b>·</b> '
local res = '<span id="' .. ns .. ':' .. tname
.. '" class="plainlinks nourlexpansion 1x">'
.. '[[:' .. ns .. ':' .. tname .. ']] ('
if ymd ~= '' then
local dmy = frame:expandTemplate{ title='date', args={ymd, 'dmy'} }
res = res .. '[[' .. fullpagename .. '#' .. fname
.. '|' .. dmy .. ']]) ('
end
res = res .. fullurllink(fname, 'action=edit', 'edit') .. sep
.. '[[' .. ns .. ' talk:' .. tname .. '|talk]]' .. sep
.. fullurllink(fname, 'action=history', 'history') .. sep
.. fullurllink('Special:Whatlinkshere/' .. fname, 'limit=5000', 'links') .. sep
.. fullurllink('Special:Log', 'page=' .. urlencode(fname), 'logs') .. sep
.. '[[Special:PrefixIndex/' .. fname .. '/|subpages]]'
return res
end
return p