Diferencia entre revisiones de «Módulo:Ficha»

Sin resumen de edición
m Revertidos los cambios de Miguillen (disc.) a la última edición de Abián
Línea 5: Línea 5:
local p = {}
local p = {}
   
   
--local HtmlBuilder = require('Module:HtmlBuilder')
local HtmlBuilder = require('Module:HtmlBuilder')
local marco = {}  
local marco = {}  
local args
local args
Línea 53: Línea 53:
     if rowArgs.seccion then
     if rowArgs.seccion then
         root
         root
             :tag('tr')
             .tag('tr')
                 :tag('th')
                 .tag('th')
                     :attr('colspan', 3)
                     .attr('colspan', 3)
                     :addClass(rowArgs.clasefila)
                     .addClass(rowArgs.clasefila)
                     :css('text-align', 'center')
                     .css('text-align', 'center')
                     :cssText(rowArgs.estiloseccion or args.estiloseccion)
                     .cssText(rowArgs.estiloseccion or args.estiloseccion)
                     :wikitext(rowArgs.seccion)
                     .wikitext(rowArgs.seccion)
     elseif rowArgs.datos then
     elseif rowArgs.datos then
         local fila = root:tag('tr')
         local fila = root.tag('tr')
         fila.addClass(rowArgs.clasefila)
         fila.addClass(rowArgs.clasefila)
         if rowArgs.etiqueta then
         if rowArgs.etiqueta then
             fila
             fila
                 :tag('th')
                 .tag('th')
                     :attr('scope', 'row')
                     .attr('scope', 'row')
                     :css('text-align', 'left')
                     .css('text-align', 'left')
                     :addClass(rowArgs.clasefila)
                     .addClass(rowArgs.clasefila)
                     :cssText (rowArgs.estiloetiqueta or args.estiloetiqueta)
                     .cssText (rowArgs.estiloetiqueta or args.estiloetiqueta)
                     :wikitext(rowArgs.etiqueta)
                     .wikitext(rowArgs.etiqueta)
                     :done()
                     .done()
         end
         end
          
          
         local datosCelula = fila:tag('td')
         local datosCelula = fila.tag('td')
         if rowArgs.etiqueta then  
         if rowArgs.etiqueta then  
             datosCelula
             datosCelula
                 :attr('colspan', 2)
                 .attr('colspan', 2)
         else
         else
             datosCelula
             datosCelula
                 :attr('colspan', 3)
                 .attr('colspan', 3)
                 :css('text-align', 'center')  
                 .css('text-align', 'center')  
         end
         end
         datosCelula
         datosCelula
             :addClass(rowArgs.clase)
             .addClass(rowArgs.clase)
             :cssText (rowArgs.estilodatos or args.estilodatos)
             .cssText (rowArgs.estilodatos or args.estilodatos)
             :wikitext(detectaTablas(rowArgs.datos))
             .wikitext(detectaTablas(rowArgs.datos))
     end
     end
end
end
Línea 105: Línea 105:
     end
     end
     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 'black')
               :cssText(args.estilotitulo)
               .cssText(args.estilotitulo)
               :wikitext(args.titulo)
               .wikitext(args.titulo)
end
end
local function hacerFilaArriba()
local function hacerFilaArriba()
Línea 119: Línea 119:
   
   
     root
     root
         :tag('tr')
         .tag('tr')
             :tag('th')
             .tag('th')
                 :attr('colspan', 3)
                 .attr('colspan', 3)
                 :addClass(args.clasearribaor or args.clasetitulo2)
                 .addClass(args.clasearribaor or args.clasetitulo2)
                 :css('text-align', 'center')
                 .css('text-align', 'center')
                 :css('font-size', '125%')
                 .css('font-size', '125%')
                 :css('font-weight', 'bold')
                 .css('font-weight', 'bold')
                 :cssText(args.estiloarriba or args.estilotitulo2)
                 .cssText(args.estiloarriba or args.estilotitulo2)
                 :wikitext(args.arriba or args.titulo2)
                 .wikitext(args.arriba or args.titulo2)
end
end


Línea 134: Línea 134:
      
      
     root
     root
         :tag('tr')
         .tag('tr')
             :tag('td')
             .tag('td')
                 :attr('colspan', '3')
                 .attr('colspan', '3')
                 :addClass(args.clasepiedetabla)
                 .addClass(args.clasepiedetabla)
                 :css('text-align', 'center')
                 .css('text-align', 'center')
                 :cssText(args.estilopiedetabla)
                 .cssText(args.estilopiedetabla)
                 :wikitext(args.piedetabla)
                 .wikitext(args.piedetabla)
