Diferencia entre revisiones de «Módulo:Ficha»

Cambiando pie de imágenes desde span a div con inline
Sin resumen de edición
 
(No se muestran 34 ediciones intermedias de 13 usuarios)
Línea 6: Línea 6:
   
   
local HtmlBuilder = require('Module:HtmlBuilder')
local HtmlBuilder = require('Module:HtmlBuilder')
local CategorizacionAByAD = require('Módulo:Categorización de buenos y destacados')
-- local CategorizacionAByAD = require('Módulo:Categorización de buenos y destacados') -- DESACTIVADO: Causa de error si el módulo o Wikidata no existen.
local marco = {}  
local marco = {}  
local args
local args
local root
local root
local anchoImagen = '245px'  
local anchoImagen = '320px'  
function union(t1, t2)
function union(t1, t2)
     -- devuelve la unión de los valores de dos tablas, como una secuencia
     -- devuelve la unión de los valores de dos tablas, como una secuencia
Línea 97: Línea 97:
local function hacerTitulo() -- Cabecera de la ficha
local function hacerTitulo() -- Cabecera de la ficha
     if not args.titulo then return end
     if not args.titulo then return end
local cabecera = {}  
local cabecera = {}  
     if args.media == 'si' and args.clasetitulo then
     if args.media == 'si' and args.clasetitulo then
       cabecera = 'media ' .. args['clasetitulo']
       cabecera = 'media ' .. args['clasetitulo']
Línea 111: Línea 111:
     root
     root
         .tag('tr')
         .tag('tr')
          .tag('th')
            .tag('th')
              .attr('colspan', 3)
                .attr('colspan', 3)
              .addClass(cabecera)
                .addClass(cabecera)
              .css('text-align', 'center')
                .css('text-align', 'center')
              .css('background-color', args.colorfondo or args.colorfondotitulo or 'transparent')
                .css('background-color', args.colorfondo or args.colorfondotitulo or 'transparent')
              .css('color', args.colortexto or 'black')
                .css('color', args.colortexto or 'inherit')
              .cssText(args.estilotitulo)
                .cssText(args.estilotitulo)
              .wikitext(args.titulo)
                .wikitext(args.titulo)
end
end
local function hacerFilaArriba()
local function hacerFilaArriba()
Línea 149: Línea 149:
local function hacerImagenInferior()-- Imagen que aparecerá en la parte inferior de la tabla
local function hacerImagenInferior()-- Imagen que aparecerá en la parte inferior de la tabla
     if not args.imageninferior then return end
     if not args.imageninferior then return end
            imageninferior  = {}
                imageninferior  = {}
            if args['tamañoimageninferior']  == nil or args['tamañoimageninferior'] == '' then
                if args['tamañoimageninferior']  == nil or args['tamañoimageninferior'] == '' then
                args['tamañoimageninferior'] = anchoImagen
                        args['tamañoimageninferior'] = anchoImagen
            end
                end
            if string.find(args.imageninferior, '[{[]') == nil then
                if string.find(args.imageninferior, '[{[]') == nil then
            imageninferior = ('[[Archivo:' .. args.imageninferior .. '|'.. args['tamañoimageninferior'] .. ']]' )
                imageninferior = ('[[Archivo:' .. args.imageninferior .. '|'.. args['tamañoimageninferior'] .. ']]' )
            else  
                else  
            imageninferior = args.imageninferior
                imageninferior = args.imageninferior
            end
                end
      
      
     root
     root
Línea 163: Línea 163:
             .tag('td')
             .tag('td')
                 .attr('colspan', '3')
                 .attr('colspan', '3')
                 .addClass(args.claseimageninferior)
                 .addClass('imagen ' .. (args.claseimageninferior or '') )
                 .css('text-align', 'center')
                 .css('text-align', 'center')
                 .cssText(args.estiloimageninferior)
                 .cssText(args.estiloimageninferior)
Línea 170: Línea 170:
                 .tag('br', {selfClosing = true})
                 .tag('br', {selfClosing = true})
                     .done()
                     .done()
                 .tag('span')
                 .tag('div')
                    .css('display','inline')
                     .cssText(args.estilopieinferior)
                     .cssText(args.estilopieinferior)
                     .wikitext(args.pieinferior)
                     .wikitext(args.pieinferior)
                    .done()
                     .newline()
                     .newline()
