Module:Infobox: Difference between revisions

Created page with "local p = {} function p.infobox( f ) local args = require( 'Module:ProcessArgs' ).merge( true ) local titleObject = mw.title.getCurrentTitle() local title = args.title or titleObject.baseText local template = f:getParent():getTitle():lower():gsub( 'template:', '' ) local headerArea = '' local json = { images = {}, rows = {} } local imageArea = args.imagearea if not imageArea and imageArea ~= 'none' then local images = {} local defaultImageSize = args..."
 
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 67: Line 67:
for _, w in ipairs( groupImgList['group' .. v] ) do
for _, w in ipairs( groupImgList['group' .. v] ) do
local image = args[v .. '-' .. w]
local image = args[v .. '-' .. w]
image = string.gsub(string.gsub(image, "^[Ff][Ii][Ll][Ee]:", ""), "^[Ii][Mm][Aa][Gg][Ee]:", "")
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
Line 94: Line 95:
for k, v in ipairs( imgCount ) do
for k, v in ipairs( imgCount ) do
local image = args['image' .. v]
local image = args['image' .. v]
image = string.gsub(string.gsub(image, "^[Ff][Ii][Ll][Ee]:", ""), "^[Ii][Mm][Aa][Gg][Ee]:", "")
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
Line 108: Line 110:
elseif string.match( image, 'UNIQ%-%-gallery%-' ) then
elseif string.match( image, 'UNIQ%-%-gallery%-' ) then
image = image
image = image
--[[elseif image:match( ';' ) then
if not animate then
animate = require( 'Module:Animate' ).animate
end
image = animate{ image, size, class = class }--]]
else
else
json.images[#json.images + 1] = image
json.images[#json.images + 1] = image
Line 158: Line 155:
json.title = title
json.title = title
--[[local repl = function( label, field )
json.rows[#json.rows + 1] = {
label = mw.text.jsonDecode( label:gsub( '\n', '\\n' ) ),
field = mw.text.jsonDecode( field:gsub( '\n', '\\n' ) )
}
return ''
end
args.rows = string.gsub( args.rows or '', '<code class="history%-json">{"label": (".-"), "field": (".-")}</code>\n', repl )--]]
local html = {
local html = {
'<div class="infobox">',
'<div class="infobox">',
'<div class="tfpwiki-header infobox-title">' .. title .. '</div>',
'<div class="infobox-title">' .. title .. '</div>',
headerArea,
headerArea,
'{| class="infobox-rows" cellspacing="1" cellpadding="4"',
'{| class="infobox-rows" cellspacing="1" cellpadding="4"',
'|-',
'|-',
args.rows or '',
args.rows or '',
footer or '',
footer or '',
'|}',
'|}',
'</div>',
'</div>'
f:callParserFunction( '#tag', { 'pre', class = 'history-json noexcerpt navigation-not-searchable',
}
mw.text.jsonEncode( json, mw.text.JSON_PRETTY )
 
} )
return table.concat( html, '\n' )
}
return table.concat( html, '\n' )
end
end


return p
return p