« Module:Liste de pages-listes » : différence entre les versions

De Les Archives de Vault-Tec
Kharmitch (discussion | contributions)
Page créée avec « local p = {} local games = { 'Fallout', 'Fallout 2', 'Fallout Tactics', 'Fallout 3', 'Fallout: New Vegas', 'Fallout Shelter', 'Fallout 4', 'Fallout 76', 'Fallout… »
 
Aucun résumé des modifications
 
(7 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 12 : Ligne 12 :
'Fallout: Brotherhood of Steel',
'Fallout: Brotherhood of Steel',
'Van Buren',
'Van Buren',
'Project V13'
'Project V13',
'Fallout (série télévisée)'
}
}


function p._build(args)
function p._build(args)
local mode = args['mode'] or ''
local mode = args['mode'] or ''
local subject = args['sujet'] or ''
local subject = args['sujet']
if subject ~= '' then
if not subject then
subject = subject .. ' de '
subject = require( 'Module:Outils' ).simpletitle(mw.getCurrentFrame()) .. 's'
end
end
subject = subject .. ' de '
local res = mw.html.create( 'ul' )
local res = mw.html.create( 'ul' )
Ligne 35 : Ligne 38 :
if mode ~= 'liste' then
if mode ~= 'liste' then
local image = args['image']
if image then
image = '[[Fichier:' .. image .. '|x100px|center|alt=|link=]]'
end
res = mw.html.create( 'div' )
res = mw.html.create( 'div' )
:addClass( 'avt-game-listpage' )
:addClass( 'infobox avt-game-listpage' )
:tag( 'div' )
:tag( 'div' )
:addClass( 'avt-game-listpage-title' )
:addClass( 'avt-game-listpage-title' )
:wikitext( 'Page-liste par jeu' )
:wikitext( 'Pages-listes par jeu' )
:done()
:done()
:wikitext(image)
:node( res:addClass( 'avt-game-listpage-list' ) )
:node( res:addClass( 'avt-game-listpage-list' ) )
:done()
:done()

Dernière version du 16 décembre 2023 à 15:52

La documentation pour ce module peut être créée à Module:Liste de pages-listes/doc

local p = {}

local games = {
	'Fallout',
	'Fallout 2',
	'Fallout Tactics',
	'Fallout 3',
	'Fallout: New Vegas',
	'Fallout Shelter',
	'Fallout 4',
	'Fallout 76',
	'Fallout: Brotherhood of Steel',
	'Van Buren',
	'Project V13',
	'Fallout (série télévisée)'
}

function p._build(args)
	local mode = args['mode'] or ''
	local subject = args['sujet']
	
	if not subject then
		subject = require( 'Module:Outils' ).simpletitle(mw.getCurrentFrame()) .. 's'
	end
	
	subject = subject .. ' de '
	
	local res = mw.html.create( 'ul' )
	
	for k, v in ipairs(games) do
		local pagename = subject .. v
		if mw.title.new( pagename ).exists then
			res	:tag( 'li' )
				:wikitext( "[[" .. pagename .. "|" .. subject .. "''" .. v .. "'']]" )
				:done()
		end
	end
	
	if mode ~= 'liste' then
		local image = args['image']
		if image then
			image = '[[Fichier:' .. image .. '|x100px|center|alt=|link=]]'
		end
		
		res = mw.html.create( 'div' )
			:addClass( 'infobox avt-game-listpage' )
			:tag( 'div' )
				:addClass( 'avt-game-listpage-title' )
				:wikitext( 'Pages-listes par jeu' )
				:done()
			:wikitext(image)
			:node( res:addClass( 'avt-game-listpage-list' ) )
			:done()
	end
	
	return res
end

function p.build(frame)
	local args = {}
	
	local argsParent = frame:getParent().args
	for cle, val in pairs(argsParent) do
		if val then
			args[cle] = mw.text.trim(val)
		end
	end
	
	return p._build(args)
end

return p