end
end
Línea 182: Línea 184:
     end
     end
     imagensuperior  = {}
     imagensuperior  = {}
            if string.find(args.imagensuperior, '[{[]') == nil then
                if string.find(args.imagensuperior, '[{[]') == nil then
            imagensuperior = ('[[Archivo:' .. args.imagensuperior .. '|'.. args['tamañoimagensuperior'] .. ']]' )
                imagensuperior = ('[[Archivo:' .. args.imagensuperior .. '|'.. args['tamañoimagensuperior'] .. ']]' )
            else  
                else  
            imagensuperior = args.imagensuperior
                imagensuperior = args.imagensuperior
            end
                end
      
      
     root
     root
Línea 192: Línea 194:
             .tag('td')
             .tag('td')
                 .attr('colspan', '3')
                 .attr('colspan', '3')
                 .addClass(args.claseimagensuperior)
                 .addClass('imagen ' .. (args.claseimagensuperior or '') )
                 .css('text-align', 'center')
                 .css('text-align', 'center')
                 .cssText(args.estiloimagensuperior)
                 .cssText(args.estiloimagensuperior)
Línea 199: Línea 201:
                 .tag('br', {selfClosing = true})
                 .tag('br', {selfClosing = true})
                     .done()
                     .done()
                 .tag('span')
                 .tag('div')
                    .css('display','inline')
                     .cssText(args.estilopiesuperior)
                     .cssText(args.estilopiesuperior)
                     .wikitext(args.piesuperior)
                     .wikitext(args.piesuperior)
                    .done()
                     .newline()
                     .newline()
end
end
Línea 245: Línea 249:
local function hacerImageneslaterales()
local function hacerImageneslaterales()
-- Imagenes que apareceran arriba de forma geminada por ejemplo escudos y banderas
-- Imagenes que apareceran arriba de forma geminada por ejemplo escudos y banderas
 
   
if args['tamañoimagenizquierda'] == "" or args['tamañoimagenizquierda'] == nil then
if args['tamañoimagenizquierda'] == "" or args['tamañoimagenizquierda'] == nil then
         args['tamañoimagenizquierda'] = '100px'
         args['tamañoimagenizquierda'] = '100px'
      end  
      end  
      if args['tamañoimagenderecha'] == "" or args['tamañoimagenderecha'] == nil then
      if args['tamañoimagenderecha'] == "" or args['tamañoimagenderecha'] == nil then
         args['tamañoimagenderecha'] = '100px'
         args['tamañoimagenderecha'] = '100px'
      end
      end
   if args.imagenderecha and args.imagenizquierda then
   if args.imagenderecha and args.imagenizquierda then
     
      if args.pieizquierdo then brcondicionalizquierdo = 'br' end
      root
      if args.piederecho then brcondicionalderecho = 'br' end
     
      root
         .tag('tr')
         .tag('tr')
         .tag('td')
         .tag('td')
Línea 274: Línea 280:
                 .cssText(args.estiloimagenizquierda)
                 .cssText(args.estiloimagenizquierda)
                 .wikitext('[[Archivo:' .. args.imagenizquierda .. '|' .. args['tamañoimagenizquierda'] .. ']]' )
                 .wikitext('[[Archivo:' .. args.imagenizquierda .. '|' .. args['tamañoimagenizquierda'] .. ']]' )
                 .tag('br')
                 .tag(brcondicionalizquierdo)
                 .tag('div')
                 .tag('div')
                     .css('display','inline')
                     .css('display','inline')
Línea 288: Línea 294:
                 .cssText(args.estiloimagenderecha)       
                 .cssText(args.estiloimagenderecha)       
                 .wikitext('[[Archivo:' .. args.imagenderecha .. '|' .. args['tamañoimagenderecha'] .. ']]' )
                 .wikitext('[[Archivo:' .. args.imagenderecha .. '|' .. args['tamañoimagenderecha'] .. ']]' )
                 .tag('br')
                 .tag(brcondicionalderecho)
                 .tag('div')
                 .tag('div')
                     .css('display','inline')
                     .css('display','inline')
Línea 295: Línea 301:
                     .done()
                     .done()
                 .newline()
                 .newline()
    elseif args.imagenderecha or args.imagenizquierda then  
  elseif args.imagenderecha or args.imagenizquierda then  
