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"
-- === Field Processors ===
template.config.blocks = template.config.blocks or {}
template.config.processors = template.config.processors or {}
template.config.blocks.title = {
template.config.processors.tld_type = function(value, args)
feature = 'title',
     return select(1, getCanonicalForms().normalize(value, template.config.mappings.tld_type)) or value
render = function(template, args)
end
     return Blueprint.protectedExecute(
template.config.processors.tld_subtype = function(value, args)
        template,
    return select(1, getCanonicalForms().normalize(value, template.config.mappings.tld_subtype)) or value
        'CustomBlock_title',
end
        function()
template.config.processors.introduced = function(value, args)
            local titleText = (args._type == 'ccTLD') and 'ccTLD' or 'gTLD'
    return TemplateHelpers.formatDateRange(value, nil, {outputMode='text'})
            return TemplateHelpers.renderTitleBlock(
end
                args,
template.config.processors.implemented = function(value, args)
                'template-title template-title-tld',
    return TemplateHelpers.formatDateRange(value, nil, {outputMode='text'})
                titleText,
end
                template.config.meta and template.config.meta.titleOptions or {}
template.config.processors.website = function(value, args)
            )
    return TemplateHelpers.normalizeWebsites(value)
        end,
end
        '',
template.config.processors.country = function(value, args)
        args
     return TemplateHelpers.normalizeCountries(value)
     )
end
end
}


-- === PIC/RVC Link Processor ===
-- 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


-- === Property Provider ===
-- 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)


-- ================================================================================
-- ================================================================================