Module:T-CountryHub: Difference between revisions

// via Wikitext Extension for VSCode
Tag: Reverted
Maintenance update // via Wikitext Extension for VSCode
 
(4 intermediate revisions by the same user not shown)
Line 82: Line 82:
     end
     end
     return renderTable(data, columns)
     return renderTable(data, columns)
end
-- generateProcessedBrowseLink: Constructs and preprocesses a MediaWiki link for browsing data.
local function generateProcessedBrowseLink(template, browseType, browseQueryParam, linkTextPattern, country)
    -- Use the centralized LinkParser function to create the fullurl wikitext
    local browseLinkWikitext = LinkParser.createFullUrlWikitext('Special:BrowseData/' .. browseType, {
        [browseQueryParam] = country
    })
    -- Create the full link with display text
    local browseLinkString = string.format(
        '[%s %s →]',
        browseLinkWikitext,
        string.format(linkTextPattern, country) -- Use original country name for display
    )
   
    if template.current_frame and template.current_frame.preprocess then
        local ok, result = pcall(function() return template.current_frame:preprocess(browseLinkString) end)
        if ok then
            return result
        else
            return browseLinkString -- Fallback on preprocess error
        end
    end
    return browseLinkString -- Fallback if no frame or preprocess
end
end


Line 212: 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 for ICANN 83, and are under <strong>HEAVY TESTING</strong>. ' ..
               '<strong>Country Hubs</strong> have been enabled as a feature preview and are still under testing.' ..
               'Help us improve them and, especially, contribute more knowledge to our database so that they can keep growing!' ..
               ' Contribute more knowledge to our database so that they can keep growing!' ..
               '</div>'
               '</div>'
     end
     end
Line 296: 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
       
        -- Check for a Youth IGF initiative in the country
        local youthParams = {
            string.format('[[Category:Youth IGF %s]]', args.has_country),
            limit = 1
        }
        local youthData = askCached('infoBox:youth:' .. args.has_country, youthParams)
        local youthText
        if youthData[1] and youthData[1]['result'] and youthData[1]['result'] ~= '' then
            youthText = youthData[1]['result']
        else
            youthText = string.format('[[Youth IGF %s]]', args.has_country)
         end
         end
          
          
Line 357: 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()
       
        -- Youth IGF row
        infoBox:tag('tr')
            :tag('th'):wikitext('Youth IGF'):done()
            :tag('td'):wikitext(youthText):done()
             :done()
             :done()