-- Si solo una de las dos, la imagen que aparezca estará en el centro
-- Si solo una de las dos, la imagen que aparezca estará en el centro
        imagenL = {}     
      imagenL = {}     
           if args.imagenderecha ~= '' and  args.imagenderecha ~= nil then
           if args.imagenderecha ~= '' and  args.imagenderecha ~= nil then
               imagenL = 'imagenderecha'   
               imagenL = 'imagenderecha'   
Línea 303: Línea 309:
               imagenL = 'imagenizquierda'
               imagenL = 'imagenizquierda'
           end
           end
        pieL = {}
      pieL = {}
          if args.imagenderecha then
        if args.imagenderecha then
               pieL = 'piederecho'  
               pieL = 'piederecho'  
          elseif args.imagenizquierda then
        elseif args.imagenizquierda then
               pieL = 'pieizquierdo'  
               pieL = 'pieizquierdo'  
          end
        end
      root
      root
         .tag('tr')
         .tag('tr')
             .tag('td')
             .tag('td')
Línea 319: Línea 325:
                 .wikitext('[[Archivo:' ..  args[imagenL] .. '|'.. args['tamaño'..imagenL] .. ']]' )
                 .wikitext('[[Archivo:' ..  args[imagenL] .. '|'.. args['tamaño'..imagenL] .. ']]' )
                 .tag('br')
                 .tag('br')
                 .tag('span')
                 .tag('div')
                .cssText(args['estilo' .. pieL])
                  .css('display','inline')
                .wikitext(args[pieL])
                  .cssText(args['estilo' .. pieL])
                  .wikitext(args[pieL])
                  .done()
               
     end
     end
     end
     end
           
         
local function hacerImagenes() -- Puede crear un número infinito de imágenes  
local function hacerImagenes() -- Puede crear un número infinito de imágenes  
     if args.imagen then
     if args.imagen then
Línea 331: Línea 340:
     if args['tamañoimagen'] then
     if args['tamañoimagen'] then
         args['tamañoimagen1'] = args['tamañoimagen']
         args['tamañoimagen1'] = args['tamañoimagen']
    end
    end
    if args['imagenmodooscuro'] then
        args['imagenmodooscuro1'] = args['imagenmodooscuro']
    end


     if args.pie then
     if args.pie then
