Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Roadmap » : différence entre les versions

De Nefald
Hiob (discussion | contributions)
Aucun résumé des modifications
Hiob (discussion | contributions)
Aucun résumé des modifications
 
Ligne 70 : Ligne 70 :
end
end


-- Sanitize un nom de tag pour l'utiliser comme classe CSS
-- Ne garde que lettres, chiffres et tirets
local function sanitizeClass(s)
local function sanitizeClass(s)
if not s then return "" end
if not s then return "" end
Ligne 80 : Ligne 78 :


-- ------------------------------------------------------------
-- ------------------------------------------------------------
-- PARSEUR
-- PARSEUR (séparateur ;; au lieu de |)
-- ------------------------------------------------------------
-- ------------------------------------------------------------


Ligne 95 : Ligne 93 :
titre = trim(titre or "Section"),
titre = trim(titre or "Section"),
})
})
elseif line:match("^item%s*|") then
elseif line:match("^item%s*;;") then
local parts = {}
local parts = {}
for part in line:gmatch("([^|]+)") do
for part in (line .. ";;"):gmatch("(.-);;") do
table.insert(parts, trim(part))
table.insert(parts, trim(part))
end
end
-- parts[1] = "item", parts[2] = statut, parts[3] = titre, etc.
local statut = trim(parts[2] or "planned"):lower()
local statut = trim(parts[2] or "planned"):lower()
local titre  = trim(parts[3] or "")
local titre  = trim(parts[3] or "")
Ligne 171 : Ligne 170 :
local parts = {}
local parts = {}
for _, tag in ipairs(tags) do
for _, tag in ipairs(tags) do
local classe = sanitizeClass(tag)
table.insert(parts, string.format(
table.insert(parts, string.format(
'<span class="roadmap-tag roadmap-tag-%s">%s</span>',
'<span class="roadmap-tag roadmap-tag-%s">%s</span>',
classe, escapeHtml(tag)
sanitizeClass(tag), escapeHtml(tag)
))
))
end
end
Ligne 289 : Ligne 287 :
function p.render(frame)
function p.render(frame)
local args = frame:getParent().args
local args = frame:getParent().args
local rawContenu = args["contenu"] or args[1] or "(vide)"
local rawContenu = trim(args["contenu"] or args[1] or "")
return '<pre>' .. mw.text.nowiki(tostring(rawContenu)) .. '</pre>'
--
local titre    = getParam(args, "titre", "title") or "Roadmap"
local subtitle = getParam(args, "subtitle")
--
local elements = parseContenu(rawContenu)
local pct, done, total = calcProgression(elements)
--
local out = {}
table.insert(out, '<div class="roadmap-container">')
-- En-tête
table.insert(out, '<div class="roadmap-header">')
table.insert(out, string.format('<div class="roadmap-title">%s</div>', escapeHtml(titre)))
if subtitle then
table.insert(out, string.format('<div class="roadmap-subtitle">%s</div>', escapeHtml(subtitle)))
end
table.insert(out, htmlProgressBar(pct, done, total))
table.insert(out, htmlStats(elements))
table.insert(out, htmlLegende())
table.insert(out, '</div>')
-- Corps
local sectionOpen = false
for _, el in ipairs(elements) do
if el.type == "section" then
if sectionOpen then
table.insert(out, '</div>')
end
table.insert(out, htmlSection(el))
sectionOpen = true
elseif el.type == "item" then
table.insert(out, htmlItem(el))
end
end
if sectionOpen then
table.insert(out, '</div>')
end
table.insert(out, '</div>')
return table.concat(out, "\n")
end
end


-- ------------------------------------------------------------
-- ------------------------------------------------------------
Les témoins (''cookies'') nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de témoins.