| Contenidos de Wikipedia en español bajo licencia CC BY-SA 4.0 ⇔ Mapas de OpenStreetMap bajo licencia ODbL |
Módulo:Fuentes del libro
De Hispanopedia
La documentación para este módulo puede ser creada en Módulo:Fuentes del libro/doc
-- Módulo:Fuentes del libro
-- Renders a "Buscar este libro" block with three sources below {{Ficha de libro}}:
-- • Casa del Libro (Awin-tracked affiliate, disclosed)
-- • Google Libros (free; uses isbn: query prefix when querying by ISBN)
-- • WorldCat (free)
--
-- Args (read from parent template if invoked via wrapper, else from frame):
-- isbn = ISBN (preferred lookup key; specific edition)
-- titulo = book title (fallback when isbn is empty; uses {{PAGENAME}} if both blank)
--
-- Renders as a <table class="infobox"> so it visually matches the {{Ficha de libro}}
-- above it (same border, same background, same 100%%-width mobile responsive rule).
local p = {}
local AWIN_MID = "21491"
local AWIN_AFFID = "1175128"
local CLICKREF = "fichadelibro"
function p.link( frame )
local parent = frame:getParent()
local args = (parent and parent.args) or frame.args
local isbn = mw.text.trim( args.isbn or "" )
local titulo = mw.text.trim( args.titulo or "" )
if titulo == "" then
titulo = mw.title.getCurrentTitle().text
end
local hasIsbn = isbn ~= ""
local query = hasIsbn and isbn or titulo
if query == "" then
return ""
end
local enc = mw.uri.encode( query, "QUERY" )
-- Casa del Libro via Awin (only affiliate link in the block)
local cdlInner = "https://www.casadellibro.com/busqueda?busqueda=" .. enc .. "&query=" .. enc
local cdlUrl = "https://www.awin1.com/cread.php?awinmid=" .. AWIN_MID
.. "&awinaffid=" .. AWIN_AFFID
.. "&clickref=" .. CLICKREF
.. "&ued=" .. mw.uri.encode( cdlInner, "QUERY" )
-- Google Libros (free; isbn: query prefix only when actually given an ISBN)
local googleQuery = hasIsbn and ("isbn:" .. query) or query
local googleUrl = "https://books.google.com/books?q="
.. mw.uri.encode( googleQuery, "QUERY" ) .. "&hl=es"
-- WorldCat (free)
local worldcatUrl = "https://www.worldcat.org/es/search?q=" .. enc
return string.format(
[[<table class="infobox fuentes-del-libro" style="float:right;clear:right;width:22.7em;font-size:90%%;margin:0.5em 0 0.5em 1em;line-height:1.4em;text-align:left;padding:.23em;">]]
.. [[<caption style="font-weight:bold;text-align:center;padding:0.2em 0;">Buscar este libro</caption>]]
.. [[<tr><td style="padding:0.2em 0.4em;">📕 [%s Casa del Libro] (Enlace Afiliado)</td></tr>]]
.. [[<tr><td style="padding:0.2em 0.4em;">🔍 [%s Google Libros] (Proyecto Biblioteca)</td></tr>]]
.. [[<tr><td style="padding:0.2em 0.4em;">🌐 [%s WorldCat] (Catálogo mundial)</td></tr>]]
.. [[</table>]],
cdlUrl, googleUrl, worldcatUrl )
end
return p