Module:Galerie de vidéos

De Les Archives de Vault-Tec

La documentation pour ce module peut être créée à Module:Galerie de vidéos/doc

local p = {}

--------------------------------------
-----     Fonctions communes     ----- 
--------------------------------------


function getArgs(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 args
end

--------------------------------------

function p.build(frame)
	local args = getArgs(frame)
	
	local res = mw.html.create( 'ul' )
		:addClass( 'avt-videogallery' )
	
	local defaultService = args['service'] or 'youtube'
	local dimensions = args['widths'] or '300'
		
	for i = 1, 15 do
		local id = args[i]
		if id then
			local service = args['service' .. i] or defaultService
			local description = args['t' .. i] or ''
			local video = frame:callParserFunction{ name = '#ev:' .. service, args = {
				id, dimensions, '', description
			}}
		
			res	:tag( 'li' )
				:addClass( 'avt-videogallery-item' )
				:wikitext( video )
				:done()
		else
			break
		end
	end
	
	return res
end

return p