Модуль:Галерея

Материал из Posmotrelisu
Перейти к навигации Перейти к поиску

Для документации этого модуля может быть создана страница Модуль:Галерея/doc

local p = {}

function youtubestring (id, text)
	if text==nil 
		then return '<td>{{Youtube|'..id..'}}</td>'
		else return '<td>{{Youtube|'..id..'|'..text..'}}</td>'
	end 
end 

p.videogallery = function ( frame )
local args = require('Module:Arguments').getArgs(frame)
local cols = 2

if args['cols'] ~= nil then cols=args['cols'] end

	if cols<1 then return '<font color="red">Ошибка: попытка создать видеогалерею меньше чем в 1 ряд</font>' end

local i=1
local icols = 0

local result='<tr valign="top" >'

while true do
	if args[i] == nil and args[i+1] == nil then break end
	if icols == cols 
		then 
		result=result..'</tr><tr valign="top">'
		icols=0
		end 

	result=result..youtubestring ( args[i], args[i+1] )
	i=i+2
	icols=icols+1
	
end

return '<table align="left" style="border: solid 1px #CCCCCC; background-color: inherit;" class="videogallery">'..frame:preprocess(result)..'</tr></table><br clear="both" />'
end 



return p
КлассикаАтлас