Diferencia entre revisiones de «Módulo:Ficha»
Sin resumen de edición |
Sin resumen de edición |
||
| 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 | ||
| 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') | |||
.attr('colspan', 3) | |||
.addClass(cabecera) | |||
.css('text-align', 'center') | |||
.css('background-color', args.colorfondo or args.colorfondotitulo or 'transparent') | |||
.css('color', args.colortexto or 'inherit') | |||
.cssText(args.estilotitulo) | |||
.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 = {} | |||
if args['tamañoimageninferior'] == nil or args['tamañoimageninferior'] == '' then | |||
args['tamañoimageninferior'] = anchoImagen | |||
end | |||
if string.find(args.imageninferior, '[{[]') == nil then | |||
imageninferior = ('[[Archivo:' .. args.imageninferior .. '|'.. args['tamañoimageninferior'] .. ']]' ) | |||
else | |||
imageninferior = args.imageninferior | |||
end | |||
root | root | ||
| Línea 184: | Línea 184: | ||
end | end | ||
imagensuperior = {} | imagensuperior = {} | ||
if string.find(args.imagensuperior, '[{[]') == nil then | |||
imagensuperior = ('[[Archivo:' .. args.imagensuperior .. '|'.. args['tamañoimagensuperior'] .. ']]' ) | |||
else | |||
imagensuperior = args.imagensuperior | |||
end | |||
root | root | ||
| Línea 249: | 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 | |||
if args['tamañoimagenderecha'] == "" or args['tamañoimagenderecha'] == nil then | |||
args['tamañoimagenderecha'] = '100px' | args['tamañoimagenderecha'] = '100px' | ||
end | |||
if args.imagenderecha and args.imagenizquierda then | if args.imagenderecha and args.imagenizquierda then | ||
if args.pieizquierdo then brcondicionalizquierdo = 'br' end | |||
if args.piederecho then brcondicionalderecho = 'br' end | |||
root | |||
.tag('tr') | .tag('tr') | ||
.tag('td') | .tag('td') | ||
| Línea 301: | Línea 301: | ||
.done() | .done() | ||
.newline() | .newline() | ||
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 = {} | |||
if args.imagenderecha ~= '' and args.imagenderecha ~= nil then | if args.imagenderecha ~= '' and args.imagenderecha ~= nil then | ||
imagenL = 'imagenderecha' | imagenL = 'imagenderecha' | ||
| Línea 309: | Línea 309: | ||
imagenL = 'imagenizquierda' | imagenL = 'imagenizquierda' | ||
end | end | ||
pieL = {} | |||
if args.imagenderecha then | |||
pieL = 'piederecho' | pieL = 'piederecho' | ||
elseif args.imagenizquierda then | |||
pieL = 'pieizquierdo' | pieL = 'pieizquierdo' | ||
end | |||
root | |||
.tag('tr') | .tag('tr') | ||
.tag('td') | .tag('td') | ||
| Línea 333: | Línea 333: | ||
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 343: | Línea 343: | ||
if args['imagenmodooscuro'] then | if args['imagenmodooscuro'] then | ||
args['imagenmodooscuro1'] = args['imagenmodooscuro'] | args['imagenmodooscuro1'] = args['imagenmodooscuro'] | ||
end | |||
if args.pie then | if args.pie then | ||
| Línea 454: | Línea 454: | ||
if argumentosSucesion['estilo fuente'] then | if argumentosSucesion['estilo fuente'] then | ||
celda | |||
.tag('div') | |||
.css('display','inline') | |||
.css('font-style', argumentosSucesion['estilo fuente']) | |||
.wikitext(argumentosSucesion.anterior) | |||
.done() | |||
else | else | ||
celda.wikitext(argumentosSucesion.anterior) | celda.wikitext(argumentosSucesion.anterior) | ||
| Línea 472: | Línea 472: | ||
celda = fila.tag('td') | celda = fila.tag('td') | ||
celda | celda | ||
.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 478: | Línea 478: | ||
celda | celda | ||
.tag('div') | |||
.css('display','inline') | |||
.css('font-weight', 'bold') | |||
.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 498: | Línea 498: | ||
if argumentosSucesion['estilo fuente'] then | if argumentosSucesion['estilo fuente'] then | ||
celda | |||
.tag('div') | |||
.css('display','inline') | |||
.css('font-style', argumentosSucesion['estilo fuente']) | |||
.wikitext(argumentosSucesion.siguiente) | |||
.done() | |||
else | else | ||
celda.wikitext(argumentosSucesion.siguiente) | celda.wikitext(argumentosSucesion.siguiente) | ||
| Línea 528: | 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 544: | 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 | 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 554: | Línea 554: | ||
clasefila = fila['clasefila'] or tabla['clasefila'] | clasefila = fila['clasefila'] or tabla['clasefila'] | ||
}) | }) | ||
end | end | ||
end | end | ||
end | end | ||
| Línea 574: | 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 enlacePagina = mw.title.getCurrentTitle().prefixedText | local enlacePagina = mw.title.getCurrentTitle().prefixedText | ||
local etiquetaPagina = mw.ustring.gsub(enlacePagina,'%s%(.*%)','') | local etiquetaPagina = mw.ustring.gsub(enlacePagina,'%s%(.*%)','') | ||
| Línea 649: | 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 mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Plantilla:Ficha/imagelimit.css' } } .. tostring(root) | return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Plantilla:Ficha/imagelimit.css' } } .. tostring(root) | ||
| Línea 690: | Línea 690: | ||
local origArgs | local origArgs | ||
marco = frame | marco = frame | ||
-- Si se llama a través de #invoke, utilice los argumentos pasados | -- 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 | ||