Línea 342: Línea 354:
         local flotante = args['imagenflotante' .. num] or false
         local flotante = args['imagenflotante' .. num] or false
             if args['tamañoimagen'..num]  == nil then
             if args['tamañoimagen'..num]  == nil then
                 args['tamañoimagen'..num]  =   anchoImagen
                 args['tamañoimagen'..num]  = anchoImagen
             end
             end
       
        -- Comprobamos si se ha activado el argumento imagenmodooscuro para esta imagen
        local claseInversion = args['imagenmodooscuro' .. num] and 'class=skin-invert-image' or ''
           
         imagen  = {}
         imagen  = {}
             local cadenaBusqueda = mw.ustring.gsub(args['imagen'..num],'UNIQ','[') -- Para que no de problemas con ciertas plantillas
             local cadenaBusqueda = mw.ustring.gsub(args['imagen'..num],'UNIQ','[') -- Para que no de problemas con ciertas plantillas
             if mw.ustring.find(cadenaBusqueda, '[{[|]') == nil then -- Comprueba si hay [ o { para no añadir prefijo
             if mw.ustring.find(cadenaBusqueda, '[{[|]') == nil then -- Comprueba si hay [ o { para no añadir prefijo
             imagen = ('[[Archivo:' .. args['imagen' .. num] .. '|'.. args['tamañoimagen' ..num] .. ']]' )
             imagen = ('[[Archivo:' .. args['imagen' .. num] .. '|'.. args['tamañoimagen' ..num] .. '|' .. claseInversion .. ']]' )
             else  
             else  
             imagen = args['imagen'..num]
             imagen = args['imagen'..num]
Línea 363: Línea 379:
                     .cssText(args.estilopie)
                     .cssText(args.estilopie)
                     .wikitext(pie)
                     .wikitext(pie)
                    .done()
         end
         end
         anadirfila({
         anadirfila({
             datos = tostring(datos),
             datos = tostring(datos),
             estilodatos = args.estiloimagen,
             estilodatos = args.estiloimagen,
             clase = args.claseimagen,
             clase = 'imagen ' .. (args.claseimagen or ''),
             clasefila = args['claseimagen' .. num]
             clasefila = args['claseimagen' .. num]
         })
         })
Línea 416: Línea 433:


function anadirSucesion(argumentosSucesion)
function anadirSucesion(argumentosSucesion)
     local fila = root.tag('tr')
     local filaGen = root.tag('tr')
     fila.css('font-size', '88%')
     filaGen.css('font-size', '88%')
     fila.css('text-align', 'center')
     filaGen.css('text-align', 'center')
      
      
     local celda
     local celda
Línea 424: Línea 441:
      
      
     width = '33%'
     width = '33%'
   
    local celdaGen = filaGen.tag('td').attr('colspan', 3).css('padding', 0)
    local tablaSuc = celdaGen.tag('table')
    tablaSuc.css('width', '100%')
    local fila = tablaSuc.tag('tr')
      
      
     celda = fila.tag('td')
     celda = fila.tag('td')
Línea 432: Línea 454:


     if argumentosSucesion['estilo fuente'] then
     if argumentosSucesion['estilo fuente'] then
          celda
              celda
                .tag('span')
                  .tag('div')
                    .css('font-style', argumentosSucesion['estilo fuente'])
                      .css('display','inline')
                    .wikitext(argumentosSucesion.anterior)
                      .css('font-style', argumentosSucesion['estilo fuente'])
                      .wikitext(argumentosSucesion.anterior)
                      .done()
     else  
     else  
         celda.wikitext(argumentosSucesion.anterior)
         celda.wikitext(argumentosSucesion.anterior)
Línea 448: Línea 472:
     celda = fila.tag('td')
     celda = fila.tag('td')
     celda
     celda
        .css('width', width)  
          .css('width', width)  
             .css('padding', '0.2em 0.1em')
             .css('padding', '0.2em 0.1em')
             .css('vertical-align', 'middle')
             .css('vertical-align', 'middle')
Línea 454: Línea 478:
              
              
     celda
     celda
        .tag('span')
      .tag('div')
              .css('font-weight', 'bold')
            .css('display','inline')
              .css('font-style', argumentosSucesion['estilo fuente'] or '')
            .css('font-weight', 'bold')
              .wikitext(argumentosSucesion.actual or args.titulo)
            .css('font-style', argumentosSucesion['estilo fuente'] or '')
             
            .wikitext(argumentosSucesion.actual or args.titulo)
            .done()
           
     if argumentosSucesion['año'] then
     if argumentosSucesion['año'] then
         celda
         celda
             .tag('br')
             .tag('br')
             .wikitext('(' .. argumentosSucesion['año'] .. ')')
             .wikitext('(' .. argumentosSucesion['año'] .. ')')
     end            
     end          
      
      
     celda = fila.tag('td')
     celda = fila.tag('td')
Línea 472: Línea 498:
          
          
     if argumentosSucesion['estilo fuente'] then
     if argumentosSucesion['estilo fuente'] then
          celda
              celda
                .tag('span')
                  .tag('div')
                    .css('font-style', argumentosSucesion['estilo fuente'])
                      .css('display','inline')
                    .wikitext(argumentosSucesion.siguiente)
                      .css('font-style', argumentosSucesion['estilo fuente'])
                      .wikitext(argumentosSucesion.siguiente)
                      .done()
     else  
     else  
         celda.wikitext(argumentosSucesion.siguiente)
         celda.wikitext(argumentosSucesion.siguiente)
Línea 500: Línea 528:
                         estiloseccion = fila['estilotitulo'] or fila['estilotítulo'],
                         estiloseccion = fila['estilotitulo'] or fila['estilotítulo'],
                         seccion      = tituloSeccion
                         seccion      = tituloSeccion
                  })
                    })
                 end
                 end
                 hacerFilasTabla(fila)
                 hacerFilasTabla(fila)
Línea 516: Línea 544:
                 })
                 })
             elseif fila.tipo == 'dos columnas'  then -- FALTA
             elseif fila.tipo == 'dos columnas'  then -- FALTA
             elseif fila.tipo == 'tres columnas' then -- FALTA          
             elseif fila.tipo == 'tres columnas' then -- FALTA            
             else                     -- Etiqueta + Datos o solo Datos
             else                         -- Etiqueta + Datos o solo Datos
                 anadirfila({
                 anadirfila({
                     etiqueta      = depurarVacias(fila[1]) or depurarVacias(fila['etiqueta']),
                     etiqueta      = depurarVacias(fila[1]) or depurarVacias(fila['etiqueta']),
Línea 526: Línea 554:
                     clasefila      = fila['clasefila']      or tabla['clasefila']
                     clasefila      = fila['clasefila']      or tabla['clasefila']
                 })
                 })
             end      
             end      
         end
         end
     end   
     end   
