Module:ElementAchievementBadges: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- Module:ElementAchievementBadges
--[[
-- Renders achievement badges for Person templates and handles all badge-type achievements.
* Name: ElementAchievementBadges
* Author: Mark W. Datysgeld
* Description: Element module that renders achievement badges for Person templates and handles all badge-type achievements
* Notes: Creates blocks for Blueprint framework; loads achievement data using AchievementSystem; filters for badge-type achievements; renders badges as HTML spans with CSS classes; includes category links; protected execution with error handling
]]


local p = {}
local p = {}
Line 79: Line 83:
                     -- Add CSS classes from achievement type (e.g., "badge-icann-fellow")
                     -- Add CSS classes from achievement type (e.g., "badge-icann-fellow")
                     local badgeSpan = string.format(
                     local badgeSpan = string.format(
                         '<span class="%s %s" title="%s" data-category="%s"></span>',
                         '<span class="%s %s" title="%s"></span>',
                         badgeClass, badgeType, achievement.name or badgeType, achievement.category or ""
                         badgeClass, badgeType, achievement.name or badgeType
                     )
                     )
                     table.insert(badgesHtml, badgeSpan)
                     table.insert(badgesHtml, badgeSpan)
                 end
                 end
             end
             end
            -- Get category links from the centralized function
            local categoryLinksString = Achievements.getCategoryLinks(badgeAchievements, frame)
              
              
             -- Return the complete HTML with debug info
             -- Return the complete HTML with debug info and category links
             return table.concat(badgesHtml) .. debugInfo
             return table.concat(badgesHtml) .. categoryLinksString .. debugInfo
         end
         end