end
end
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
Línea 155: Línea 155:
      
      
     root
     root
         :tag('tr')
         .tag('tr')
             :tag('td')
             .tag('td')
                 :attr('colspan', '3')
                 .attr('colspan', '3')
                 :addClass(args.claseimageninferior)
                 .addClass(args.claseimageninferior)
                 :css('text-align', 'center')
                 .css('text-align', 'center')
                 :cssText(args.estiloimageninferior)
                 .cssText(args.estiloimageninferior)
                 :newline()
                 .newline()
                 :wikitext(imageninferior)
                 .wikitext(imageninferior)
                 :tag('br', {selfClosing = true})
                 .tag('br', {selfClosing = true})
                     :done()
                     .done()
                 :tag('span')
                 .tag('span')
                     :cssText(args.estilopieinferior)
                     .cssText(args.estilopieinferior)
                     :wikitext(args.pieinferior)
                     .wikitext(args.pieinferior)
                     :newline()
                     .newline()
end
end


Línea 184: Línea 184:
      
      
     root
     root
         :tag('tr')
         .tag('tr')
             :tag('td')
             .tag('td')
                 :attr('colspan', '3')
                 .attr('colspan', '3')
                 :addClass(args.claseimagensuperior)
                 .addClass(args.claseimagensuperior)
                 :css('text-align', 'center')
                 .css('text-align', 'center')
                 :cssText(args.estiloimagensuperior)
                 .cssText(args.estiloimagensuperior)
                 :newline()
                 .newline()
                 :wikitext(imagensuperior)
                 .wikitext(imagensuperior)
                 :tag('br', {selfClosing = true})
                 .tag('br', {selfClosing = true})
                     :done()
                     .done()
                 :tag('span')
                 .tag('span')
                     :cssText(args.estilopiesuperior)
                     .cssText(args.estilopiesuperior)
                     :wikitext(args.piesuperior)
                     .wikitext(args.piesuperior)
                     :newline()
                     .newline()
end
end


Línea 250: Línea 250:
        
        
       root
       root
         :tag('tr')
         .tag('tr')
         :tag('td')
         .tag('td')
         --:attr('cellspacing', '0em')
         --.attr('cellspacing', '0em')
         --:attr('padding','0em')
         --.attr('padding','0em')
         :attr('colspan', '3')
         .attr('colspan', '3')
         :css('align', 'center')
         .css('align', 'center')
         :tag('table') -- tiene que ir dentro de una tabla para que las filas no lo deformen
         .tag('table') -- tiene que ir dentro de una tabla para que las filas no lo deformen
         :css('width', '100%')
         .css('width', '100%')
         :addClass('mergedrow')
         .addClass('mergedrow')
         :tag('tr')
         .tag('tr')
             :tag('td')
             .tag('td')
             :css('text-align', 'center')
             .css('text-align', 'center')
                 :css('background-color', 'transparent')
                 .css('background-color', 'transparent')
                 :addClass(args.claseimagenizquiera)
                 .addClass(args.claseimagenizquiera)
                 :css('align', 'center')-- Se alinea en el centro horizontal
                 .css('align', 'center')-- Se alinea en el centro horizontal
                 :css('text-align', 'center') -- Se alinea en el centro horizontal
                 .css('text-align', 'center') -- Se alinea en el centro horizontal
                 :css('vertical-align', 'middle')-- Se alinea en el centro vertical  
                 .css('vertical-align', 'middle')-- Se alinea en el centro vertical  
                 :cssText(args.estiloimagenizquierda)
                 .cssText(args.estiloimagenizquierda)
                 :wikitext('[[Archivo:' .. args.imagenizquierda .. '|' .. args['tamañoimagenizquierda'] .. ']]' )
                 .wikitext('[[Archivo:' .. args.imagenizquierda .. '|' .. args['tamañoimagenizquierda'] .. ']]' )
                 :tag('br')
                 .tag('br')
                 --:tag('span')
                 .tag('span')
                 :cssText(args.estilopieizquierdo)
                 .cssText(args.estilopieizquierdo)
                 :wikitext(args.pieizquierdo)
                 .wikitext(args.pieizquierdo)
             :tag('td')
             .tag('td')
                 :css('text-align', 'center')-- Se alinea en el centro horizontal
                 .css('text-align', 'center')-- Se alinea en el centro horizontal
                 :css('align', 'center')-- Se alinea en el centro horizontal
                 .css('align', 'center')-- Se alinea en el centro horizontal
                 :css('vertical-align', 'middle')-- Se alinea en el centro vertical
                 .css('vertical-align', 'middle')-- Se alinea en el centro vertical
                 :css('background-color', 'transparent')
                 .css('background-color', 'transparent')
                 :addClass(args.claseimagenderecha)
                 .addClass(args.claseimagenderecha)
                 :cssText(args.estiloimagenderecha)       
                 .cssText(args.estiloimagenderecha)       
                 :wikitext('[[Archivo:' .. args.imagenderecha .. '|' .. args['tamañoimagenderecha'] .. ']]' )
                 .wikitext('[[Archivo:' .. args.imagenderecha .. '|' .. args['tamañoimagenderecha'] .. ']]' )
                 :tag('br')
                 .tag('br')
                 :tag('span')
                 .tag('span')
                 :cssText(args.estilopiederecho)
                 .cssText(args.estilopiederecho)
                 :wikitext(args.piederecho)
                 .wikitext(args.piederecho)
                 :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