Línea 546: Línea 574:


local function hacerBarraWikidata()-- Crea en la parte inferior un enlace al ítem de Wikidata
local function hacerBarraWikidata()-- Crea en la parte inferior un enlace al ítem de Wikidata
     local wikibase = require('Módulo:Wikibase')
      
     local enlacePagina = mw.title.getCurrentTitle().text
     local enlacePagina = mw.title.getCurrentTitle().prefixedText
     local etiquetaPagina = mw.ustring.gsub(enlacePagina,'%s%(.*%)','')  
     local etiquetaPagina = mw.ustring.gsub(enlacePagina,'%s%(.*%)','')  
     local entidad = args.entidad or wikibase.id()
     local entidad = mw.wikibase and mw.wikibase.getEntity and mw.wikibase.getEntity() or nil
 
     local textoPie = ""
     local textoPie = ""
     if  (args.child == 'si' or args.integrada == 'sí' or args.wikidata == 'no') or (mw.title.getCurrentTitle().namespace ~= 0 and mw.title.getCurrentTitle().namespace ~= 104 and not args.entidad) then
     if  (args.child == 'si' or args.integrada == 'sí' or args.wikidata == 'no') or (mw.title.getCurrentTitle().namespace ~= 0 and mw.title.getCurrentTitle().namespace ~= 104 and not args.entidad) then
         textoPie = ''
         textoPie = ''
     elseif  entidad ~= "" and entidad ~= nil  then
     elseif  entidad ~= "" and entidad ~= nil  then
         textoPie = '<div class="plainlinks" style="font-size: 0.85em">&#x5B;[[d:' .. tostring(entidad) .. '|editar datos en Wikidata]]&#x5D;</div>'
         textoPie = '<div class="plainlinks wikidata-link" style="font-size: 0.85em">&#x5B;[[d:' .. tostring(entidad) .. '|editar datos en Wikidata]]&#x5D;</div>'
         if args.entidad and (mw.title.getCurrentTitle().namespace == 0 or mw.title.getCurrentTitle().namespace == 104) then
         if (entidad ~= mw.wikibase.getEntityIdForCurrentPage()) and (mw.title.getCurrentTitle().namespace == 0 or mw.title.getCurrentTitle().namespace == 104) then
         textoPie = textoPie .. '[[Categoría:Wikipedia:Artículos con fichas que utilizan acceso arbitrario]]'
         textoPie = textoPie .. '[[Categoría:Wikipedia:Artículos con fichas que utilizan acceso arbitrario]]'
         end
         end
Línea 568: Línea 597:
         .tag('tr')
         .tag('tr')
            .tag('td')
            .tag('td')
                .addClass('noprint')
                 .attr('colspan', '3')
                 .attr('colspan', '3')
                 .css('text-align', 'left')
                 .css('text-align', 'left')
Línea 619: Línea 649:
     hacerPieDeTabla()   
     hacerPieDeTabla()   
     hacerBarraDeNavegacion()
     hacerBarraDeNavegacion()
     hacerBarraWikidata()
     -- hacerBarraWikidata() -- DESACTIVADO: Causa de error si Wikidata no está configurado.
     hacerCategoriasSeguimiento()
     -- hacerCategoriasSeguimiento() -- DESACTIVADO: Causa de error si Wikidata no está configurado.
      
      
     return tostring(root)
     return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Plantilla:Ficha/imagelimit.css' } } .. tostring(root)
end
end
local function touchParameters(prefixTable, origArgs, step)
local function touchParameters(prefixTable, origArgs, step)
Línea 660: Línea 690:
     local origArgs
     local origArgs
     marco = frame
     marco = frame
     -- Si se llama a través de #invoke, utilice los argumentos pasados ​​a la plantilla de invocación.
     -- Si se llama a través de #invoke, utilice los argumentos pasados a la plantilla de invocación.
     -- De lo contrario, para fines de prueba, asume args que se pasan directamente como parámetros.
     -- De lo contrario, para fines de prueba, asume args que se pasan directamente como parámetros.
     if frame == mw.getCurrentFrame() then
     if frame == mw.getCurrentFrame() then