Module:ElementAchievementBadges: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(2 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 39: Line 43:
             -- Get all badge-type achievements using the centralized function
             -- Get all badge-type achievements using the centralized function
             local badgeAchievements = Achievements.getBadgeAchievements(pageId, frame)
             local badgeAchievements = Achievements.getBadgeAchievements(pageId, frame)
            -- Inject achievement categories onto the page
            for _, ach in ipairs(badgeAchievements) do
                if ach.category and ach.category ~= "" then
                    mw.addCategory(ach.category)
                end
            end
              
              
             -- Minimal debug info for troubleshooting
             -- Minimal debug info for troubleshooting
Line 91: Line 89:
                 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