Difference between revisions 51821 and 51822 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)function p._startBox(args, env)
	-- Generate [view][edit][history][purge] or [create] links.
	local links
	local content = args.content
	if not content then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if 
type(linksData) == 'table' then
			links = p.renderStartBoxLinks(linksData)
		else
			-- linksData is nil or an error message.
			return linksData
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if type(data) == 'table'data then
		return p.renderStartBox(data)
	elseif type(data) == 'string' then
		-- data is an error message.
		return data
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	local data = {}
(contracted; show full)		ret = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
	end
end

function p.makeStartBoxData(args, env, links)
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		
return nil-- Default to an "other namespaces" namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
(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