« Module:Infobox/Évènement » : différence entre les versions
mAucun résumé des modifications |
Aucun résumé des modifications |
||
(3 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 14 : | Ligne 14 : | ||
function buildColumns(localdata, prefix) | function buildColumns(localdata, prefix) | ||
local res = mw.html.create( 'div' ) | local res = mw.html.create( 'div' ) | ||
local style = 'display:grid;' | local style = 'display:grid;text-align:left;' | ||
local isFirstColumn = true | local isFirstColumn = true | ||
Ligne 22 : | Ligne 22 : | ||
if isFirstColumn then | if isFirstColumn then | ||
isFirstColumn = false | isFirstColumn = false | ||
style = style .. 'grid-template-columns: | style = style .. 'grid-template-columns:1fr' | ||
else | else | ||
style = style .. ' | style = style .. ' 1fr' | ||
end | end | ||
res :tag( 'div' ) | res :tag( 'div' ) | ||
:wikitext( value ) | :wikitext( value ) | ||
:done() | :done() | ||
else | |||
break | |||
end | end | ||
end | end | ||
Ligne 34 : | Ligne 36 : | ||
res :attr('style', style .. ';') | res :attr('style', style .. ';') | ||
:allDone() | :allDone() | ||
if isFirstColumn then return end | |||
return tostring(res) | return tostring(res) | ||
Ligne 64 : | Ligne 68 : | ||
{ type = 'row', label = 'Connexe', value = 'connexe' }, | { type = 'row', label = 'Connexe', value = 'connexe' }, | ||
{ type = 'succession', value = { | { type = 'succession', value = { | ||
before = localdata['précédent'], | before = function(localdata) return localdata['précédent'] end, | ||
after = localdata['suivant'] | after = function(localdata) return localdata['suivant'] end | ||
}} | }} | ||
}}, | }}, |
Dernière version du 19 septembre 2022 à 12:08
Ce module contient le paramétrage de l'infobox {{Infobox évènement}}.
local localdata = require('Module:Infobox/Localdata')
function buildSubject(arg)
local subject = 'Évènement'
if arg then
local types = {
['conflit militaire'] = 'Conflit militaire'
}
subject = types[arg:lower()] or subject
end
return subject
end
function buildColumns(localdata, prefix)
local res = mw.html.create( 'div' )
local style = 'display:grid;text-align:left;'
local isFirstColumn = true
for i = 1, 4 do
local value = localdata[prefix .. i]
if value then
if isFirstColumn then
isFirstColumn = false
style = style .. 'grid-template-columns:1fr'
else
style = style .. ' 1fr'
end
res :tag( 'div' )
:wikitext( value )
:done()
else
break
end
end
res :attr('style', style .. ';')
:allDone()
if isFirstColumn then return end
return tostring(res)
end
return {
parts = {
{ type = 'title', value = 'nom', subtitle = 'sous-titre', icon = 'icône', subhead = { games = 'jeux', subject = buildSubject(localdata['type']), link = 'Chronologie' }},
{ type = 'images', imageparameters = { 'image', 'image2', 'image3', 'image4', 'image5' }, captionparameter = { 'légende', 'image desc' }},
{ type = 'table', title = 'Informations générales', rows = {
{ type = 'row', label = 'Date', value = 'date' },
{ type = 'row', label = 'Lieu', value = 'lieu' },
{ type = 'row', label = '\'\'Casus belli\'\'', value = 'casus belli' },
{ type = 'row', label = 'Issue', value = 'issue' }
}},
{ type = 'table', title = 'Belligérants', rows = {
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'combattant') end }
}},
{ type = 'table', title = 'Commandants', rows = {
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'commandant') end }
}},
{ type = 'table', title = 'Forces en présence', rows = {
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'forces') end }
}},
{ type = 'table', title = 'Pertes', rows = {
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'pertes') end }
}},
{ type = 'table', title = 'Évènements associés', rows = {
{ type = 'row', label = 'Partie de', value = 'partie de' },
{ type = 'row', label = 'Connexe', value = 'connexe' },
{ type = 'succession', value = {
before = function(localdata) return localdata['précédent'] end,
after = function(localdata) return localdata['suivant'] end
}}
}},
{ type = 'text', value = 'pied' }
}
}