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

Материал из Posmotrelisu
Перейти к навигации Перейти к поиску
(Новая страница: «local p = {} p.videogallery = function ( frame ) local args = require('Module:Arguments').getArgs(frame) local cols = 2 if args['cols'] ~= nil then cols=args['cols'] 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 if args[i+1] == nil then result=result..'<td>{{Youtube|'..args[i]....»)
 
м (Защитил страницу Модуль:Галерея ([Редактирование=Разрешено только автоподтверждённым участникам] (бессрочно) [Переименование=Разрешено только автоподтверждённым участникам] (бессрочно)))
 
(не показаны 3 промежуточные версии этого же участника)
Строка 1: Строка 1:
local p = {}
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 )
p.videogallery = function ( frame )
local args = require('Module:Arguments').getArgs(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
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


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


local i=1
local i=1
Строка 13: Строка 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  
Строка 20: Строка 73:
end  
end  


if args[i+1] == nil
result=result..youtubestring ( args[i], args[i+1], w, h, shorts )
then
i=i+2
result=result..'<td>{{Youtube|'..args[i]..'}}</td>'
i=i+1
else
result=result..'<td>{{Youtube|'..args[i]..'|'..args[i+1]..'}}</td>'
i=i+2
end
icols=icols+1
icols=icols+1
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
КлассикаАтлас