Module:T-CountryHub: Difference between revisions
// via Wikitext Extension for VSCode |
Maintenance update // via Wikitext Extension for VSCode |
||
| (16 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 144: | Line 121: | ||
template.config.blockSequence = { | template.config.blockSequence = { | ||
'wrapperOpen', | 'wrapperOpen', | ||
'featureBanner', | |||
'overview', | 'overview', | ||
'intelligentMasonry', | 'intelligentMasonry', | ||
| Line 168: | Line 146: | ||
columns = 3, | columns = 3, | ||
mobileColumns = 1, | mobileColumns = 1, | ||
containerClass = 'country-hub-masonry-container', | containerClass = 'country-hub-masonry-container', | ||
columnClass = 'country-hub-masonry-column', | columnClass = 'country-hub-masonry-column', | ||
cardClass = 'country-hub-masonry-card' | cardClass = 'country-hub-masonry-card', | ||
-- Note: We cannot detect mobile server-side in MediaWiki | |||
-- The MasonryLayout will output both desktop and mobile HTML | |||
-- CSS media queries will handle the actual display | |||
mobileMode = false -- Always use desktop mode in Lua, CSS handles responsive | |||
} | } | ||
| Line 198: | Line 179: | ||
return '<div class="country-hub-wrapper">' -- .. flagImageWikitext -- Appended flag | return '<div class="country-hub-wrapper">' -- .. flagImageWikitext -- Appended flag | ||
end | |||
} | |||
-- Feature Preview Banner | |||
template.config.blocks.featureBanner = { | |||
feature = 'fullPage', | |||
render = function(template, args) | |||
return '<div class="country-hub-feature-banner">' .. | |||
'<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>' | |||
end | end | ||
} | } | ||
| Line 226: | 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 279: | 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 340: | 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 394: | Line 367: | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::Organization]]', args.has_country), | string.format('[[Has country::%s]] [[Has entity type::Organization]]', args.has_country), | ||
limit = | limit = 20 | ||
} | } | ||
local data = askCached('organizations:' .. args.has_country, params) | local data = askCached('organizations:' .. args.has_country, params) | ||
| Line 400: | Line 373: | ||
template._rawDataCounts = template._rawDataCounts or {} | template._rawDataCounts = template._rawDataCounts or {} | ||
template._rawDataCounts.organizations = #data | template._rawDataCounts.organizations = #data | ||
-- Only render if we have data | |||
if #data == 0 then | |||
return '' | |||
end | |||
return renderTable(data, {'Organizations'}) | return renderTable(data, {'Organizations'}) | ||
end | end | ||
| Line 417: | Line 394: | ||
template._rawDataCounts = template._rawDataCounts or {} | template._rawDataCounts = template._rawDataCounts or {} | ||
template._rawDataCounts.people = #data | template._rawDataCounts.people = #data | ||
-- Only render if we have data | |||
if #data == 0 then | |||
return '' | |||
end | |||
return renderTable(data, {'People'}) | return renderTable(data, {'People'}) | ||
end, | end, | ||
| Line 426: | 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 = | |||
} | } | ||
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, | ||
} | } | ||
| Line 443: | Line 430: | ||
'[[Category:Document]]', | '[[Category:Document]]', | ||
mainlabel = 'Document', sort = 'Has date', order = 'desc', | mainlabel = 'Document', sort = 'Has date', order = 'desc', | ||
limit = | limit = 20 | ||
} | } | ||
return renderSection('documents:' .. args.has_country, params, {'Key Documents'}) | return renderSection('documents:' .. args.has_country, params, {'Key Documents'}) | ||
| Line 455: | Line 442: | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::TLD]] [[Has TLD subtype::geoTLD]]', args.has_country), | string.format('[[Has country::%s]] [[Has entity type::TLD]] [[Has TLD subtype::geoTLD]]', args.has_country), | ||
limit = | limit = 20 | ||
} | } | ||
local data = askCached('geoTlds:' .. args.has_country, params) | |||
-- Store the raw count for masonry layout | |||
template._rawDataCounts = template._rawDataCounts or {} | |||
template._rawDataCounts.geoTlds = #data | |||
-- Only render if we have data | |||
if #data == 0 then | |||
return '' | |||
end | |||
return renderTable(data, {'GeoTLDs'}) | |||
end, | end, | ||
} | } | ||
| Line 468: | Line 463: | ||
string.format('[[Has country::%s]]', args.has_country), | string.format('[[Has country::%s]]', args.has_country), | ||
'[[Has entity type::Event]]', | '[[Has entity type::Event]]', | ||
limit = | limit = 20 | ||
} | } | ||
local data = askCached('events:' .. args.has_country, params) | |||
-- Store the raw count for masonry layout | |||
template._rawDataCounts = template._rawDataCounts or {} | |||
template._rawDataCounts.meetings = #data | |||
-- Only render if we have data | |||
if #data == 0 then | |||
return '' | |||
end | |||
return renderTable(data, {'Internet Governance Events'}) | |||
end, | end, | ||
} | } | ||
| Line 480: | Line 483: | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::Organization]] [[Has organization type::Government agency]]', args.has_country), | string.format('[[Has country::%s]] [[Has entity type::Organization]] [[Has organization type::Government agency]]', args.has_country), | ||
limit = | limit = 20 | ||
} | } | ||
local data = askCached('nra:' .. args.has_country, params) | |||
-- Store the raw count for masonry layout | |||
template._rawDataCounts = template._rawDataCounts or {} | |||
template._rawDataCounts.nra = #data | |||
-- Only render if we have data | |||
if #data == 0 then | |||
return '' | |||
end | |||
return renderTable(data, {'National Authorities'}) | |||
end, | end, | ||
} | } | ||
| Line 496: | Line 507: | ||
'[[Category:Resource]]', | '[[Category:Resource]]', | ||
mainlabel = 'Resource', | mainlabel = 'Resource', | ||
limit = | limit = 20 | ||
} | } | ||
return renderSection('resources:' .. args.has_country, params, {'Resources'}) | return renderSection('resources:' .. args.has_country, params, {'Resources'}) | ||