« Module:Infobox/Événement » : différence entre les versions

De Starfield Wiki
Page créée avec « 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[pre... »
 
m Kharmitch a déplacé la page Module:Infobox/Évènement vers Module:Infobox/Événement sans laisser de redirection
 
(2 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
local localdata = require('Module:Infobox/Localdata')
local localdata = require("Module:Infobox/Localdata")


function buildSubject(arg)
function build_columns(localdata, prefix)
local subject = 'Évènement'
    local res = mw.html.create("div")
if arg then
    local style = "display:grid;text-align:left;"
local types = {
    local isFirstColumn = true
['conflit militaire'] = 'Conflit militaire'
 
}
    for i = 1, 4 do
subject = types[arg:lower()] or subject
        local value = localdata[prefix .. i]
end
        if value then
return subject
            if isFirstColumn then
end
                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


function buildColumns(localdata, prefix)
    return tostring(res)
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
end


return {
return {
parts = {
    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 = "title",
{ type = 'table', title = 'Informations générales', rows = {
            value = "titre",
{ type = 'row', label = 'Date', value = 'date' },
            subtitle = "sous-titre",
{ type = 'row', label = 'Lieu', value = 'lieu' },
        },
{ type = 'row', label = '\'\'Casus belli\'\'', value = 'casus belli' },
        {
{ type = 'row', label = 'Issue', value = 'issue' }
            type = "images",
}},
            imageparameters = {"image", "image2", "image3", "image4", "image5"},
{ type = 'table', title = 'Belligérants', rows = {
            captionparameter = "légende",
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'combattant') end }
        },
}},
        {
{ type = 'table', title = 'Commandants', rows = {
            type = "table",
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'commandant') end }
            title = "Informations générales",
}},
            rows = {
{ type = 'table', title = 'Forces en présence', rows = {
                {type = "row", label = "Date", value = "date"},
{ type = 'row1col', value = function(localdata) return buildColumns(localdata, 'forces') end }
                {type = "row", label = "Lieu", value = "lieu"},
}},
                {type = "row", label = "''Casus belli''", value = "casus belli"},
{ type = 'table', title = 'Pertes', rows = {
                {type = "row", label = "Issue", value = "issue"}
{ 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 = "table",
{ type = 'row', label = 'Connexe', value = 'connexe' },
            title = "Belligérants",
{ type = 'succession', value = {
            rows = {
before = localdata['précédent'],
                {type = "row1col", value = function(localdata)
after = localdata['suivant']
                        return build_columns(localdata, "combattant")
}}
                    end}
}},
            }
{ type = 'text', value = 'pied' }
        },
}
        {
            type = "table",
            title = "Commandants",
            rows = {
                {type = "row1col", value = function(localdata)
                        return build_columns(localdata, "commandant")
                    end}
            }
        },
        {
            type = "table",
            title = "Forces en présence",
            rows = {
                {type = "row1col", value = function(localdata)
                        return build_columns(localdata, "forces")
                    end}
            }
        },
        {
            type = "table",
            title = "Pertes",
            rows = {
                {type = "row1col", value = function(localdata)
                        return build_columns(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 = localdata["précédent"],
                        after = localdata["suivant"]
                    }
                }
            }
        },
    }
}
}

Dernière version du 14 janvier 2023 à 19:27

Documentation[voir] [modifier] [purger]
local localdata = require("Module:Infobox/Localdata")

function build_columns(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 = "titre",
            subtitle = "sous-titre",
        },
        {
            type = "images",
            imageparameters = {"image", "image2", "image3", "image4", "image5"},
            captionparameter = "légende",
        },
        {
            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 build_columns(localdata, "combattant")
                    end}
            }
        },
        {
            type = "table",
            title = "Commandants",
            rows = {
                {type = "row1col", value = function(localdata)
                        return build_columns(localdata, "commandant")
                    end}
            }
        },
        {
            type = "table",
            title = "Forces en présence",
            rows = {
                {type = "row1col", value = function(localdata)
                        return build_columns(localdata, "forces")
                    end}
            }
        },
        {
            type = "table",
            title = "Pertes",
            rows = {
                {type = "row1col", value = function(localdata)
                        return build_columns(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 = localdata["précédent"],
                        after = localdata["suivant"]
                    }
                }
            }
        },
    }
}