Module:T-CountryHub: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 178: | Line 178: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
-- Derive ccTLD from ISO code via CountryData module | -- Derive ccTLD from ISO code via CountryData module | ||
local isoCode = CountryData.getCountryCodeByName( | local isoCode = CountryData.getCountryCodeByName(args.has_country) | ||
local ccTLDText | local ccTLDText | ||
if isoCode and #isoCode == 2 then | if isoCode and #isoCode == 2 then | ||
| Line 192: | Line 191: | ||
-- Fetch ICANN region for the country | -- Fetch ICANN region for the country | ||
local regionParams = { | local regionParams = { | ||
string.format('[[Has country::%s]]', | string.format('[[Has country::%s]]', args.has_country), | ||
'?Has ICANN region', | '?Has ICANN region', | ||
format = 'plain', | format = 'plain', | ||
limit = 1 | limit = 1 | ||
} | } | ||
local regionData = askCached('infoBox:region:' .. | 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 = NormalizationText.processWikiLink(regionText, 'strip') | regionText = NormalizationText.processWikiLink(regionText, 'strip') | ||
| Line 219: | Line 218: | ||
end | end | ||
local countryData = CountryData.getCountryByName( | local countryData = CountryData.getCountryByName(args.has_country) | ||
local countryNamesToMatch = {} | local countryNamesToMatch = {} | ||
if countryData then | if countryData then | ||
| Line 229: | Line 228: | ||
end | end | ||
else | else | ||
table.insert(countryNamesToMatch, normalizeForMatching( | table.insert(countryNamesToMatch, normalizeForMatching(args.has_country)) | ||
end | end | ||
| Line 251: | Line 250: | ||
if not foundMatch then | if not foundMatch then | ||
ISOCText = string.format('[[Internet Society %s Chapter]]', | ISOCText = string.format('[[Internet Society %s Chapter]]', args.has_country) | ||
end | end | ||
-- Check for a Youth IGF initiative in the country | -- Check for a Youth IGF initiative in the country | ||
local youthParams = { | local youthParams = { | ||
string.format('[[Category:Youth IGF %s]]', | string.format('[[Category:Youth IGF %s]]', args.has_country), | ||
limit = 1 | limit = 1 | ||
} | } | ||
local youthData = askCached('infoBox:youth:' .. | local youthData = askCached('infoBox:youth:' .. args.has_country, youthParams) | ||
local youthText | local youthText | ||
if youthData[1] and youthData[1]['result'] and youthData[1]['result'] ~= '' then | if youthData[1] and youthData[1]['result'] and youthData[1]['result'] ~= '' then | ||
youthText = youthData[1]['result'] | youthText = youthData[1]['result'] | ||
else | else | ||
youthText = string.format('[[Youth IGF %s]]', | youthText = string.format('[[Youth IGF %s]]', args.has_country) | ||
end | end | ||
local flagImageWikitext = "" | local flagImageWikitext = "" | ||
if | if args.has_country and args.has_country ~= "" then | ||
local isoCode = CountryData.getCountryCodeByName( | local isoCode = CountryData.getCountryCodeByName(args.has_country) | ||
if isoCode and #isoCode == 2 then | if isoCode and #isoCode == 2 then | ||
local flagFile = "Flag-" .. string.lower(isoCode) .. ".svg" | local flagFile = "Flag-" .. string.lower(isoCode) .. ".svg" | ||
| Line 366: | Line 365: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::Organization]]', | string.format('[[Has country::%s]] [[Has entity type::Organization]]', args.has_country), | ||
limit = 50 | limit = 50 | ||
} | } | ||
local data = askCached('organizations:' .. | local data = askCached('organizations:' .. args.has_country, params) | ||
local htmlTable = renderTable(data, {'Organizations'}) | local htmlTable = renderTable(data, {'Organizations'}) | ||
-- local processedBrowseLink = generateProcessedBrowseLink( | -- local processedBrowseLink = generateProcessedBrowseLink( | ||
| Line 392: | Line 390: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::Person]]', | string.format('[[Has country::%s]] [[Has entity type::Person]]', | ||
args.has_country), | |||
limit = 20 | limit = 20 | ||
} | } | ||
local data = askCached('people:' .. | local data = askCached('people:' .. args.has_country, params) | ||
local tableHtml = renderTable(data, {'People'}) | local tableHtml = renderTable(data, {'People'}) | ||
-- local processedLink = generateProcessedBrowseLink( | -- local processedLink = generateProcessedBrowseLink( | ||
| Line 421: | Line 418: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]]', | string.format('[[Has country::%s]]', args.has_country), | ||
'[[Category:Laws]]', | '[[Category:Laws]]', | ||
mainlabel = 'Law', sort = 'Has date', order = 'desc', | mainlabel = 'Law', sort = 'Has date', order = 'desc', | ||
limit = 50 | limit = 50 | ||
} | } | ||
local data = askCached('laws:' .. | local data = askCached('laws:' .. args.has_country, params) | ||
local tableHtml = renderTable(data, {'Laws and Regulations'}) | local tableHtml = renderTable(data, {'Laws and Regulations'}) | ||
-- local processedLink = generateProcessedBrowseLink( | -- local processedLink = generateProcessedBrowseLink( | ||
| Line 446: | Line 442: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]]', | string.format('[[Has country::%s]]', args.has_country), | ||
'[[Category:Document]]', | '[[Category:Document]]', | ||
mainlabel = 'Document', sort = 'Has date', order = 'desc', | mainlabel = 'Document', sort = 'Has date', order = 'desc', | ||
limit = 50 | limit = 50 | ||
} | } | ||
local data = askCached('documents:' .. | local data = askCached('documents:' .. args.has_country, params) | ||
local tableHtml = renderTable(data, {'Key Documents'}) | local tableHtml = renderTable(data, {'Key Documents'}) | ||
-- local processedLink = generateProcessedBrowseLink( | -- local processedLink = generateProcessedBrowseLink( | ||
| Line 471: | Line 466: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::TLD]] [[Has TLD subtype::geoTLD]]', | string.format('[[Has country::%s]] [[Has entity type::TLD]] [[Has TLD subtype::geoTLD]]', args.has_country), | ||
limit = 50 | limit = 50 | ||
} | } | ||
local data = askCached('geoTlds:' .. | local data = askCached('geoTlds:' .. args.has_country, params) | ||
local tableHtml = renderTable(data, {'GeoTLDs'}) | local tableHtml = renderTable(data, {'GeoTLDs'}) | ||
-- local processedLink = generateProcessedBrowseLink( | -- local processedLink = generateProcessedBrowseLink( | ||
| Line 494: | Line 488: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]]', | string.format('[[Has country::%s]]', args.has_country), | ||
'[[Has entity type::Event]]', | '[[Has entity type::Event]]', | ||
limit = 50 | limit = 50 | ||
| Line 507: | Line 500: | ||
-- "Has_country", | -- "Has_country", | ||
-- "Browse all events for %s", | -- "Browse all events for %s", | ||
-- | -- args.has_country | ||
-- ) | -- ) | ||
local data = askCached('events:' .. | local data = askCached('events:' .. args.has_country, params) | ||
if not data or #data == 0 then | if not data or #data == 0 then | ||
| Line 526: | Line 519: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]] [[Has entity type::Organization]] [[Has organization type::Government agency]]', | string.format('[[Has country::%s]] [[Has entity type::Organization]] [[Has organization type::Government agency]]', args.has_country), | ||
limit = 10 | limit = 10 | ||
} | } | ||
local data = askCached('nra:' .. | local data = askCached('nra:' .. args.has_country, params) | ||
local tableHtml = renderTable(data, {'National Authorities'}) | local tableHtml = renderTable(data, {'National Authorities'}) | ||
return tableHtml | return tableHtml | ||
| Line 544: | Line 536: | ||
render = function(template, args) | render = function(template, args) | ||
local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | local displayCountry = (args.country or mw.title.getCurrentTitle().text or ""):gsub('_',' ') | ||
local params = { | local params = { | ||
string.format('[[Has country::%s]]', | string.format('[[Has country::%s]]', args.has_country), | ||
'[[Category:Resource]]', | '[[Category:Resource]]', | ||
mainlabel = 'Resource', | mainlabel = 'Resource', | ||
limit = 10 | limit = 10 | ||
} | } | ||
local data = askCached('resources:' .. | local data = askCached('resources:' .. args.has_country, params) | ||
local tableHtml = renderTable(data, {'Resources'}) | local tableHtml = renderTable(data, {'Resources'}) | ||
return tableHtml | return tableHtml | ||