Module:ConfigRepository
Documentation for this module may be created at Module:ConfigRepository/doc
-- Module:ConfigRepository
-- Central repository for template configurations that works with TemplateHelpers
-- This module acts as a single source of truth for configurations across all templates
local p = {}
-- Store all template configurations in this table
p.templates = {
-- Event template configuration
Event = {
meta = {
description = "Module for rendering Event templates with automatic event navigation"
},
constants = {
-- Default date formats
dateFormats = {
display = "%d %B %Y", -- e.g., "15 March 2025"
semantic = "%Y-%m-%d" -- ISO format for semantic properties
}
},
patterns = {
-- Patterns for event navigation detection
seriesNumber = "^([%w%s]+)%s+(%d+)$", -- e.g., "ICANN 76"
seriesYear = "^([%w%s]+)%s+(%d%d%d%d)$", -- e.g., "IGF 2023"
-- Patterns for multi-value fields
itemDelimiter = ";%s*", -- Semicolon delimiter for lists
dateRange = "(%d%d?%s+%w+%s+%d%d%d%d)" -- Date pattern for ranges
},
fields = {
{key="logo", label="Logo"},
{key="process", label="Process"},
{key="start", label="Start Date"},
{key="end", label="End Date"},
{key="region", label="Region"},
{keys={"country", "territory"}, label="Country"},
{key="city", label="City"},
{key="venue", label="Venue"},
{key="organizer", label="Organizer"},
{keys={"website", "url"}, label="Website"},
{keys={"subject", "category"}, label="Subject"}
},
semantics = {
-- Property mappings (semantic property to template field)
properties = {
["Has event start date"] = "start",
["Has event end date"] = "end",
["Part of process"] = "process",
-- "Has country" and "Has ICANN region" handled by CountryData.addCountrySemanticProperties
["Has city"] = "city",
["Has venue"] = "venue",
["Has event organizer"] = "organizer"
-- "Has event subject" temporarily removed
},
-- Additional properties for special cases
additionalProperties = {
["Has country"] = {"country", "territory"}
-- "Has event subject" temporarily removed
},
-- Transformation functions for properties
transforms = {
["Has event start date"] = function(value)
return tostring(require('Module:DateNormalization').formatDate(value))
end,
["Has event end date"] = function(value)
return tostring(require('Module:DateNormalization').formatDate(value))
end
}
}
},
-- Person template configuration
Person = {
meta = {
description = "Renders profiles of people with a carousel for multiple images, supporting various normalizations"
},
mappings = {
community = {
{canonical = "ICANN Community",
synonyms = {"icann community", "icann", "community"},
category = "[[Category:ICANN Community]]"},
{canonical = "ICANN Staff",
synonyms = {"icann staff", "staff"},
category = "[[Category:ICANN Staff]]"},
{canonical = "Root Server Operator Community",
synonyms = {"root server operator community", "root server operator", "rso"},
category = "[[Category:Root Server Operator Community]]"},
{canonical = "RIR Community",
synonyms = {"rir community", "rir"},
category = "[[Category:RIR Community]]"},
{canonical = "Universal Acceptance Community",
synonyms = {"universal acceptance community", "universal acceptance", "ua"},
category = "[[Category:Universal Acceptance Community]]"},
{canonical = "ISOC Community",
synonyms = {"isoc community", "isoc"},
category = "[[Category:ISOC Community]]"},
{canonical = "IETF Member",
synonyms = {"ietf member", "ietf"},
category = "[[Category:IETF Member]]"},
{canonical = "W3C Community",
synonyms = {"w3c community", "w3c"},
category = "[[Category:W3C Community]]"},
{canonical = "IGF Community",
synonyms = {"igf community", "igf"},
category = "[[Category:IGF Community]]"},
{canonical = "Governmental",
synonyms = {"governmental", "government"},
category = "[[Category:Governmental]]"},
{canonical = "Intergovernmental",
synonyms = {"intergovernmental"},
category = "[[Category:Intergovernmental]]"}
}
},
fields = {
{key="community", label="Community"},
{key="affiliation", label="ICANN group"},
{key="organization",label="Organization"},
{key="region", label="Region"},
{key="country", label="Country"},
{key="languages", label="Languages"},
{key="website", label="Website"},
{key="soi", label="SOI"},
{key="userbox", label="Achievements"}
},
patterns = {
itemDelimiter = ";%s*",
websitePattern = "^https?://[^%s]+"
},
semantics = {
-- Property mappings (semantic property to template field)
properties = {
["Has community"] = "community",
["Has ICANN affiliation"] = "affiliation",
["Has organization"] = "organization",
-- "Has ICANN region", "Has country", "Speaks language", are all handled separately
},
-- Additional properties for special cases
additionalProperties = {
-- Handle multiple countries and regions in the special case handlers
["Has country"] = {"country"},
["Has ICANN region"] = {"region"}
},
-- Transformation functions for properties
transforms = {
["Has community"] = function(value)
local CanonicalForms = require('Module:CanonicalForms')
return select(1, CanonicalForms.normalize(value, p.templates.Person.mappings.community)) or value
end,
["Speaks language"] = function(value)
-- Return raw value, the semantic property should store the raw data
return value
end
}
}
}
}
-- Get configuration for a specific template type
function p.getConfig(templateType)
return p.templates[templateType] or {}
end
-- Get a standard config object for use with existing template modules
-- This integrates with TemplateHelpers.createStandardConfig
function p.getStandardConfig(templateType, customOverrides)
local TemplateHelpers = require('Module:TemplateHelpers')
-- Get the base configuration
local baseConfig = p.getConfig(templateType)
-- Create a standard config using TemplateHelpers
return TemplateHelpers.createStandardConfig(baseConfig, customOverrides)
end
return p