Модуль:Галерея: различия между версиями

Материал из Posmotrelisu
Перейти к навигации Перейти к поиску
(в2)
(в3)
Строка 1: Строка 1:
local p = {}
local p = {}


function youtubestring (id, text)
-- Делаем строку с ютуб-шаблоном
if text==nil
function youtubestring (id, text, width, height, shorts )
then return '<td>{{Youtube|'..id..'}}</td>'
 
else return '<td>{{Youtube|'..id..'|'..text..'}}</td>'
local res = '<td>{{Youtube|'..id
 
if text~=nil
then
res=res..'|'..text  
end  
end  
if width~=nil
then
res=res..'|width='..width
end
if height~=nil
then
res=res..'|height='..height
end
if shorts~=nil
then
res=res..'|shorts=1'
end
return res..'}}</td>'
end  
end  


Строка 12: Строка 34:
local cols = 2
local cols = 2


if args['cols'] ~= nil then cols=args['cols'] end
-- Эти параметры дб инициализированы
if args['cols'] ~= nil then cols=tonumber(args['cols']) end
if cols<1 then return '<font color="red">Ошибка: попытка создать видеогалерею меньше чем в 1 ряд</font>' end


if cols<1 then return '<font color="red">Ошибка: попытка создать видеогалерею меньше чем в 1 ряд</font>' end
local align='left'
if args['align'] ~= nil then align=args['align'] end
 
-- Эти параметры могут быть пустыми
local w = args['w']
local h = args['h']
local shorts = args['shorts']


local i=1
local i=1
Строка 29: Строка 59:
end  
end  


result=result..youtubestring ( args[i], args[i+1] )
result=result..youtubestring ( args[i], args[i+1], w, h, shorts )
i=i+2
i=i+2
icols=icols+1
icols=icols+1
Строка 35: Строка 65:
end
end


return '<table align="left" style="border: solid 1px #CCCCCC; background-color: inherit;" class="videogallery">'..frame:preprocess(result)..'</tr></table><br clear="both" />'
-- Полируем всё препроцесором, чтоб работало
return '<table align="'..align..'" style="border: solid 1px #CCCCCC; background-color: inherit;" class="videogallery">'..frame:preprocess(result)..'</tr></table><br clear="both" />'
end  
end  



Версия 18:43, 24 мая 2026

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

local p = {}

-- Делаем строку с ютуб-шаблоном
function youtubestring (id, text, width, height, shorts )

local res = '<td>{{Youtube|'..id

	if text~=nil 
	then
	res=res..'|'..text 
	end 
	
	if width~=nil
	then
	res=res..'|width='..width 
	end
	
	if height~=nil
	then	
	res=res..'|height='..height 
	end
	
	if shorts~=nil 
	then
	res=res..'|shorts=1' 
	end

return res..'}}</td>'

end 

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

-- Эти параметры дб инициализированы 
if args['cols'] ~= nil then cols=tonumber(args['cols']) end
	if cols<1 then return '<font color="red">Ошибка: попытка создать видеогалерею меньше чем в 1 ряд</font>' end

local align='left'
if args['align'] ~= nil then align=args['align'] end

-- Эти параметры могут быть пустыми	
local w = args['w']
local h = args['h']
local shorts = args['shorts']

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], w, h, shorts )
	i=i+2
	icols=icols+1
	
end

-- Полируем всё препроцесором, чтоб работало
return '<table align="'..align..'" style="border: solid 1px #CCCCCC; background-color: inherit;" class="videogallery">'..frame:preprocess(result)..'</tr></table><br clear="both" />'
end 



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