Más idiomas
Más acciones
La documentación para este módulo puede ser creada en Módulo:Citación web/doc
local p = {}
local function is_set (var)
return not (var == nil or var == '');
end
local function italics (var)
return "''" .. var .. "''"
end
function p.cita( frame )
local pframe = frame:getParent()
local Autor = pframe.args['autor'] or pframe.args.author
local Date = pframe.args['data'] or pframe.args['date']
local Title = pframe.args['titulo'] or pframe.args['título'] or pframe.args.title
local URL = pframe.args['url'] or pframe.args.url
local Newspaper = pframe.args['pagina-web'] or pframe.args.newspaper
local ArchiveURL = pframe.args['archivo-url'] or pframe.args['archive-url']
local ArchiveDate = pframe.args['archivo-data'] or pframe.args['archive-date']
local Retrieved = pframe.args['consultado'] or pframe.args.retrieved
local Quote = pframe.args['cita'] or pframe.args.quote
local Image = pframe.args['imagen'] or pframe.args.image
local ImageCaption = pframe.args['pie-imagen'] or pframe.args['image-caption']
if is_set (Autor) then
if is_set (Date) then
first_part = Autor .. " (" .. Date .. ")."
else
first_part = Autor .. "."
end
else
first_part = ""
end
if is_set (Image) then
local span = mw.html.create ( 'span' )
span
:wikitext('[[File:' .. Image .. '|center|300px|frameless]]')
local br = mw.html.create ('br', selfClosing)
if is_set(ImageCaption) then
local caption = mw.html.create ('div')
caption
:attr("style", "text-align:center;font-size:85%;")
:wikitext(ImageCaption)
first_part = tostring(span) .. tostring(caption) .. first_part
else
first_part = tostring(span) .. first_part
end
end
if is_set (Title) then
if is_set (URL) then
Title = "[" .. URL .. " " .. "\"" .. Title .. "\"" .. "]"
end
if not is_set (Autor) then
if is_set (Date) then
Title = Title .. " (" .. Date .. ")."
else
Title = Title .. "."
end
end
second_part = Title
else
second_part = ""
end
if is_set(Newspaper) then
third_part = "''" .. Newspaper .. "''."
else
third_part = ""
end
if is_set(ArchiveURL) then
if is_set(ArchiveDate) then
fourth_part = "[" .. ArchiveURL .. " Archivado] desde el original en " .. ArchiveDate .. "."
else
fourth_part = "[" .. ArchiveURL .. " " .. "Archivado] desde el original."
end
else
fourth_part = ""
end
if is_set (Retrieved) then
fifth_part = "Consultado en" .. " " .. Retrieved .. "."
else
fifth_part = ""
end
if is_set (Quote) then
Quote = string.gsub(Quote,"\n","<br>")
Quote = "“" .. Quote .. "”"
local div = mw.html.create ('div')
div
:attr("style", "width:80%; margin-left:10%;")
:wikitext(Quote)
local br = mw.html.create ('br', selfClosing)
first_part = italics(tostring(div)) .. tostring(br) .. first_part
end
if is_set (first_part) then
first_part = first_part .. " "
end
if is_set (second_part) then
second_part = second_part .. " "
end
if is_set (third_part) then
third_part = third_part .. " "
end
if is_set (fourth_part) then
fourth_part = fourth_part .. " "
end
Render = first_part .. second_part .. third_part .. fourth_part .. fifth_part
return Render
end
return p