Jump to content

Module:Workspace intro

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by James Hare (NIOSH) (talk | contribs) at 20:42, 15 January 2024 (specify Template namespace). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.build(frame)
	local title = ''
	local intro = ''
	local image = ''
	local navigation = ''
	local color = '#6af' -- default value
	local displaymode = 'normal' -- default value
	for key, value in pairs(frame:getParent().args) do  -- iterate through arguments, pick out values
		if key == 'title' then
			title = value
		elseif key == 'intro' then
			intro = value
		elseif key == 'image' then
			image = value
		elseif key == 'navigation' then
			navigation = value
		elseif key == 'color' then
			color = value
		end
	end

	-- Rendering table of contents and body
	local body = ""

	-- Adding header
	local header = "__NOTOC__\n<div style='display: flex; flex-flow: row wrap;'>" -- top container
	header = header .. "<div style='flex: 1 0; padding-bottom: 3em; border-top: solid .7em " .. color .. ";'>" -- intro
	-- Adding project icon
	header = header .. "<div class='nomobile' style='float:left; margin-top: 1em; margin-right: 2em; margin-bottom: 1em; text-align: center;'>"
	header = header .. image .. "</div>"
	-- Adding project title
	header = header .. "<div style='font-size: 120%; padding: 0;'>" -- header
    header = header .. "<h1 style='font-weight: bold; border-bottom: none; margin:0; padding-top:0.5em;'>" .. title .. "</h1></div>"
	-- Adding intro blurb
	header = header .. "<div style='margin-top: 1em; font-size: 110%;'>"
	header = header .. intro .. "</div>"
	-- Adding navigation header
	if mw.title.makeTitle(navigation).exists == true then
		header = header .. frame:expandTemplate{ 'Template', navigation, args = { } }
	end
	header = header .. "</div>"
	-- Adding member box
	header = header .. "<div style='flex: 0 1 20em;'>"
	header = header .. frame:expandTemplate{ title = 'WPX participants box', args = { } }
	header = header .. "</div>"
	-- Closing off header
	header = header .. "</div>"

	-- Return header
	return header
end

return p