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

Contenuto cancellato Contenuto aggiunto
m fix riga vuota
migliorata gestione categorie per identificativo, semplificata e separata
Riga 8:
local modlingue = require( 'Modulo:Linguaggi' )
require( 'Module:No globals' )
 
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
-- it.wiki aggiunge queste categorie solo nel namespace principale
if namespace == 0 then
return '[[Categoria:Voci con codice ' .. id .. ']]'
else
return ''
end
--elseif namespace == 2 and not title.isSubpage then
-- return '[[Category:User pages with ' .. id .. ' identifiers]]'
--else
-- return '[[Category:Miscellaneous pages with ' .. id .. ' identifiers]]'
--end
end
 
local function viafLink( id )
Riga 29 ⟶ 13:
return false
end
return '[http://viaf.org/viaf/' .. id .. ' ' .. id .. ']' .. getCatForId( 'VIAF' )
end
 
Riga 96 ⟶ 80:
return false
end
return '[http://opac.sbn.it/opacsbn/opac/iccu/scheda_authority.jsp?bid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SBN' )
end
 
Riga 159 ⟶ 143:
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 .. ']' .. getCatForId( 'LCCN' )
end
 
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '[//musicbrainz.org/artist/' .. id .. ' ' .. id .. ']' .. getCatForId( 'MusicBrainz' )
end
 
Riga 200 ⟶ 184:
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 ) .. ']' .. getCatForId( 'ISNI' )
end
 
Riga 209 ⟶ 193:
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '[http://orcid.org/' .. id .. ' ' .. id .. ']' .. getCatForId( 'ORCID' )
end
 
local function gndLink( id )
return '[http://d-nb.info/gnd/' .. id .. ' ' .. id .. ']' .. getCatForId( 'GND' )
end
 
Riga 220 ⟶ 204:
return false
end
return '[//libris.kb.se/auth/' .. id .. ' ' .. id .. ']' .. getCatForId( 'SELIBR' )
end
 
Riga 229 ⟶ 213:
end
 
return '[http://catalogue.bnf.fr/ark:/12148/' .. id .. ' ' .. id .. '] [http://data.bnf.fr/ark:/12148/' .. id .. ' (data)]' .. getCatForId( 'BNF' )
end
 
Riga 236 ⟶ 220:
return false
end
return '[http://www.biografischportaal.nl/en/persoon/' .. id .. ' ' .. id .. ']' .. getCatForId( 'BPN' )
end
 
local function ridLink( id )
return '[http://www.researcherid.com/rid/' .. id .. ' ' .. id .. ']' .. getCatForId( 'RID' )
end
 
local function bibsysLink( id )
return '[http://ask.bibsys.no/ask/action/result?cmd=&kilde=biblio&cql=bs.autid+%3D+' .. id .. '&feltselect=bs.autid ' .. id .. ']' .. getCatForId( 'BIBSYS' )
end
 
local function ulanLink( id )
return '[//www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'ULAN' )
end
 
local function nlaLink( id )
return '[//nla.gov.au/anbd.aut-an' .. id .. ' ' .. id .. ']' .. getCatForId( 'NLA' )
end
 
Riga 259 ⟶ 243:
return false
end
return id .. getCatForId( 'BAV' )
end
 
Riga 266 ⟶ 250:
return false
end
return '[http://thesaurus.cerl.org/record/' .. id .. ' ' .. id .. ']' .. getCatForId( 'CERL' )
end
 
local function createRow( id, label, rawValue, lingue, link, withUid )
if link then
if withUid then
return label .. ' <span class="uid">' .. lingue .. link .. '</span>'
else
return label .. ' ' .. lingue .. link
end
else
return '<span class="error">Il valore ' .. rawValue .. ' di ' .. id .. ' non è valido.</span>[[Categoria:Voci con codici controllo di autorità non validi (' .. id .. ')]]'
end
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 328 ⟶ 300:
local val = mWikidata._getProperty({ 'P' .. params[3], n = 1 })
if val then
local el, cat
local lingue = params['lingue'] and ( modlingue.lingue( params['lingue'] ) .. '&nbsp;' ) or ''
table.insert(local elements,link createRow( params[1], params[2] .. ':', val, lingue,= params[4]( val ), true ) )
if link then
local lingue = params['lingue'] and ( modlingue.lingue( params['lingue'] ) .. '&nbsp;' ) or ''
el = string.format( '%s <span class="uid">%s%s</span>', params[2], lingue, link )
return cat = string.format( '[[Categoria:Voci con codice %s]]', ..params[1] id .. ']]')
else
el = string.format( '<span class="error">Il valore %s di %s non è valido.</span>', val, params[1] )
cat = string.format( '[[Categoria:Voci con codici controllo di autorità non validi (%s)]]', params[1] )
end
table.insert( elements, el )
table.insert( categories, cat )
end
end