Module:ElementAchievementBadges: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- | --[[ | ||
* 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 66: | Line 70: | ||
or p.defaultConfig.badgeClass | or p.defaultConfig.badgeClass | ||
-- Build the badges HTML | -- Build the badges HTML | ||
local badgesHtml = {} | local badgesHtml = {} | ||
-- Add a table row to contain the badges | -- Add a table row to contain the badges | ||
table.insert(badgesHtml, '|-\n| colspan="2" class="' .. containerClass .. '" | ') | table.insert(badgesHtml, '|-\n| colspan="2" class="' .. containerClass .. '" | ') | ||
-- Add each badge | -- Add each badge | ||
for _, achievement in ipairs(badgeAchievements) do | for _, achievement in ipairs(badgeAchievements) do | ||
-- For each badge, create a span with appropriate classes | -- For each badge, create a span with appropriate classes | ||
| Line 85: | Line 88: | ||
table.insert(badgesHtml, badgeSpan) | table.insert(badgesHtml, badgeSpan) | ||
end | end | ||
end | |||
-- Get category links from the centralized function | |||
local categoryLinksString = Achievements.getCategoryLinks(badgeAchievements, frame) | |||
-- Return the complete HTML with debug info and category links | -- Return the complete HTML with debug info and category links | ||
return table.concat(badgesHtml) .. | return table.concat(badgesHtml) .. categoryLinksString .. debugInfo | ||
end | end | ||