Open main menu

Changes

Module:Authority control

270 bytes added, 03:43, 1 July 2014
don't use globals
require('Module:No globals') local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
local function kulturnavLink( id )
return '[http://kulturnav.org/language/en/' .. id .. ' id]'
end
local function sikartLink( id )
return '[http://www.sikart.ch/KuenstlerInnen.aspx?id=' .. id .. '&lng=en ' .. id .. ']'
end
local function tlsLink( id )
id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '[http://tls.theaterwissenschaft.ch/wiki/' .. id2 .. ' ' .. id .. ']'
local function ciniiLink( id )
return '[http://ci.nii.ac.jp/author/' .. id .. '?l=en ' .. id .. ']'
end
local function bneLink( id )
return '[http://catalogo.bne.es/uhtbin/authoritybrowse.cgi?action=display&authority_id=' .. id .. ' ' .. id .. ']'
end
local function uscongressLink( id )
return '[http://bioguide.congress.gov/scripts/biodisplay.pl?index=' .. id .. ' ' .. id .. ']'
end
local function narapersonLink( id )
return '[http://research.archives.gov/person/' .. id .. ' ' .. id .. ']'
end
local function naraorganizationLink( id )
return '[http://research.archives.gov/organization/' .. id .. ' ' .. id .. ']'
end
local function botanistLink( id )
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 mgpLink( id )
-- TODO Implement some sanity checking regex
return '[http://www.genealogy.ams.org/id.php?id=' .. id .. ' ' .. id .. ']'
end
local function rslLink( 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 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)
end
local function sbnLink( 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 false
end
local function nkcLink( id )
return '[http://aleph.nkp.cz/F/?func=find-c&local_base=aut&ccl_term=ica=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
local function ndlLink( id )
return '[http://id.ndl.go.jp/auth/ndlna/' .. id .. ' ' .. id .. ']'
end
local function sudocLink( id )
if not string.match( id, '^%d%d%d%d%d%d%d%d[%dxX]$' ) then
return false
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
function lccnLink( id ) local parts = splitLccn( id ) if not parts then return false end id = parts[1] .. parts[2] .. append( parts[3], '0', 6 ) return '[http://id.loc.gov/authorities/names/' .. id .. ' ' .. id .. ']' .. getCatForId( 'LCCN' )end function mbLink( id ) -- TODO Implement some sanity checking regex return '[//musicbrainz.org/artist/' .. id .. ' ' .. id .. ']' .. getCatForId( 'MusicBrainz' )end function splitLccn( 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
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
local function isniLinklccnLink( id ) id local parts = validateIsnisplitLccn( id ) if not id parts then
return false
end
return 'id = parts[http://isni-url1] .oclc.nl/isni/' .. id parts[2] .. append( parts[3], ' 0' .. id:sub( 1, 4 6 ) .. return ' ' .. [http://id:sub( 5, 8 ) .loc. gov/authorities/names/' ' .. id:sub( 9, 12 ) .. ' ' .. id:sub( 13, 16 ) .. ']' .. getCatForId( 'ISNILCCN' )
end
--Validate ISNI local function mbLink(and ORCIDid ) and retuns it as a 16 characters string or returns false if it's invalid --See http:TODO Implement some sanity checking regex return '[//support.orcidmusicbrainz.org/knowledgebaseartist/articles/116780-structure-of-the-orcid-identifierfunction 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. getCatForId( id:byte( 16 ) 'MusicBrainz' ) then return false end return id
end
--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
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-identifierlocal 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 idend local function isniLink( id ) id = validateIsni( id ) if not id then return false end return '[http://isni-url.oclc.nl/isni/' .. id .. ' ' .. id:sub( 1, 4 ) .. ' ' .. id:sub( 5, 8 ) .. ' ' .. id:sub( 9, 12 ) .. ' ' .. id:sub( 13, 16 ) .. ']' .. getCatForId( 'ISNI' )end local function orcidLink( id )
id = validateIsni( id )
if not id then
end
local function gndLink( id )
return '[http://d-nb.info/gnd/' .. id .. ' ' .. id .. ']' .. getCatForId( 'GND' )
end
local function selibrLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
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
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
Anonymous user