Module:TfdLinks

From BadWolfMC Wiki
Revision as of 23:09, 17 May 2018 by Merc (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local function urlencode(text) -- Return equivalent of 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 '.. 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'] or 'Example') local fname = ns .. ':' .. tname local ymd = args['2'] or local fullpagename = (ymd ~= ) and 'WP:Templates for discussion/Log/' .. ymd or frame:preprocess('Module:TfdLinks') local sep = ' · '

local res = '' .. '' .. 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 res = res .. 'talk' .. sep res = res .. fullurllink(fname, 'action=history', 'history') .. sep if ns ~= 'Category' then res = res .. fullurllink('Special:Whatlinkshere/' .. fname, 'limit=5000', 'links') .. sep end res = res .. fullurllink('Special:Log', 'page=' .. urlencode(fname), 'logs') .. sep res = res .. 'subpages' res = res .. '' .. sep .. fullurllink(fname, 'action=delete&wpReason=' .. urlencode('' .. fullpagename .. '#' .. fname .. ''), 'delete') .. '' res = res .. ')'

return res end

return p