Module:Infobox: Difference between revisions

No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:
local titleObject = mw.title.getCurrentTitle()
local titleObject = mw.title.getCurrentTitle()
local title = args.title or titleObject.baseText
local title = args.title or titleObject.baseText
local template = f:getParent():getTitle():lower():gsub( 'template:', '' )
local template = f:getParent():getTitle():lower():gsub( 'template:', '' ):gsub( 'infobox ', '' )
local headerArea = ''
local headerArea = ''
Line 10: Line 10:
images = {},
images = {},
invimages = {},
invimages = {},
rows = {}
rows = {},
}
}
Line 22: Line 22:
args.image1size = args.image1size or args.imagesize
args.image1size = args.image1size or args.imagesize
args.image1class = args.image1class or args.imageclass
args.image1class = args.image1class or args.imageclass
args.image1caption = args.image1caption or args.imagecaption or ''
args.invimage1 = args.invimage1 or args.invimage or 'none'
args.invimage1 = args.invimage1 or args.invimage or 'none'
args.group1 = args.group1 or args.group
args.group1 = args.group1 or args.group
args.group1size = args.group1size or args.groupsize
args.group1size = args.group1size or args.groupsize
args.group1class = args.group1class or args.groupclass
args.group1class = args.group1class or args.groupclass
args.group1caption = args.group1caption or args.groupcaption or ''
local imgCount = {}
local imgCount = {}
Line 65: Line 67:
local groupSize = args['group' .. v .. 'size'] or defaultImageSize
local groupSize = args['group' .. v .. 'size'] or defaultImageSize
local groupClass = args['group' .. v .. 'class'] or defaultImageClass
local groupClass = args['group' .. v .. 'class'] or defaultImageClass
local groupCaption = args['group' .. v .. 'caption'] or ''
local groupImages = {}
local groupImages = {}
Line 72: Line 75:
local size = args[v .. '-' .. w .. 'size'] or groupSize
local size = args[v .. '-' .. w .. 'size'] or groupSize
local class = args[v .. '-' .. w .. 'class'] or groupClass
local class = args[v .. '-' .. w .. 'class'] or groupClass
local caption = args[v .. '-' .. w .. 'caption'] or ''
if string.match( image, 'UNIQ%-%-gallery%-' ) then
if string.match( image, 'UNIQ%-%-gallery%-' ) then
Line 86: Line 90:
end
end
table.insert( groupImages, '<div>' .. image .. '</div>' )
if caption ~= '' then
caption = '<div class="infobox-imagecaption">\n' .. caption .. '\n</div>'
end
table.insert( groupImages, '<div>' .. image .. caption .. '</div>' )
end
if groupCaption ~= '' then
groupCaption = '<div class="infobox-imagecaption">\n' .. groupCaption .. '\n</div>'
end
end
table.insert( tabber, '|-|' .. group .. '=\n' .. table.concat( groupImages, '\n' ) )
table.insert( tabber, '|-|' .. group .. '=\n' .. table.concat( groupImages, '\n' ) .. groupCaption )
end
end
table.insert( images, '<div>' .. f:extensionTag( 'tabber', table.concat( tabber, '\n' ) ) .. '</div>' )
table.insert( images, '<div>' .. f:extensionTag( 'tabber', table.concat( tabber, '\n' ) ) .. '</div>' )
Line 99: Line 111:
local size = args['image' .. v .. 'size'] or defaultImageSize
local size = args['image' .. v .. 'size'] or defaultImageSize
local class = args['image' .. v .. 'class'] or defaultImageClass
local class = args['image' .. v .. 'class'] or defaultImageClass
local caption = args['image' .. v .. 'caption'] or ''
if image == 'title' then
if image == 'title' then
Line 129: Line 142:
end
end
table.insert( images, '<div>' .. image .. '</div>' )
if caption ~= '' then
caption = '<div class="infobox-imagecaption">\n' .. caption .. '\n</div>'
end
if image ~= '' or caption ~= '' then
table.insert( images, '<div>' .. image .. caption .. '</div>' )
end
end
end
Line 211: Line 230:
end
end
args.rows = string.gsub( args.rows or '', '<code class="history%-json">{"label": (".-"), "field": (".-")}</code>\n', repl )
args.rows = string.gsub( args.rows or '', '<code class="history%-json">{"label": (".-"), "field": (".-")}</code>\n', repl )
args.rows2 = string.gsub( args.rows2 or '', '<code class="history%-json">{"label": (".-"), "field": (".-")}</code>\n', repl )
 
local html = {
local html = {
'<div class="notaninfobox">',
'<div class="notaninfobox">',
Line 219: Line 239:
'|-',
'|-',
args.rows or '',
args.rows or '',
args.rows2 or '',
footer or '',
footer or '',
'|}',
'|}',