Línea 301: Línea 301:
           end
           end
       root
       root
         :tag('tr')
         .tag('tr')
             :tag('td')
             .tag('td')
                 :attr('colspan', '3')
                 .attr('colspan', '3')
                 :addClass(args['clase' .. imagenL])
                 .addClass(args['clase' .. imagenL])
                 :css('text-align', 'center')
                 .css('text-align', 'center')
                 :cssText(args['estilo' .. imagenL])
                 .cssText(args['estilo' .. imagenL])
                 :newline()
                 .newline()
                 :wikitext('[[Archivo:' ..  args[imagenL] .. '|'.. args['tamaño'..imagenL] .. ']]' )
                 .wikitext('[[Archivo:' ..  args[imagenL] .. '|'.. args['tamaño'..imagenL] .. ']]' )
                 :tag('br')
                 .tag('br')
                 :tag('span')
                 .tag('span')
                 :cssText(args['estilo' .. pieL])
                 .cssText(args['estilo' .. pieL])
                 :wikitext(args[pieL])
                 .wikitext(args[pieL])
     end
     end
     end
     end
Línea 342: Línea 342:
             imagen = args['imagen'..num]
             imagen = args['imagen'..num]
             end
             end
         local datos = mw.html.create():wikitext(imagen)
         local datos = HtmlBuilder.create().wikitext(imagen)
         if pie and not flotante then
         if pie and not flotante then
         datos
         datos
                 :tag('br', {selfClosing = true})
                 .tag('br', {selfClosing = true})
                     :done()
                     .done()
         end
         end
         if pie then
         if pie then
             datos
             datos
                 :tag('span')
                 .tag('span')
                     :cssText(args.estilopie)
                     .cssText(args.estilopie)
                     :wikitext(pie)
                     .wikitext(pie)
         end
         end
         anadirfila({
         anadirfila({
Línea 406: Línea 406:


function anadirSucesion(argumentosSucesion)
function anadirSucesion(argumentosSucesion)
     local fila = root:tag('tr')
     local fila = root.tag('tr')
     fila:css('font-size', '88%')
     fila.css('font-size', '88%')
     fila:css('text-align', 'center')
     fila.css('text-align', 'center')
      
      
     local celda
     local celda
Línea 415: Línea 415:
     width = '33%'
     width = '33%'
      
      
     celda = fila:tag('td')
     celda = fila.tag('td')
     celda
     celda
             :css('width', width)
             .css('width', width)
             :css('padding', '0.2em 0.1em 0.2em 0')
             .css('padding', '0.2em 0.1em 0.2em 0')
             :css('vertical-align', 'middle')
             .css('vertical-align', 'middle')


     if argumentosSucesion['estilo fuente'] then
     if argumentosSucesion['estilo fuente'] then
           celda
           celda
                 :tag('span')
                 .tag('span')
                     :css('font-style', argumentosSucesion['estilo fuente'])
                     .css('font-style', argumentosSucesion['estilo fuente'])
                     :wikitext(argumentosSucesion.anterior)
                     .wikitext(argumentosSucesion.anterior)
     else  
     else  
         celda:wikitext(argumentosSucesion.anterior)
         celda.wikitext(argumentosSucesion.anterior)
     end
     end
          
          
     if argumentosSucesion['año anterior'] then
     if argumentosSucesion['año anterior'] then
         celda
         celda
             :tag('br')
             .tag('br')
             :wikitext('(' .. argumentosSucesion['año anterior'] .. ')')
             .wikitext('(' .. argumentosSucesion['año anterior'] .. ')')
     end
     end
      
      
     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')
             :css('background-color', argumentosSucesion.color or '#E6E8FA')
             .css('background-color', argumentosSucesion.color or '#E6E8FA')
              
              
     celda
     celda
         :tag('span')
         .tag('span')
               :css('font-weight', 'bold')
               .css('font-weight', 'bold')
               :css('font-style', argumentosSucesion['estilo fuente'] or '')
               .css('font-style', argumentosSucesion['estilo fuente'] or '')
               :wikitext(argumentosSucesion.actual or args.titulo)
               .wikitext(argumentosSucesion.actual or args.titulo)
                
                
     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')
     celda
     celda
             :css('width', width)
             .css('width', width)
             :css('padding', '0.2em 0 0.2em 0.1em')
             .css('padding', '0.2em 0 0.2em 0.1em')
             :css('vertical-align', 'middle')
             .css('vertical-align', 'middle')
          
          
     if argumentosSucesion['estilo fuente'] then
     if argumentosSucesion['estilo fuente'] then
           celda
           celda
                 :tag('span')
                 .tag('span')
                     :css('font-style', argumentosSucesion['estilo fuente'])
                     .css('font-style', argumentosSucesion['estilo fuente'])
                     :wikitext(argumentosSucesion.siguiente)
                     .wikitext(argumentosSucesion.siguiente)
     else  
     else  
         celda:wikitext(argumentosSucesion.siguiente)
         celda.wikitext(argumentosSucesion.siguiente)
     end
     end
          
          
     if argumentosSucesion['año siguiente'] then
     if argumentosSucesion['año siguiente'] then
         celda
         celda
             :tag('br')
             .tag('br')
             :wikitext('(' .. argumentosSucesion['año siguiente'] .. ')')
             .wikitext('(' .. argumentosSucesion['año siguiente'] .. ')')
     end
     end
end
end
Línea 525: Línea 525:
      
      
     root
     root
         :tag('tr')
         .tag('tr')
             :tag('td')
             .tag('td')
                 :attr('colspan', '3')
                 .attr('colspan', '3')
                 :css('text-align', 'right')
                 .css('text-align', 'right')
                 :wikitext(mw.getCurrentFrame():expandTemplate({  
                 .wikitext(mw.getCurrentFrame():expandTemplate({  
                     title = 'navbar',  
                     title = 'navbar',  
                     args = { args.nombre, mini = 1 }
                     args = { args.nombre, mini = 1 }
Línea 553: Línea 553:
     if textoPie ~= '' then
     if textoPie ~= '' then
     root
     root
         :tag('tr')
         .tag('tr')
            :tag('td')
            .tag('td')
                 :attr('colspan', '3')
                 .attr('colspan', '3')
                 :css('text-align', 'left')
                 .css('text-align', 'left')
                 :wikitext(textoPie)
                 .wikitext(textoPie)
     end
     end
end
end
local function hacerCategoriasSeguimiento()
local function hacerCategoriasSeguimiento()
     if args.decat ~= 'si' and #(getArgNums('datos')) == 0 and not args[1] and mw.title.getCurrentTitle().namespace == 0 then
     if args.decat ~= 'si' and #(getArgNums('datos')) == 0 and not args[1] and mw.title.getCurrentTitle().namespace == 0 then
         root:wikitext('[[Categoría:Wikipedia:Artículos que usan ficha sin datos en filas]]')
         root.wikitext('[[Categoría:Wikipedia:Artículos que usan ficha sin datos en filas]]')
     end
     end
end
end
Línea 568: Línea 568:
function _infobox()
function _infobox()
     if args.child ~= 'si' and args.integrada ~= 'sí' then
     if args.child ~= 'si' and args.integrada ~= 'sí' then
         root = mw.html.create('table')
         root = HtmlBuilder.create('table')
          
          
         root  -- Estilo de toda la ficha         
         root  -- Estilo de toda la ficha         
             :addClass('infobox_v2 ')
             .addClass('infobox_v2 ')
             :addClass(args.clase)
             .addClass(args.clase)
             :cssText('width:22.7em; line-height: 1.4em; text-align:left; padding:.23em') -- Lo mismo que la plantilla:Ficha
             .cssText('width:22.7em; line-height: 1.4em; text-align:left; padding:.23em') -- Lo mismo que la plantilla:Ficha
             :cssText(args.estilo)
             .cssText(args.estilo)
         if args.estilo then
         if args.estilo then
         root:wikitext('[[Categoría:Wikipedia:Fichas con el parámetro estilo]]')
         root.wikitext('[[Categoría:Wikipedia:Fichas con el parámetro estilo]]')
         end
         end
      
      
Línea 582: Línea 582:
         hacerFilaArriba()
         hacerFilaArriba()
     else
     else
         root = mw.html.create()
         root = HtmlBuilder.create()
          
          
         if args.titulo then
         if args.titulo then
             root:wikitext("'''" .. args.titulo .. "'''")
             root.wikitext("'''" .. args.titulo .. "'''")
         end
         end
     end
     end