Modulo:Nukat
Aspetto
Il modulo NUKAT riceve un id del sito Narodowy Uniwersalny Katalog Centralny e restituisce la pagina web relativa.
È utilizzato dal template {{controllo autorità}} che pone il link in tabella con altre biblioteche. Inserire nelle voci che lo richiedono.
local p = {}
function p.visualizza(frame)
-- 1. Recupero ID (dal primo parametro o da Wikidata)
local args = frame.args
local raw_id = args[1] -- Legge il primo parametro anonimo
if not raw_id or raw_id == "" then
raw_id = frame:getParent().args[1]
end
if not raw_id or raw_id == "" then
local entity = mw.wikibase.getEntity()
if entity and entity:formatPropertyValues("P1207") then
raw_id = entity.claims["P1207"][1].mainsnak.datavalue.value
end
end
if not raw_id or raw_id == "" then return "" end
-- 2. Pulizia ID: isola solo i numeri
local numeri = raw_id:gsub("%s+", ""):match("n?(%d+)")
if not numeri then return raw_id end
-- 3. LOGICA DEGLI SPAZI (Padding)
-- n + 1 spazio (%20) + 10 cifre
-- n + 2 spazi (%20%20) + 8 cifre
local padding = "%20"
if #numeri <= 8 then
padding = "%20%20"
end
-- 4. Costruzione URL (aggiornato a Koha)
local url_base = "https://katalog.nukat.edu.pl/cgi-bin/koha/opac-authorities-home.pl"
local query = "?op=do_search&type=opac&operator=exact&value=n" .. padding .. numeri .. "&marclist=lc-card-number&and_or=&excluding=&order_by="
local url_completo = url_base .. query
-- 5. Etichetta
local etichetta = "n" .. numeri
-- 6. Risultato
return "[" .. url_completo .. " " .. etichetta .. "]"
end
return p