Module:User:AnomieBOT/TFDTemplateSubster/row

From blackwiki
Revision as of 07:41, 1 February 2020 by blackwiki>Anomie (Protected "Module:User:AnomieBOT/TFDTemplateSubster/row": User request within own user space ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite)))
Jump to navigation Jump to search
local p = {}

function p.main( frame )
	local args = frame:getParent().args
	local tmpl = args[1]
	if tmpl == nil then
		return '* <strong class="error">Row template missing target template name!</strong>\n'
	end
	
	local link, logpage
	if args['link'] then
		link = args['link']
		logpage = string.gsub( link, '#.*', '' )
	else
		if args[2] == nil then
			return '* <strong class="error">Row template missing link or TFD date!</strong>\n'
		end
		logpage = 'WP:Templates for discussion/Log/' .. args[2]
		link = logpage .. '#' .. ( args['section'] or args[1] )
	end
	local reason = ''
	if args['reason'] then
		reason = '|' .. args['reason']
	end
	
	local ret
	if string.sub( tmpl, 1, 9 ) == 'Template:' then
	    ret = '{{[[' .. tmpl .. '|' .. string.sub( tmpl, 10 ) .. ']]}}'
	else
	    ret = '{{[[:' .. tmpl .. ']]}}'
	end
	return '* ' .. ret .. ' per [[' .. link .. reason .. ']]<br><small>(' ..
        '<span class="plainlinks">[//en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/' .. mw.uri.encode( tmpl ) .. '&limit=999 links]</span>' ..
        '&nbsp;&#124; <span class="plainlinks">[//en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/' .. mw.uri.encode( tmpl ) .. '&limit=999&hidelinks=1 transclusions]</span>' ..
        '&nbsp;&#124; [[' .. string.gsub( tmpl, ':', ' talk:', 1 ) .. '|talk]]' ..
        '&nbsp;&#124; [[' .. tmpl .. '/doc|doc]]' ..
        '&nbsp;&#124; [[' .. tmpl .. '/sandbox|sandbox]]' ..
        '&nbsp;&#124; [[' .. tmpl .. '/testcases|testcases]]' ..
	    ')</small>'
end

return p