Modulo:Controllo di autorità/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
migliorata gestione categorie per identificativo, semplificata e separata
riordinate le funzioni in base alla configurazione, commentate le inutilizzate
Riga 1:
--[[
* Modulo che implementa le funzionalità delil template {{Controllo di autorità}}.
* Il modulo è stato importato inizialmente da:
* http://en.wikipedia.org/w/index.php?title=Module:Authority_control&oldid=633242817
]]
Riga 16:
end
 
-- Returns the ISNI check digit isni must be a string where the 15 first elements are digits
local function kulturnavLink( id )
local function getIsniCheckDigit( isni )
return '[http://kulturnav.org/language/en/' .. id .. ' id]'
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
local function sikartLink( id )
-- See http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
return '[http://www.sikart.ch/KuenstlerInnen.aspx?id=' .. id .. '&lng=en ' .. id .. ']'
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 tlsLinkisniLink( id )
id = validateIsni( id )
local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
if not id then
return '[http://tls.theaterwissenschaft.ch/wiki/' .. id2 .. ' ' .. id .. ']'
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
 
local function ciniiLinksbnLink( id )
if not string.match( id, '^IT\\ICCU\\%d%d%d%d%d%d%d%d%d%d$' ) and not string.match( id, '^IT\\ICCU\\%u%u[%d%u]%u\\%d%d%d%d%d%d$' ) then
return '[http://ci.nii.ac.jp/author/' .. id .. '?l=en ' .. id .. ']'
return false
end
return '[http://opac.sbn.it/opacsbn/opac/iccu/scheda_authority.jsp?bid=' .. id .. ' ' .. id .. ']'
end
 
local function bneLinkappend(str, idc, length)
while str:len() < length do
return '[http://catalogo.bne.es/uhtbin/authoritybrowse.cgi?action=display&authority_id=' .. id .. ' ' .. id .. ']'
str = c .. str
end
return str
end
 
