Difference between revisions 51813 and 51814 on wikimaniawiki

-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local htmlBuilder = require('Module:HtmlBuilder')
local messageBox = require('Module:Message box')

-- Get the config table.
(contracted; show full)end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

function p.sandboxNotice(args, env)
	local 
sandboxNoticeTemplate = message('sandboxNoticeTemplate', 'string')
	if not (sandboxNoticeTtitle = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	if not (title and sandboxTitle and templateTitle and envmw.title.subpageText =equals(title, sandboxTitle)) then
		return nil
	end
	local omargs = {} -- Args for {{ombox}}.
	-- Get the image wikitext.
	omargs.image = message('sandboxSubpNoticeImage', 'string')) then
		return nil
	end
	local frame = mw.getCurrentFrame()
	local notice = htmlBuilder.create()
	notice
		.tag('div')
			.css('clear', 'both')
			.done()
		.wikitext(frame:expandTemplate{title = sandboxNoticeTemplate, args = {[message('sandboxNoticeLivepageParam')] = args.livepage}})
	return tostring(notice
	-- Get the text. We start with the opening blurb, which is something like
	-- "This is the template sandbox for [[Template:Foo]] (diff)."
	local text = ''
	local frame = mw.getCurrentFrame()
	local isPreviewing = frame:callParserFunction('REVISIONID') == '' -- True if the page is being previewed.
	local templateLink = makeWikilink(templateTitle.prefixedText)
	if isPreviewing then
		-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1.'
		text = text .. message('sandboxNoticeBlurb', 'string', {templateLink})
	else
		-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1 ($2).'
		text = text .. message('sandboxNoticeDiffBlurb', 'string', {templateLink, env.compareLink})
	end
	-- Get the test cases page blurb if the page exists.
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		local testcasesLinkDisplay = message('sandboxNoticeTestcasesLinkDisplay', 'string')
		local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
		text = text .. ' ' .. message('sandboxNoticeTestcasesBlurb', 'string', {testcasesLink})
	end
	-- Add the page to [[Category:Template sandboxes]].
	text = text .. makeCategoryLink(message('sandboxCategory', 'string'))
	omargs.text = text
	return messageBox.main('ombox', omargs)
end

function p.protectionTemplate(env)
	local title = env.title
	local protectionTemplate = message('protectionTemplate', 'string')
	if not (protectionTemplate and title.namespace == 10) then
		-- Don't display the protection template if we are not in the template namespace.
(contracted; show full)
		local sort = (title.namespace == 0 and message('strangeUsageCategoryMainspaceSort', 'string') or '') .. title.prefixedText -- Sort on namespace.
		ret = ret .. makeCategoryLink(message('strangeUsageCategory', 'string'), sort)
	end
	return ret
end

return p