Módulo:Galería/pruebas
Apariencia
Esta documentación está transcluida desde Módulo:Galería/pruebas/doc.
Por favor, añade las categorías a la subpágina de documentación.
(subpáginas - enlaces)
Por favor, añade las categorías a la subpágina de documentación.
(subpáginas - enlaces)
--[[
Genera galerías a partir de una lista de Índices
]]
require('strict')
local p = {}
local getArgs = require('Módulo:Arguments').getArgs
local Obra = require('Módulo:Obra/pruebas')
local roleString = function(Role)
if type(Role) == 'string' then return Role end
local list = {}
for i, creator in ipairs(Role) do
if creator.text == 'valor desconocido' then
creator.text = '[[Portal:Anónimo|Anónimo]]'
end
list[i] = creator.text
end
return mw.text.listToText(list, ', ', ' y ')
end
local titleString = function(title, wsPage)
-- ya formateado con enlace
if type(title) == 'string' and string.find( title, '%[%[' ) and string.find( title, '%]%]' ) then
return title
end
if wsPage and wsPage ~= "" then
return "[[" .. wsPage .. "|" .. title .. "]]"
end
return "[["..title.."]]"
end
function p.galeria(frame)
local args = getArgs(frame)
local content = {}
if args[1] == nil then return '' end
for file in mw.text.gsplit(args[1], '\n') do
if file =='' then
-- pass
else
if mw.ustring.match(file, 'Índice:') then
file = mw.ustring.sub(file, 8)
end
local index = mw.ext.proofreadPage.newIndex( file )
if not index.title.exists then
-- pass
else
local fields = index.fields
local work = Obra.newWork(file, nil, fields)
-- fields = loadWikidata(fields, work)
local archivo = 'Archivo:' .. file
local page = fields.Imagen
local titulo = work.title
local wsPage = work.wsPage
local title = titleString(titulo, wsPage)
local anyo = work.pubYear
local roles = ''
local coma = false
for i, role in ipairs{'author', 'translator', 'illustrator', 'introducer'} do
local Role = work[role]
if Role and Role ~= '' then
Role = roleString(Role)
if coma then
roles = roles..', <br>'
end
coma = true
if role == 'author' then
roles = roles..'por ' .. Role
elseif role == 'translator' then
roles = roles..'traducido por ' .. Role
elseif role == 'illustrator' then
roles = roles..'ilustrado por ' .. Role
elseif role == 'introducer' then
roles = roles..'prólogo por ' .. Role
end
end
end
local str = archivo .. '|page='..page..'|link=Índice:'..file..'|'
str = str .. "'''"..title.."''' (".. anyo..")"
if roles ~= '' then
str = str.."<br/> <span style=\"font-size: 83%;\">"
str = str..roles
str = str..'</span>'
end
-- TODO: parámetro para no mostrar links de descarga
local dlink = frame:expandTemplate{ title = 'descarga2', args={titulo} }
str= str..'<br/>'..dlink
table.insert(content, str)
end
end
end
local all = table.concat(content, '\n')
local tag = frame:extensionTag( 'gallery', all, { heights = 200, widths = 200, mode="packed" } )
return tag
end
return p