local function uscongressLinksplitLccn( id )
if id:match( '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
return '[http://bioguide.congress.gov/scripts/biodisplay.pl?index=' .. id .. ' ' .. id .. ']'
id = id:gsub( '^(%l+)(%d+)(%d%d%d%d%d%d)$', '%1/%2/%3' )
end
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
 
local function narapersonLinklccnLink( id )
local parts = splitLccn( id )
return '[http://research.archives.gov/person/' .. id .. ' ' .. id .. ']'
if not parts then
return false
end
local lccnType = parts[1] ~= 'sh' and 'names' or 'subjects'
id = parts[1] .. parts[2] .. append( parts[3], '0', 6 )
return '[http://id.loc.gov/authorities/' .. lccnType .. '/' .. id .. ' ' .. id .. ']'
end
 
local function naraorganizationLinkorcidLink( id )
id = validateIsni( id )
return '[http://research.archives.gov/organization/' .. id .. ' ' .. id .. ']'
if not id then
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '[http://orcid.org/' .. id .. ' ' .. id .. ']'
end
 
local function botanistLinkgndLink( id )
return '[http://d-nb.info/gnd/' .. id .. ' ' .. id .. ']'
local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '[http://www.ipni.org/ipni/advAuthorSearch.do?find_abbreviation=' .. id2 .. ' ' .. id .. ']'
end
 
local function mgpLinkbnfLink( id )
-- Add cb prefix if it has been removed
-- TODO Implement some sanity checking regex
if not string.match( id, '^cb.+$' ) then
return '[http://www.genealogy.ams.org/id.php?id=' .. id .. ' ' .. id .. ']'
id = 'cb' .. id
end
 
return '[http://catalogue.bnf.fr/ark:/12148/' .. id .. ' ' .. id .. '] [http://data.bnf.fr/ark:/12148/' .. id .. ' (data)]'
end
 
local function rslLinkulanLink( id )
return '[//www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=' .. id .. ' ' .. id .. ']'
-- TODO Implement some sanity checking regex
return '[http://aleph.rsl.ru/F?func=find-b&find_code=SYS&adjacent=Y&local_base=RSL11&request=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end
 
local function leonoreLinknlaLink( id )
return '[//nla.gov.au/anbd.aut-an' .. id .. ' ' .. id .. ']'
-- Identifiants allant de LH/1/1 à LH/2794/54 (légionnaires)
-- Identifiants allant de C/0/1 à C/0/84 (84 légionnaires célèbres)
-- Identifiants allant de 19800035/1/1 à 19800035/385/51670 (légionnaires décédés entre 1954 et 1977, et quelques dossiers de légionnaires décédés avant 1954)
if not string.match( id, '^LH/%d%d?%d?%d?/%d%d?%d?$' ) and
not string.match( id, '^C/0/%d%d?$' ) and
not string.match( id, '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) then
return false
end
return '[//www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=' .. id .. ' ' .. id .. ']'
end
 
local function sbnLinkbavLink( id )
if not string.match( id, '^IT\\ICCU\\%d%dADV%d%d%d%d%d%d%d%d$' ) andthen not string.match( id, '^IT\\ICCU\\%u%u[%d%u]%u\\%d%d%d%d%d%d$' ) then
return false
end
return id
return '[http://opac.sbn.it/opacsbn/opac/iccu/scheda_authority.jsp?bid=' .. id .. ' ' .. id .. ']'
end
 
local function nkcLinkcerlLink( id )
if not string.match( id, 'cn[cilp]%d%d%d%d%d%d%d%d$' ) then
return '[http://aleph.nkp.cz/F/?func=find-c&local_base=aut&ccl_term=ica=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
return false
end
return '[http://thesaurus.cerl.org/record/' .. id .. ' ' .. id .. ']'
end
 
--[[
local function nclLink( id )
local function selibrLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://aleweblibris.nclkb.edu.twse/Fauth/?func=accref&acc_sequence=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end
 
local function ndlLink( id )
return '[http://id.ndl.go.jp/auth/ndlna/' .. id .. ' ' .. id .. ']'
end
 
Riga 105 ⟶ 145:
end
 
local function hlsLinkbpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.hls-dhs-dssbiografischportaal.chnl/textesen/fpersoon/F' .. id .. '.php ' .. id .. ']'
end
 
local function lirLinkridLink( id )
return '[http://www.researcherid.com/rid/' .. id .. ' ' .. id .. ']'
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.e-lir.ch/e-LIR___Lexicon.' .. id .. '.450.0.html ' .. id .. ']'
end
 
local function splitLccnbibsysLink( id )
return '[http://ask.bibsys.no/ask/action/result?cmd=&kilde=biblio&cql=bs.autid+%3D+' .. id .. '&feltselect=bs.autid ' .. id .. ']'
if id:match( '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
id = id:gsub( '^(%l+)(%d+)(%d%d%d%d%d%d)$', '%1/%2/%3' )
end
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
 
local function appendhlsLink(str, c,id length)
if not string.match( id, '^%d+$' ) then
while str:len() < length do
return false
str = c .. str
end
return '[http://www.hls-dhs-dss.ch/textes/f/F' .. id .. '.php ' .. id .. ']'
return str
end
 
local function lccnLinklirLink( id )
if not string.match( id, '^%d+$' ) then
local parts = splitLccn( id )
if not parts then
return false
end
return '[http://www.e-lir.ch/e-LIR___Lexicon.' .. id .. '.450.0.html ' .. id .. ']'
local lccnType = parts[1] ~= 'sh' and 'names' or 'subjects'
id = parts[1] .. parts[2] .. append( parts[3], '0', 6 )
return '[http://id.loc.gov/authorities/' .. lccnType .. '/' .. id .. ' ' .. id .. ']'
end
 
Riga 151 ⟶ 179:
end
 
local function mgpLink( id )
--Returns the ISNI check digit isni must be a string where the 15 first elements are digits
-- TODO Implement some sanity checking regex
local function getIsniCheckDigit( isni )
return '[http://www.genealogy.ams.org/id.php?id=' .. id .. ' ' .. id .. ']'
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
 
local function ndlLink( id )
--Validate ISNI (and ORCID) and retuns it as a 16 characters string or returns false if it's invalid
return '[http://id.ndl.go.jp/auth/ndlna/' .. id .. ' ' .. id .. ']'
--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 isniLinknclLink( id )
idif =not validateIsnistring.match( id, '^%d+$' ) then
if not id then
return false
end
return '[http://isnialeweb.orgncl.edu.tw/isniF/?func=accref&acc_sequence=' .. id .. '&CON_LNG=ENG ' .. id:sub( 1, 4 ) .. ' ]' .. id:sub( 5, 8 ) .. ' ' .. id:sub( 9, 12 ) .. ' ' .. id:sub( 13, 16 ) .. ']'
end
 
local function orcidLinknkcLink( id )
return '[http://aleph.nkp.cz/F/?func=find-c&local_base=aut&ccl_term=ica=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
id = validateIsni( id )
end
if not id then
 
local function leonoreLink( id )
-- Identifiants allant de LH/1/1 à LH/2794/54 (légionnaires)
-- Identifiants allant de C/0/1 à C/0/84 (84 légionnaires célèbres)
-- Identifiants allant de 19800035/1/1 à 19800035/385/51670 (légionnaires décédés entre 1954 et 1977, et quelques dossiers de légionnaires décédés avant 1954)
if not string.match( id, '^LH/%d%d?%d?%d?/%d%d?%d?$' ) and
not string.match( id, '^C/0/%d%d?$' ) and
not string.match( id, '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) then
return false
end
return '[//www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=' .. id .. ' ' .. id .. ']'
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '[http://orcid.org/' .. id .. ' ' .. id .. ']'
end
 
local function gndLinkrslLink( id )
-- TODO Implement some sanity checking regex
return '[http://d-nb.info/gnd/' .. id .. ' ' .. id .. ']'
return '[http://aleph.rsl.ru/F?func=find-b&find_code=SYS&adjacent=Y&local_base=RSL11&request=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end
 
local function selibrLinkbotanistLink( id )
local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
if not string.match( id, '^%d+$' ) then
return '[http://www.ipni.org/ipni/advAuthorSearch.do?find_abbreviation=' .. id2 .. ' ' .. id .. ']'
return false
end
return '[//libris.kb.se/auth/' .. id .. ' ' .. id .. ']'
end
 
local function bnfLinknarapersonLink( id )
return '[http://research.archives.gov/person/' .. id .. ' ' .. id .. ']'
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
 
return '[http://catalogue.bnf.fr/ark:/12148/' .. id .. ' ' .. id .. '] [http://data.bnf.fr/ark:/12148/' .. id .. ' (data)]'
end
 
local function bpnLinknaraorganizationLink( id )
return '[http://research.archives.gov/organization/' .. id .. ' ' .. id .. ']'
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.biografischportaal.nl/en/persoon/' .. id .. ' ' .. id .. ']'
end
 
local function ridLinkuscongressLink( id )
return '[http://wwwbioguide.researcheridcongress.comgov/ridscripts/biodisplay.pl?index=' .. id .. ' ' .. id .. ']'
end
 
local function bibsysLinkbneLink( id )
return '[http://askcatalogo.bibsysbne.noes/askuhtbin/action/resultauthoritybrowse.cgi?cmdaction=display&kildeauthority_id=biblio&cql=bs.autid+%3D+' .. id .. '&feltselect=bs.autid ' .. id .. ']'
end
 
local function ulanLinkciniiLink( id )
return '[http://wwwci.gettynii.eduac.jp/vowauthor/ULANFullDisplay?find=&role=&nation=&subjectid=' .. id .. '?l=en ' .. id .. ']'
end
 
local function nlaLinktlsLink( id )
local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '[//nla.gov.au/anbd.aut-an' .. id .. ' ' .. id .. ']'
return '[http://tls.theaterwissenschaft.ch/wiki/' .. id2 .. ' ' .. id .. ']'
end
 
local function bavLinksikartLink( id )
return '[http://www.sikart.ch/KuenstlerInnen.aspx?id=' .. id .. '&lng=en ' .. id .. ']'
if not string.match( id, 'ADV%d%d%d%d%d%d%d%d$' ) then
return false
end
return id
end
 
local function cerlLinkkulturnavLink( id )
return '[http://kulturnav.org/language/en/' .. id .. ' id]'
if not string.match( id, 'cn[cilp]%d%d%d%d%d%d%d%d$' ) then
return false
end
return '[http://thesaurus.cerl.org/record/' .. id .. ' ' .. id .. ']'
end
]]--
 
-- In this order: name of the parameter, label, propertyId in Wikidata, formatting function, lingue
local conf = {
{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 214, viafLink, lingue = { 'en' } },
Riga 261 ⟶ 263:
{ 'ORCID', '[[Open Researcher and Contributor ID|ORCID]]', 496, orcidLink, lingue = { 'en' } },
{ 'GND', '[[Gemeinsame Normdatei|GND]]', 227, gndLink, lingue = { 'de' } },
--{ 'SELIBR', '[[LIBRIS|SELIBR]]', 906, selibrLink },
--{ 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, sudocLink },
{ 'BNF', '[[Bibliothèque nationale de France|BNF]]', 268, bnfLink, lingue = { 'fr' } },
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink, lingue = { 'en' } },
{ 'NLA', '[[National Library of Australia|NLA]]', 409, nlaLink, lingue = { 'en' } },
{ 'BAV', '[[Biblioteca apostolica vaticana|BAV]]', 1017, bavLink },
{ 'CERL', '[[Consortium of European Research Libraries|CERL]]', 1871, cerlLink },
--{ 'SELIBR', '[[LIBRIS|SELIBR]]', 906, selibrLink },
--{ 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, sudocLink },
--{ 'BPN', '[[Biografisch Portaal|BPN]]', 651, bpnLink },
--{ 'RID', '[[ResearcherID]]', 1053, ridLink },
--{ 'BIBSYS', '[[BIBSYS]]', 1015, bibsysLink },
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink, lingue = { 'en' } },
--{ 'HDS', '[[Historical Dictionary of Switzerland|HDS]]', 902, hlsLink },
--{ 'LIR', '[[Historical Dictionary of Switzerland#Lexicon_Istoric_Retic|LIR]]', 886, lirLink },
--{ 'MBA', '[[MusicBrainz]]', 434, mbLink },
--{ 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, mgpLink },
{ 'NLA', '[[National Library of Australia|NLA]]', 409, nlaLink, lingue = { 'en' } },
--{ 'NDL', '[[National Diet Library|NDL]]', 349, ndlLink },
--{ 'NCL', '[[National Central Library|NCL]]', 1048, nclLink },
Riga 287 ⟶ 291:
--{ 'SIKART', '[[SIKART]]', 781, sikartLink },
--{ 'KULTURNAV', '[[KulturNav]]', 1248, kulturnavLink },
{ 'BAV', '[[Biblioteca apostolica vaticana|BAV]]', 1017, bavLink },
{ 'CERL', '[[Consortium of European Research Libraries|CERL]]', 1871, cerlLink }
}
 
local p = {}
 
-- Funzione per il template {{Controllo di autorità}}.
function p.authorityControl( frame )
local elements, categories = {}, {}