« Module:AhnentafelChart » : différence entre les versions
Apparence
Page créée avec « local p = {} function p.main(frame) local args = frame:getParent().args local output = {} table.insert(output, '<div class="mw-ahnentafel-chart"><table class="wikitable" style="width:100%;">') table.insert(output, '<tr><th>N°</th><th>Ascendant</th></tr>') -- Récupération dynamique des identifiants local indices = {} for k, _ in pairs(args) do local base = tostring(k):match('^(%d+)-nom$') if base then table.insert(indices, tonumber(base)) end... » |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
function renderCell(nom, image, dates) | |||
local html = {} | |||
table.insert(html, '<div style="text-align:center;">') | |||
if nom and nom ~= '' then | |||
table.insert(html, '<div style="font-weight:bold;">' .. nom .. '</div>') | |||
end | |||
if image and image ~= '' then | |||
table.insert(html, string.format('[[Fichier:%s|80px|center]]', image)) | |||
end | |||
if dates and dates ~= '' then | |||
table.insert(html, '<div style="font-size:0.85em; color:gray;">' .. dates .. '</div>') | |||
end | |||
table.insert(html, '</div>') | |||
return table.concat(html, '\n') | |||
end | |||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local | local out = {} | ||
table.insert( | table.insert(out, '<div class="mw-ahnentafel-tree"><table style="width:100%; text-align:center; border-spacing:10px;">') | ||
-- | -- Ligne 3e génération (4 à 7) | ||
table.insert(out, '<tr>') | |||
for | for i = 4, 7 do | ||
local | local nom = args[i .. '-nom'] or '' | ||
local img = args[i .. '-image'] or '' | |||
local dates = args[i .. '-dates'] or '' | |||
table.insert(out, '<td style="width:25%;">' .. renderCell(nom, img, dates) .. '</td>') | |||
end | end | ||
table. | table.insert(out, '</tr>') | ||
for | -- Ligne 2e génération (2 et 3) | ||
table.insert(out, '<tr>') | |||
for i = 2, 3 do | |||
local nom = args[i .. '-nom'] or '' | local nom = args[i .. '-nom'] or '' | ||
local | local img = args[i .. '-image'] or '' | ||
local dates = args[i .. '-dates'] or '' | local dates = args[i .. '-dates'] or '' | ||
table.insert(out, '<td colspan="2">' .. renderCell(nom, img, dates) .. '</td>') | |||
table.insert( | |||
end | end | ||
table.insert(out, '</tr>') | |||
table.insert( | -- Ligne 1re génération (1) | ||
local nom = args['1-nom'] or '' | |||
local img = args['1-image'] or '' | |||
local dates = args['1-dates'] or '' | |||
table.insert(out, '<tr><td colspan="4">' .. renderCell(nom, img, dates) .. '</td></tr>') | |||
return table.concat( | table.insert(out, '</table></div>') | ||
return table.concat(out, '\n') | |||
end | end | ||
return p | return p | ||
Version du 12 juin 2025 à 14:08
La documentation pour ce module peut être créée à Module:AhnentafelChart/doc
local p = {}
function renderCell(nom, image, dates)
local html = {}
table.insert(html, '<div style="text-align:center;">')
if nom and nom ~= '' then
table.insert(html, '<div style="font-weight:bold;">' .. nom .. '</div>')
end
if image and image ~= '' then
table.insert(html, string.format('[[Fichier:%s|80px|center]]', image))
end
if dates and dates ~= '' then
table.insert(html, '<div style="font-size:0.85em; color:gray;">' .. dates .. '</div>')
end
table.insert(html, '</div>')
return table.concat(html, '\n')
end
function p.main(frame)
local args = frame:getParent().args
local out = {}
table.insert(out, '<div class="mw-ahnentafel-tree"><table style="width:100%; text-align:center; border-spacing:10px;">')
-- Ligne 3e génération (4 à 7)
table.insert(out, '<tr>')
for i = 4, 7 do
local nom = args[i .. '-nom'] or ''
local img = args[i .. '-image'] or ''
local dates = args[i .. '-dates'] or ''
table.insert(out, '<td style="width:25%;">' .. renderCell(nom, img, dates) .. '</td>')
end
table.insert(out, '</tr>')
-- Ligne 2e génération (2 et 3)
table.insert(out, '<tr>')
for i = 2, 3 do
local nom = args[i .. '-nom'] or ''
local img = args[i .. '-image'] or ''
local dates = args[i .. '-dates'] or ''
table.insert(out, '<td colspan="2">' .. renderCell(nom, img, dates) .. '</td>')
end
table.insert(out, '</tr>')
-- Ligne 1re génération (1)
local nom = args['1-nom'] or ''
local img = args['1-image'] or ''
local dates = args['1-dates'] or ''
table.insert(out, '<tr><td colspan="4">' .. renderCell(nom, img, dates) .. '</td></tr>')
table.insert(out, '</table></div>')
return table.concat(out, '\n')
end
return p