Module:T-TLD: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 96: | Line 96: | ||
end | end | ||
-- Custom title row based on whether the TLD is "g" or a "cc" | |||
-- | template.config.blocks = template.config.blocks or {} | ||
template.config. | template.config.blocks.title = { | ||
template.config. | feature = 'title', | ||
return | render = function(template, args) | ||
return Blueprint.protectedExecute( | |||
template | template, | ||
'CustomBlock_title', | |||
function() | |||
local titleText = (args._type == 'ccTLD') and 'ccTLD' or 'gTLD' | |||
return TemplateHelpers.renderTitleBlock( | |||
args, | |||
template.config. | 'template-title template-title-tld', | ||
titleText, | |||
template.config.meta and template.config.meta.titleOptions or {} | |||
template.config. | ) | ||
end, | |||
end | '', | ||
args | |||
) | |||
end | end | ||
} | |||
-- | -- PIC/RVC link processor | ||
template.config.processors.RVC = function(value, args) | template.config.processors.RVC = function(value, args) | ||
local val = tostring(value) | local val = tostring(value) | ||
| Line 131: | Line 132: | ||
template.config.processors.PIC = template.config.processors.RVC | template.config.processors.PIC = template.config.processors.RVC | ||
-- | -- IDN property provider | ||
Blueprint.registerPropertyProvider(template, function(template, args) | Blueprint.registerPropertyProvider(template, function(template, args) | ||
local props = {} | local props = {} | ||
| Line 137: | Line 138: | ||
return props | return props | ||
end) | end) | ||
-- IDN detection preprocessor | -- IDN detection preprocessor | ||
| Line 161: | Line 161: | ||
return args | return args | ||
end | end | ||
-- Field Processors | |||
template.config.processors = template.config.processors or {} | |||
template.config.processors.tld_type = function(value, args) | |||
return select(1, getCanonicalForms().normalize(value, template.config.mappings.tld_type)) or value | |||
end | |||
template.config.processors.tld_subtype = function(value, args) | |||
return select(1, getCanonicalForms().normalize(value, template.config.mappings.tld_subtype)) or value | |||
end | |||
template.config.processors.introduced = function(value, args) | |||
return TemplateHelpers.formatDateRange(value, nil, {outputMode='text'}) | |||
end | |||
template.config.processors.implemented = function(value, args) | |||
return TemplateHelpers.formatDateRange(value, nil, {outputMode='text'}) | |||
end | |||
template.config.processors.website = function(value, args) | |||
return TemplateHelpers.normalizeWebsites(value) | |||
end | |||
template.config.processors.country = function(value, args) | |||
return TemplateHelpers.normalizeCountries(value) | |||
end | |||
-- Category Provider | |||
Blueprint.registerCategoryProvider(template, function(template, args) | |||
local cats = {} | |||
local cond = template.config.categories and template.config.categories.conditional or {} | |||
if cond.rvc and ((args.RVC and args.RVC ~= "") or (args.PIC and args.PIC ~= "")) then | |||
table.insert(cats, cond.rvc) | |||
end | |||
if args._idnFlag and cond.idn then | |||
table.insert(cats, cond.idn) | |||
end | |||
if args._idnFlag and args._type == "ccTLD" and cond.idn_cctld then | |||
table.insert(cats, cond.idn_cctld) | |||
end | |||
-- Type mapping categories | |||
for _, cat in ipairs(getSemanticCategoryHelpers().addMappingCategories(args._type, template.config.mappings.tld_type) or {}) do | |||
table.insert(cats, cat) | |||
end | |||
-- Subtype mapping categories | |||
for _, cat in ipairs(getSemanticCategoryHelpers().addMappingCategories(args._type, template.config.mappings.tld_subtype) or {}) do | |||
table.insert(cats, cat) | |||
end | |||
return cats | |||
end) | |||
-- ================================================================================ | -- ================================================================================ | ||