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

Материал из Posmotrelisu
Перейти к навигации Перейти к поиску
(в2)
м (Защитил страницу Модуль:Галерея ([Редактирование=Разрешено только автоподтверждённым участникам] (бессрочно) [Переименование=Разрешено только автоподтверждённым участникам] (бессрочно)))
 
(не показаны 2 промежуточные версии этого же участника)
Строка 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  


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


if args['cols'] ~= nil then cols=args['cols'] end
-- Эти параметры могут быть пустыми
local w = args['w']
local h = args['h']
local shorts = args['shorts']
 
 
 
 
-- Эти параметры дб инициализированы
 
local align='left'
if args['align'] ~= nil then align=args['align'] end


local cols = 2
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
-- Устанавливаем ширину, если много столбцов
if w==nil then
if cols == 3 then w=200 end
if cols > 3 then w=150 end
end


local i=1
local i=1
Строка 22: Строка 64:


while true do
while true do
if args[i] == nil and args[i+1] == nil then break end
 
if args[i] == nil and args[i+1] == nil then break end
 
if icols == cols  
if icols == cols  
then  
then  
Строка 29: Строка 73:
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: Строка 79:
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  



Текущая версия на 19:32, 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 w = args['w']
local h = args['h']
local shorts = args['shorts']




-- Эти параметры дб инициализированы 

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

local cols = 2
if args['cols'] ~= nil then cols=tonumber(args['cols']) end
	if cols<1 then return '<font color="red">Ошибка: попытка создать видеогалерею меньше чем в 1 ряд</font>' end
	
	-- Устанавливаем ширину, если много столбцов 
	if w==nil then
		if cols == 3 then w=200 end
		if cols > 3 then w=150 end
	
	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], 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
КлассикаАтлас