Module:T-CountryHub: Difference between revisions
// via Wikitext Extension for VSCode |
Maintenance update // via Wikitext Extension for VSCode |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 21: | Line 21: | ||
local CountryData = safeRequire('Module:CountryData') | local CountryData = safeRequire('Module:CountryData') | ||
local TemplateHelpers = safeRequire('Module:TemplateHelpers') | local TemplateHelpers = safeRequire('Module:TemplateHelpers') | ||
local LinkParser = safeRequire('Module:LinkParser') | |||
local NormalizationText = safeRequire('Module:NormalizationText') | local NormalizationText = safeRequire('Module:NormalizationText') | ||
local NormalizationDiacritic = safeRequire('Module:NormalizationDiacritic') | local NormalizationDiacritic = safeRequire('Module:NormalizationDiacritic') | ||
| Line 82: | Line 83: | ||
return renderTable(data, columns) | return renderTable(data, columns) | ||
end | end | ||
local errorContext = ErrorHandling.createContext("T-CountryHub") | local errorContext = ErrorHandling.createContext("T-CountryHub") | ||
| Line 123: | Line 100: | ||
organizations = true, | organizations = true, | ||
people = true, | people = true, | ||
laws = | laws = true, | ||
documents = false, | documents = false, | ||
geoTlds = true, | geoTlds = true, | ||
| Line 210: | Line 187: | ||
render = function(template, args) | render = function(template, args) | ||
return '<div class="country-hub-feature-banner">' .. | return '<div class="country-hub-feature-banner">' .. | ||
'<strong>Country Hubs</strong> have been enabled as a feature preview | '<strong>Country Hubs</strong> have been enabled as a feature preview and are still under testing.' .. | ||
' | ' Contribute more knowledge to our database so that they can keep growing!' .. | ||
'</div>' | '</div>' | ||
end | end | ||
| Line 241: | Line 218: | ||
local regionData = askCached('infoBox:region:' .. args.has_country, regionParams) | local regionData = askCached('infoBox:region:' .. args.has_country, regionParams) | ||
local regionText = regionData[1] and regionData[1]['Has ICANN region'] or '' | local regionText = regionData[1] and regionData[1]['Has ICANN region'] or '' | ||
regionText = | regionText = LinkParser.processWikiLink(regionText, 'strip') | ||
-- Check for an ISOC chapter in the country using fuzzy matching | -- Check for an ISOC chapter in the country using fuzzy matching | ||
| Line 294: | Line 271: | ||
if not foundMatch then | if not foundMatch then | ||
ISOCText = string.format('[[Internet Society %s Chapter]]', args.has_country) | ISOCText = string.format('[[Internet Society %s Chapter]]', args.has_country) | ||
end | end | ||
| Line 355: | Line 319: | ||
:tag('th'):wikitext('ISOC chapter'):done() | :tag('th'):wikitext('ISOC chapter'):done() | ||
:tag('td'):wikitext(ISOCText):done() | :tag('td'):wikitext(ISOCText):done() | ||
:done() | :done() | ||
| Line 449: | Line 407: | ||
render = function(template, args) | render = function(template, args) | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] | string.format('[[Has country::%s]] [[Has entity type::Norm]]', args.has_country), | ||
limit = 20 | limit = 20 | ||
} | } | ||
local data = askCached('laws:' .. args.has_country, params) | |||
-- Store the raw count for masonry layout | |||
template._rawDataCounts = template._rawDataCounts or {} | |||
template._rawDataCounts.laws = #data | |||
-- Only render if we have data | |||
if #data == 0 then | |||
return '' | |||
end | |||
return renderTable(data, {'Laws and Regulations'}) | |||
end, | end, | ||
} | } | ||