@DeletedUser40376207 (discusión | contribs.) (Deshecha la prueba) |
@DeletedUser40376207 (discusión | contribs.) m (Realizando cambios de traducción) |
||
Línea 19: | Línea 19: | ||
for k, v in pairs( args ) do |
for k, v in pairs( args ) do |
||
if type( k ) == 'string' then |
if type( k ) == 'string' then |
||
− | local image, num = k:match( '^(image)(%d+)$' ) |
+ | local image, num = k:match( '^(image)(%d+)$' ) or k:match( '^(imagen)(%d+)$' ) |
− | local invImage, invNum = k:match( '^(invimage)(%d+)$' ) |
+ | local invImage, invNum = k:match( '^(invimage)(%d+)$' ) or k:match( '^(miniatura)(%d+)$' ) |
if v:lower() ~= 'none' then |
if v:lower() ~= 'none' then |
||
if image then |
if image then |
||
Línea 34: | Línea 34: | ||
local animate |
local animate |
||
for k, v in ipairs( imgCount ) do |
for k, v in ipairs( imgCount ) do |
||
− | local image = args['image' .. v] |
+ | local image = args['image' .. v] or args['imagen' .. v] |
− | local size = args['image' .. v .. 'size'] or defaultImageSize |
+ | local size = args['image' .. v .. 'size'] or args['imagen' .. v .. 'size'] or defaultImageSize |
if image == 'title' then |
if image == 'title' then |
||
− | local imageTitle = mw.title.new( ' |
+ | local imageTitle = mw.title.new( 'Archivo:' .. title .. '.png' ) |
if imageTitle and imageTitle.exists then |
if imageTitle and imageTitle.exists then |
||
− | image = '[[ |
+ | image = '[[Archivo:' .. title .. '.png|' .. size .. ']]' |
elseif titleObject.namespace == 0 then |
elseif titleObject.namespace == 0 then |
||
− | image = '[[ |
+ | image = '[[Archivo:No image.svg|' .. size .. '|link=Archivo:' .. title .. '.png|Subir ' .. title .. '.png]]' |
else |
else |
||
− | image = '[[ |
+ | image = '[[Archivo:No image.svg|' .. size .. '|link=]]' |
end |
end |
||
elseif image:match( ';' ) then |
elseif image:match( ';' ) then |
||
Línea 52: | Línea 52: | ||
image = animate{ image, size } |
image = animate{ image, size } |
||
else |
else |
||
− | image = '[[ |
+ | image = '[[Archivo:' .. image .. '|' .. size .. ']]' |
end |
end |
||
Línea 63: | Línea 63: | ||
local grid |
local grid |
||
for k, v in ipairs( invImgCount ) do |
for k, v in ipairs( invImgCount ) do |
||
− | local image = args['invimage' .. v] |
+ | local image = args['invimage' .. v] or args['miniatura' .. v] |
if image == 'title' then |
if image == 'title' then |
||
− | local imageTitle = mw.title.new( ' |
+ | local imageTitle = mw.title.new( 'Archivo:Grid ' .. title .. '.png' ) |
if imageTitle and imageTitle.exists then |
if imageTitle and imageTitle.exists then |
||
image = title |
image = title |
Revisión del 06:17 9 ago 2014
Este modulo implementa {{infobox}}
. Normalmente debería ser invocada directamente en las páginas de plantillas, mejor que usar la plantilla de infobox.
Los argumentos "parent" se incorporan automáticamente con los argumentos "passed" (los más nuevos sobrescriben a los antiguos) y todos los argumentos se normalizan para reducir los "whitespace" y definir los argumentos vacios como nil
.
Dependencias
- Módulo:Animate (cuando usa imágenes animadas)
- Módulo:Inventory slot (cuando usa invimages)
- Módulo:ProcessArgs
Ver también
- Minecraft
{{Bioma}}
{{Bloque}}
{{Efecto}}
{{Encantamiento}}
{{Entidad}}
{{EntidadObjeto}}
{{Estructura}}
{{Fase de desarrollo}}
{{Fluido}}
{{Objeto}}
- Minecraft Dungeons
{{DungeonsEncantamiento}}
{{DungeonsEntidad}}
{{DungeonsObjeto}}
- Minecraft Earth
{{EarthObjeto}}
- Otros
{{Álbum}}
{{Empresa}}
{{Música}}
{{Navegación de versión}}
{{Persona}}
{{Perfil}}
{{Programa}}
- Módulo:Infobox
[Ver | Editar | Purgar]La documentación arriba es transcluída desde Módulo:Infobox/doc.
local p = {}
function p.infobox( f )
local args = require( 'Módulo:ProcessArgs' ).merge( true )
local titleObject = mw.title.getCurrentTitle()
local title = args.title or titleObject.baseText
local imageArea = args.imagearea
if not imageArea and imageArea ~= 'none' then
local images = {}
local invImages = {}
local defaultImageSize = args.defaultimagesize or '150px'
args.image1 = args.image1 or args.image or 'title'
args.image1size = args.image1size or args.imagesize
args.invimage1 = args.invimage1 or args.invimage or 'title'
local imgCount = {}
local invImgCount = {}
local grid
for k, v in pairs( args ) do
if type( k ) == 'string' then
local image, num = k:match( '^(image)(%d+)$' ) or k:match( '^(imagen)(%d+)$' )
local invImage, invNum = k:match( '^(invimage)(%d+)$' ) or k:match( '^(miniatura)(%d+)$' )
if v:lower() ~= 'none' then
if image then
table.insert( imgCount, tonumber( num ) )
elseif invImage then
table.insert( invImgCount, tonumber( invNum ) )
end
end
end
end
table.sort( imgCount )
local animate
for k, v in ipairs( imgCount ) do
local image = args['image' .. v] or args['imagen' .. v]
local size = args['image' .. v .. 'size'] or args['imagen' .. v .. 'size'] or defaultImageSize
if image == 'title' then
local imageTitle = mw.title.new( 'Archivo:' .. title .. '.png' )
if imageTitle and imageTitle.exists then
image = '[[Archivo:' .. title .. '.png|' .. size .. ']]'
elseif titleObject.namespace == 0 then
image = '[[Archivo:No image.svg|' .. size .. '|link=Archivo:' .. title .. '.png|Subir ' .. title .. '.png]]'
else
image = '[[Archivo:No image.svg|' .. size .. '|link=]]'
end
elseif image:match( ';' ) then
if not animate then
animate = require( 'Módulo:Animate' ).animate
end
image = animate{ image, size }
else
image = '[[Archivo:' .. image .. '|' .. size .. ']]'
end
table.insert( images, '<div>' .. image .. '</div>' )
end
images = table.concat( images, '\n' )
if #invImgCount > 0 then
table.sort( invImgCount )
local grid
for k, v in ipairs( invImgCount ) do
local image = args['invimage' .. v] or args['miniatura' .. v]
if image == 'title' then
local imageTitle = mw.title.new( 'Archivo:Grid ' .. title .. '.png' )
if imageTitle and imageTitle.exists then
image = title
else
image = false
end
end
if image then
if not grid then
grid = require( 'Módulo:Grid' ).cell
end
table.insert( invImages, grid{ image, link = 'none' } )
end
end
if #invImages > 0 then
invImages = '<div class="infobox-invimages">' .. table.concat( invImages, '' ) .. '</div>'
else
invImages = ''
end
else
invImages = ''
end
if images ~= '' or invImages ~= '' then
imageArea = images .. '\n' .. invImages
else
imageArea = 'none'
end
end
if imageArea and imageArea ~= 'none' then
imageArea = '<div class="infobox-imagearea">' .. imageArea .. '</div>'
else
imageArea = ''
end
local footer = args.footer
if footer then
footer = '| class="infobox-footer" colspan="2" | ' .. footer
end
local html = {
'<div class="notaninfobox">',
'<div class="infobox-title mcwiki-header"><span class="editsection">[[' ..
tostring( mw.uri.fullUrl( titleObject.fullText, { action = 'edit', section = 0 } ) ) .. ' editar' ..
']]</span>' .. title .. '</div>',
imageArea,
'{| class="infobox-rows" cellspacing="1" cellpadding="4"',
'|-',
args.rows or '',
footer or '',
'|}',
'</div>'
}
return table.concat( html, '\n' )
end
return p