PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Community: Difference between revisions

From PC Gaming Shelter
No edit summary
No edit summary
Line 55: Line 55:
local infobox    = utils.createInfobox(frame, category, properties, sections, footer)
local infobox    = utils.createInfobox(frame, category, properties, sections, footer)
return infobox
return infobox
end
local function clean(value)
if value == nil then
return nil
end
value = mw.text.trim(tostring(value))
return value ~= '' and value or nil
end
function p.yearsActive(frame)
local args = frame.args
local from = clean(args['from'])
local until_year = clean(args['until'])
if from and until_year then
if from == until_year then
return from
end
return from .. '–' .. until_year
elseif from then
return from .. '–present'
elseif until_year then
return 'until ' .. until_year
end
return ''
end
end


return p
return p

Revision as of 15:58, 15 June 2026

Documentation for this module may be created at Module:Community/doc

local utils = require( 'Module:Utils' )

local p = {}

local function propertiesPlan()
	-- ['Form field name'] = { 'Semantic property', 'delimiter' }
	local propMap = {
		['Image']               = {'Image', 'file' },
		['Related game']        = {'Related game' },
		['Has status']          = {'Has status' },
		['Has short description'] = {'Has short description' }
	}
	return propMap
end

local function infoboxSectionPlan()
	local sectionMap = {
		['Cover image'] = {
			heading = '',
			template = 'Infobox/Cover',
			order = '1',
			rows = {
				'Image'
			}
		},
		['Clan Info'] = {
			heading = 'Community Info',
			template = 'Infobox/Community Info',
			order = '2',
			rows = {
				'Related game',
				'Has status',
				'Years active from',
				'Years active until',
				'Has short description'
			}
		},
		['Community links'] = {
			heading = 'Join',
			template = 'Infobox/Community links',
			order = '3',
			rows = {
				'Community links'
			}
		}
	}
	return sectionMap
end

function p.infobox(frame)
	local category   = 'Communities'
	local properties = propertiesPlan()
	local sections   = infoboxSectionPlan()
	local footer     = 'Community footer'
	local infobox    = utils.createInfobox(frame, category, properties, sections, footer)
	return infobox
end

local function clean(value)
	if value == nil then
		return nil
	end

	value = mw.text.trim(tostring(value))
	return value ~= '' and value or nil
end

function p.yearsActive(frame)
	local args = frame.args
	local from = clean(args['from'])
	local until_year = clean(args['until'])

	if from and until_year then
		if from == until_year then
			return from
		end
		return from .. '–' .. until_year
	elseif from then
		return from .. '–present'
	elseif until_year then
		return 'until ' .. until_year
	end

	return ''
end

return p