Modulo:Controllo di autorità: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
tolgo url NL e inserisco quello .org così da avere lo stesso URL di formattazione che c'è su Wikidata - sostanzialmente non dovrebbe cambiare nulla |
m upd |
||
Riga 38: | Riga 38: | ||
-- principali codici di controllo di autorità |
-- principali codici di controllo di autorità |
||
-- si veda [[d:Property:P1630]] |
|||
-- [[d:MediaWiki:Gadget-AuthorityControl.js]] per una lista completa |
|||
local codici = { |
local codici = { |
||
{ 213, '[[w:International Standard Name Identifier|ISNI]]', 'http://isni.org/%s/', isniLink}, |
{ 213, '[[w:International Standard Name Identifier|ISNI]]', 'http://isni.org/%s/', isniLink}, |
Versione delle 04:32, 8 nov 2015
La documentazione per questo modulo può essere creata in Modulo:Controllo di autorità/man
--la tabella dei codici si trova più sotto
--Returns the ISNI check digit isni must be a string where the 15 first elements are digits
local function getIsniCheckDigit( isni )
local total = 0
for i = 1, 15 do
local digit = isni:byte( i ) - 48 --Get integer value
total = (total + digit) * 2
end
local remainder = total % 11
local result = (12 - remainder) % 11
if result == 10 then
return "X"
end
return tostring( result )
end
--Validate ISNI (and ORCID) and retuns it as a 16 characters string or returns false if it's invalid
--See http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
local function validateIsni( id )
id = id:gsub( '[ %-]', '' ):upper()
if not id:match( '^%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d[%dX]$' ) then
return false
end
if getIsniCheckDigit( id ) ~= string.char( id:byte( 16 ) ) then
return false
end
return id
end
local function isniLink( id )
id = validateIsni( id )
if not id then
return false
end
return '[http://isni.org/isni/' .. id .. ' ' .. id:sub( 1, 4 ) .. ' ' .. id:sub( 5, 8 ) .. ' ' .. id:sub( 9, 12 ) .. ' ' .. id:sub( 13, 16 ) .. ']'
end
-- principali codici di controllo di autorità
-- si veda [[d:Property:P1630]]
local codici = {
{ 213, '[[w:International Standard Name Identifier|ISNI]]', 'http://isni.org/%s/', isniLink},
{ 214, '[[w:Virtual International Authority File|VIAF]]', '//viaf.org/viaf/%s/' },
{ 227, '[[w:Gemeinsame Normdatei|GND]]', 'http://d-nb.info/gnd/%s' },
{ 244, '[[w:Library of Congress Control Number|LCCN]]', 'http://lccn.loc.gov/%s' },
{ 268, '[[w:Bibliothèque nationale de France|BNF]]', 'http://catalogue.bnf.fr/ark:/12148/cb%s/PUBLIC' },
{ 396, '[[w:Servizio bibliotecario nazionale|SBN]]', 'http://id.sbn.it/af/%s' },
{ 1871, '[[w:de:Consortium of European Research Libraries|CERL]]', 'http://thesaurus.cerl.org/record/%s' }
}
function val(item, prop)
local claims = item.claims
local res = {}
if claims and claims['P'..prop[1]] then
for index, claim in pairs(claims['P'..prop[1]]) do
local dv = claim.mainsnak.datavalue
if dv and dv.value and type(dv.value) == 'string' and mw.text.trim(dv.value) ~= '' then
if prop[4] then
table.insert(res, prop[4](dv.value))
else
table.insert(res, '['..mw.ustring.format(prop[3], mw.uri.encode(dv.value, 'PATH'))..' '..dv.value..']')
end
end
end
end
if #res > 0 then
return prop[2] .. mw.message.new('colon-separator'):plain() .. table.concat(res, mw.message.new('comma-separator'):plain())
else
return nil
end
end
local p = {}
-- per l'uso da parte di altri moduli
function p.box(item)
if mw.wikibase and not item then
item = mw.wikibase.getEntityObject()
end
if not item then
return ''
end
local res = {}
for i, v in ipairs(codici) do
local x = val(item, v)
if x then
table.insert(res, '*'..x)
end
end
if #res > 0 then
return tostring(
mw.html.create('table')
:addClass('toccolours')
:addClass('plainlinks')
-- non usa l'intera larghezza della pagina
-- :css('width','100%')
:attr('cellpadding', '4')
:tag('tr')
:css('vertical-align', 'top')
:tag('td')
:css{
background = '#ccf',
['text-align'] = 'right',
['padding-right'] = '0.4em',
width = '15%',
['font-weight'] = 'bold',
['white-space'] = 'nowrap'
}
:wikitext('[[w:Controllo di autorità|Schede di autorità]]')
:done()
:tag('td')
:tag('div')
:addClass('hlist')
:wikitext('\n'..table.concat(res, '\n'))
:allDone()
)
else
return ''
end
end
-- da invocare nel wikicodice
function p.ext(frame)
return p.box()
end
return p