Module:T-TLD: Difference between revisions

// via Wikitext Extension for VSCode
Tag: Reverted
// via Wikitext Extension for VSCode
Tag: Manual revert
Line 119: Line 119:
}
}


-- 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.website = function(value, args)
    return TemplateHelpers.normalizeWebsites(value)
end
template.config.processors.country = function(value, args)
    return TemplateHelpers.normalizeCountries(value)
end
template.config.processors.introduced = TemplateHelpers.normalizeDates
template.config.processors.implemented = TemplateHelpers.normalizeDates
-- PIC/RVC link processor
template.config.processors.RVC = function(value, args)
    local val = tostring(value)
    if val:find("gtldresult.icann.org") then
        return string.format("[%s Here]", val)
    elseif val:match("^%d+$") then
        return string.format("[https://gtldresult.icann.org/applicationstatus/applicationdetails/%s Here]", val)
    end
    return nil
end
template.config.processors.PIC = template.config.processors.RVC




Line 151: Line 182:
end
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)


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