Module:ConfigRepository: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 162: | Line 162: | ||
-- Return raw value, the semantic property should store the raw data | -- Return raw value, the semantic property should store the raw data | ||
return value | return value | ||
end | |||
} | |||
} | |||
}, | |||
-- TLD template configuration | |||
TLD = { | |||
meta = { | |||
description = "Versatile module for rendering TLD/ccTLD article templates with extensive normalization and dynamic content" | |||
}, | |||
mappings = { | |||
type = { | |||
{canonical = "gTLD", | |||
synonyms = {"gtld", "generic", "tld", "generic top level domain", "generic top-level domain", "generic tld"}, | |||
category = "[[Category:gTLD]]"}, | |||
{canonical = "ccTLD", | |||
synonyms = {"cctld", "country", "cc", "country code top level domain", "country code top-level domain", "country tld"}, | |||
category = "[[Category:ccTLD]]"} | |||
}, | |||
subtype = { | |||
{canonical="geoTLD", | |||
synonyms={"geotld","geo tld","geo","geographic","geographical","geographic top level domain","geographic top-level domain","geographic tld"}, | |||
css="tld-template-subtype-geotld", | |||
category="[[Category:geoTLD]]"}, | |||
{canonical="dotBrand", | |||
synonyms={"dotbrand","brand","brandtld","brand tld","brand top level domain","brand top-level domain"}, | |||
css="tld-template-subtype-brandtld", | |||
category="[[Category:dotBrand]]"}, | |||
{canonical="Sponsored TLD", | |||
synonyms={"sponsored tld","sponsored","sponsored top level domain","sponsored top-level domain"}, | |||
css="tld-template-subtype-sponsored", | |||
category="[[Category:Sponsored TLD]]"}, | |||
{canonical="Legacy TLD", | |||
synonyms={"legacy","legacy tld","legacy top level domain","legacy top-level domain"}, | |||
css="tld-template-subtype-legacytld", | |||
category="[[Category:Legacy TLD]]"}, | |||
{canonical="2012 gTLD Round", | |||
synonyms={"2012 gtld round", "gtld round 2012","2012 ngtld round","2012 ngtld","ngtld 2012","ngtld","2012"}, | |||
css="tld-template-subtype-ngtld-round-2012", | |||
category="[[Category:2012 gTLD Round]]"} | |||
} | |||
}, | |||
constants = { | |||
legacyTLDs = { | |||
com=true,net=true,org=true,edu=true,gov=true,mil=true,int=true,info=true, | |||
aero=true,asia=true,cat=true,coop=true,jobs=true,mobi=true,museum=true, | |||
post=true,tel=true,travel=true,xxx=true | |||
} | |||
}, | |||
patterns = { | |||
tldExtension="%.([^%.]+)$", | |||
countryDelimiter="([^;]+)" | |||
}, | |||
fields = { | |||
{key="type",label="Type"}, | |||
{key="subtype",label="Subtype"}, | |||
{key="status",label="Status"}, | |||
{keys={"country", "territory"},label="Country"}, | |||
{key="introduced",label="Introduced"}, | |||
{keys={"date", "implemented"},label="Implemented"}, | |||
{keys={"script", "language"},label="Script"}, | |||
{key="translation",label="English version"}, | |||
{key="ascii",label="Punycode"}, | |||
{keys={"registry", "registryprovider"},label="Registry"}, | |||
{key="website",label="Website"}, | |||
{keys={"RVC", "PIC"},label="PIC/RVC"} | |||
}, | |||
semantics = { | |||
-- Property mappings (semantic property to template field) | |||
properties = { | |||
["Has TLD type"] = "type", | |||
["Has TLD subtype"] = "subtype", | |||
["Has TLD status"] = "status", | |||
-- "Has country" is handled separately through addMultiCountrySemanticProperties | |||
["Date introduced"] = "introduced", | |||
["Date implemented"] = "date", -- Will also handle implemented | |||
["Uses writing script"] = "script", -- Will also handle language | |||
["Has registry operator"] = "registry", -- Will also handle registryprovider | |||
["Has PIC/RVC"] = "RVC" -- Will also handle PIC | |||
-- "Is IDN" is handled separately as a boolean property | |||
}, | |||
-- Additional properties for special cases | |||
additionalProperties = { | |||
["Has country"] = {"country", "territory"}, | |||
["Date implemented"] = {"date", "implemented"}, | |||
["Uses writing script"] = {"script", "language"}, | |||
["Has registry operator"] = {"registry", "registryprovider"}, | |||
["Has PIC/RVC"] = {"RVC", "PIC"} | |||
}, | |||
-- Transformation functions for properties | |||
transforms = { | |||
["Has TLD type"] = function(value) | |||
local CanonicalForms = require('Module:CanonicalForms') | |||
return select(1, CanonicalForms.normalize(value, p.templates.TLD.mappings.type)) or value | |||
end, | |||
["Has TLD subtype"] = function(value) | |||
local CanonicalForms = require('Module:CanonicalForms') | |||
return select(1, CanonicalForms.normalize(value, p.templates.TLD.mappings.subtype)) or value | |||
end, | |||
["Date introduced"] = function(value) | |||
return tostring(require('Module:DateNormalization').formatDate(value)) | |||
end, | |||
["Date implemented"] = function(value) | |||
return tostring(require('Module:DateNormalization').formatDate(value)) | |||
end | end | ||
} | } | ||