As with arches, the "springing" of a dome is the point from which the dome rises. The top of a dome is the "crown". The inner side of a dome is called the "intrados" and the outer side is called the "extrados". The "haunch" is the part of an arch that lies roughly halfway between the base and the top.
The word "cupola" is another word for "dome", and is usually used for a small dome upon a roof or turret. "Cupola" has also been used to describe the inner side of a dome. Drums, also called tholobates, are cylindrical or polygonal walls with or without windows that support a dome. A tambour or lantern is the equivalent structure over a dome's oculus, supporting a cupola.
The outward thrusts in the lower portion of a hemispherical masonry dome can be counteracted with the use of chains incorporated around the circumference or with external buttressing, although cracking along the meridians is natural. For small or tall domes with less horizontal thrust, the thickness of the supporting arches or walls can be enough to resist deformation, which is why drums tend to be much thicker than the domes they support.
When the base of the dome does not match the plan of the supporting walls beneath it (for example, a dome's circular base over a square bay), techniques are employed to transition between the two. The simplest technique is to use diagonal lintels across the corners of the walls to create an octagonal base. Another is to use arches to span the corners, which can support more weight. A variety of these techniques use what are called "squinches". A squinch can be a single arch or a set of multiple projecting nested arches placed diagonally over an internal corner. Squinches can take a variety of other forms, as well, including trumpet arches and niche heads, or half-domes.
Because domes are concave from below, they can reflect sound and create echoes. A dome may have a "
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
-
-
-
-
-
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return ''
elseif namespace == 2 and not title.isSubpage then
return ''
else
return ''
end
end
local function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'VIAF' )
end
local function kulturnavLink( id )
return '.. id .. ' id'
end
local function sikartLink( id )
return '.. id .. '&lng=en ' .. id .. ''
end
local function tlsLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
return '.. id2 .. ' ' .. id .. ''
end
local function ciniiLink( id )
return '.. id .. '?l=en ' .. id .. ''
end
local function bneLink( id )
return '.. id .. ' ' .. id .. ''
end
local function uscongressLink( id )
return '.. id .. ' ' .. id .. ''
end
local function narapersonLink( id )
return '.. id .. ' ' .. id .. ''
end
local function naraorganizationLink( id )
return '.. id .. ' ' .. id .. ''
end
local function botanistLink( id ) local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
return '.. id2 .. ' ' .. id .. ''
end
local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. ''
end
local function rslLink( id )
-- TODO Implement some sanity checking regex
return '.. 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) -- 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 '.. id .. ' ' .. id .. ''
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
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SBN' )
end
local function nkcLink( id ) return '.. id .. '&CON_LNG=ENG ' .. id .. '' end
local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '&CON_LNG=ENG ' .. id .. ''
end
local function ndlLink( id ) return '.. 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
return '.. id .. ' ' .. id .. ''
end
local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.php ' .. id .. ''
end
local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. '.450.0.html ' .. id .. ''
end
local 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
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
local function lccnLink( id )
local parts = splitLccn( 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 '.. lccnType .. '/' .. id .. ' ' .. id .. '' .. getCatForId( 'LCCN' )
end
local function mbLink( id )
-- TODO Implement some sanity checking regex
return '.. id .. ' ' .. id .. '' .. getCatForId( 'MusicBrainz' )
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
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 '.. 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
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ORCID' )
end
local function gndLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'GND' )
end
local function selibrLink( id ) if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'SELIBR' )
end
local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end
return '.. id .. ' ' .. id .. ' .. id .. ' (data)' .. getCatForId( 'BNF' )
end
local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '.. id .. ' ' .. id .. '' .. getCatForId( 'BPN' )
end
local function ridLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'RID' )
end
local function bibsysLink( id )
return '.. id .. '&feltselect=bs.autid ' .. id .. '' .. getCatForId( 'BIBSYS' )
end
local function ulanLink( id )
return '.. id .. ' ' .. id .. '' .. getCatForId( 'ULAN' )
end
local function nlaLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'NLA' ) end
local function rkdartistsLink( id ) return '.. id .. ' ' .. id .. '' .. getCatForId( 'RKDartists' ) end
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '* ' .. label .. ' ' .. link .. '\n'
else
return '* ' .. label .. ' ' .. link .. '\n'
end
else
return '* \n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function local conf = {
{ 'VIAF', 'VIAF', 214, viafLink },
{ 'LCCN', 'LCCN', 244, lccnLink },
{ 'ISNI', 'ISNI', 213, isniLink },
{ 'ORCID', 'ORCID', 496, orcidLink },
{ 'GND', 'GND', 227, gndLink },
{ 'SELIBR', 'SELIBR', 906, selibrLink },
{ 'SUDOC', 'SUDOC', 269, sudocLink },
{ 'BNF', 'BNF', 268, bnfLink },
{ 'BPN', 'BPN', 651, bpnLink },
{ 'RID', 'ResearcherID', 1053, ridLink },
{ 'BIBSYS', 'BIBSYS', 1015, bibsysLink },
{ 'ULAN', 'ULAN', 245, ulanLink },
{ 'HDS', 'HDS', 902, hlsLink },
{ 'LIR', 'LIR', 886, lirLink },
{ 'MBA', 'MusicBrainz', 434, mbLink },
{ 'MGP', 'MGP', 549, mgpLink },
{ 'NLA', 'NLA', 409, nlaLink },
{ 'NDL', 'NDL', 349, ndlLink },
{ 'NCL', 'NCL', 1048, nclLink },
{ 'NKC', 'NKC', 691, nkcLink },
{ 'Léonore', 'Léonore', 640, leonoreLink },
{ 'SBN', 'ICCU', 396, sbnLink },
{ 'RLS', 'RLS', 947, rslLink },
{ 'Botanist', '[[Author ci
Domes built with steel and concrete were able to achieve very large spans. In the late 19th and early 20th centuries, the Guastavino family, a father and son team who worked on the eastern seaboard of the United States, further developed the masonry dome, using tiles set flat against the surface of the curve and fast-setting Portland cement, which allowed mild steel bar to be used to counteract tension forces.[205] The thin domical shell was further developed with the construction by Walther Bauersfeld of two planetarium domes in Jena, Germany in the early 1920s. They consisting of a triangulated frame of light steel bars and mesh covered by a thin layer of concrete.[206] These are generally taken to be the first modern architectural thin shells. These are also considered the first geodesic domes. Geodesic domes have been used for radar enclosures, greenhouses, housing, and weather stations. Architectural shells had their heyday in the 1950s and 1960s, peaking in popularity shortly before the widespread adoption of computers and the finite element method of structural analysis.
In the eighteenth century, the study of dome structures changed radically, with domes being considered as a composition of smaller elements, each subject to mathematical and mechanical laws and easier to analyse individually, rather than being considered as whole units unto themselves. Although never very popular in domestic settings, domes were used in a number of 18th century homes built in the Neo-Classical style. In the United States, most public buildings in the late 18th century were only distinguishable from private residences because they featured cupolas.
Over the course of the seventeenth and eighteenth centuries, developments in mathematics and the study of statics led to a more precise formalization of the ideas of the traditional constructive practices of arches and vaults, and there was a diffusion of studies on the most stable form for these structures: the catenary curve. Robert Hooke, who first articulated that a thin arch was comparable to an inverted hanging chain, may have advised Wren on how to achieve the crossing dome of St. Paul's Cathedral. Wren's structural system became the standard for large domes well into the 19th century. The ribs in Guarino Guarini's San Lorenzo and Il Sidone were shaped as catenary curves. The idea of a large oculus in a solid dome revealing a second dome originated with him. He also established the oval dome as a reconciliation of the longitudinal plan church favored by the liturgy of the Counter-Reformation and the centralized plan favored by idealists. Because of the imprecision of oval domes in the Rococo period, drums were problematic and the domes instead often rested directly on arches or pendentives.
The construction of domes in the sixteenth and seventeenth centuries relied primarily on empirical techniques and oral traditions rather than the architectural treatises of the times, which avoided practical details. This was adequate for domes up to medium size, with diameters in the range of 12 to 20 meters. Materials were considered homogeneous and rigid, with compression taken into account and elasticity ignored. The weight of materials and the size of the dome were the key references. Lateral tensions in a dome were counteracted with horizontal rings of iron, stone, or wood incorporated into the structure.
In the early sixteenth century, the lantern of the Italian dome spread to Germany, gradually adopting the bulbous cupola from the Netherlands. Russian architecture strongly influenced the many bulbous domes of the wooden churches of Bohemia and Silesia and, in Bavaria, bulbous domes less resemble Dutch models than Russian ones. Domes like these gained in popularity in central and southern Germany and in Austria in the seventeenth and eighteenth centuries, particularly in the Baroque style, and influenced many bulbous cupolas in Poland and Eastern Europe in the Baroque period. However, many bulbous domes in eastern Europe were replaced over time in the larger cities during the second half of the eighteenth century in favor of hemispherical or stilted cupolas in the French or Italian styles.
The Il Redentore (1577–92), the latter built in thanksgiving for the end of a bad outbreak of plague in the city. The spread of the Renaissance style dome outside of Italy began with central Europe, although there was often a stylistic delay of a century or two.
The first large Imperial Mosque of Istanbul in the imported Baroque style was the Nuruosmaniye Mosque (1748-1755). One of the finest was the Laleli Mosque of 1759-1764.
The eyvan mosque type (the eyvan being derived from Seljuk architecture) uses domed-square units in a variety of sizes, heights, and details, with only the possible pair of side units being similar sizes.
The multi-unit mosque uses several domed-squares of similar size along the length of a mosque, or across its width, or both, with the central dome sometimes larger than the others. A style common in the Bursa period, and known as the "Bursa type", is like a duplication of the single-domed square, with one long space divided by an arch into two square bays that are each covered by a dome. A variation of this type has the room covered by one dome and one semi-dome, with additional side chambers. A multi-domed style derived from Seljuk architecture is that of the Ulu Camii, or Great Mosque, which consists of a number of domes of the same size supported by pillars.
The earliest stone churches in Russia featured Byzantine style domes, however by the Early Modern era the onion dome had become the predominant form in traditional Russian architecture. The onion dome is a dome whose shape resembles an onion, after which they are named. Such domes are often larger in diameter than the drums they sit on, and their height usually exceeds their width. The whole bulbous structure tapers smoothly to a point. Though the earliest preserved Russian domes of such type date from the 16th century, illustrations from older chronicles indicate they have existed since the late 13th century. Like tented roofs—which were combined with, and sometimes replaced domes in Russian architecture since the 16th century—onion domes initially were used only in wooden churches. Builders introduced them into stone architecture much later, and continued to make their carcasses of either of wood or metal on top of masonry drums.
The multidomed church is a typical form of Russian church architecture that distinguishes Russia from other Orthodox nations and Christian denominations. Indeed, the earliest Russian churches, built just after the Christianization of Kievan Rus', were multi-domed, which has led some historians to speculate about how Russian pre-Christian pagan temples might have looked. Examples of these early churches are the 13-domed wooden Saint Sophia Cathedral in Novgorod (989) and the 25-domed stone Desyatinnaya Church in Kiev (989–996). The number of domes typically has a symbolical meaning in Russian architecture, for example 13 domes symbolize Christ with 12 Apostles, while 25 domes means the same with an additional 12 Prophets of the Old Testament. The multiple domes of Russian churches were often comparatively smaller than Byzantine domes.
Italian church architecture from the late sixth century to the end of the eighth century was influenced less by the trends of Constantinople than by a variety of Byzantine provincial plans. With the crowning of Charlemagne as a new Roman Emperor, Byzantine influences were largely replaced in a revival of earlier Western building traditions. Occasional exceptions include examples of early quincunx churches at Milan and near Cassino. Another is the Palatine Chapel. Its domed octagon design was influenced by Byzantine models. It was the largest dome north of the Alps at that time. Venice, Southern Italy and Sicily served as outposts of Middle Byzantine architectural influence in Italy.
The area of north-eastern Iran was, along with Egypt, one of two areas notable for early developments in Islamic domed mausoleums, which appear in the tenth century. The Samanid Mausoleum in Transoxiana dates to no later than 943 and is the first to have squinches create a regular octagon as a base for the dome, which then became the standard practice. Cylindrical or polygonal plan tower tombs with conical roofs over domes also exist beginning in the 11th century.
In the Byzantine period, domes were normally hemispherical and had, with occasional exceptions, windowed drums. All of the surviving examples in Constantinople are ribbed or pumpkin domes, with the divisions corresponding to the number of windows. Roofing for domes ranged from simple ceramic tile to more expensive, more durable, and more form-fitting lead sheeting. Metal clamps between stone cornice blocks, metal tie rods, and metal chains were also used to stabilize domed construction. The technique of using double shells for domes, although revived in the Renaissance, originated in Byzantine practice.
"Cross-domed units", a more secure structural system created by bracing a dome on all four sides with broad arches, became a standard element on a smaller scale in later Byzantine church architecture. The Cross-in-square plan, with a single dome at the crossing or five domes in a quincunx pattern, became widely popular in the Middle Byzantine period (c. 843-1204). It is the most common church plan from the tenth century until the fall of Constantinople in 1453. Resting domes on circular or polygonal drums pierced with windows eventually became the standard style, with regional characteristics.
In the 3rd century, Imperial mausoleums began to be built as domed rotundas, rather than as tumulus structures or other types, following similar monuments by private citizens. The technique of building lightweight domes with interlocking hollow ceramic tubes further developed in North Africa and Italy in the late third and early fourth centuries. In the 4th century, Roman domes proliferated due to changes in the way domes were constructed, including advances in centering techniques and the use of brick ribbing. The material of choice in construction gradually transitioned during the 4th and 5th centuries from stone or concrete to lighter brick in thin shells. Baptisteries began to be built in the manner of domed mausoleums during the 4th century in Italy. The octagonal Lateran baptistery or the baptistery of the Holy Sepulchre may have been the first, and the style spread during the 5th century. By the 5th century, structures with small-scale domed cross plans existed across the Christian world.
The historical development from structures like these to more sophisticated domes is not well documented. That the dome was known to early Mesopotamia may explain the existence of domes in both China and the West in the first millennium BC. Another explanation, however, is that the use of the dome shape in construction did not have a single point of origin and was common in virtually all cultures long before domes were constructed with enduring materials.
Masonry saucer domes, because they exist entirely in compression, can be built much thinner than other dome shapes without becoming unstable. The trade-off between the proportionately increased horizontal thrust at their abutments and their decreased weight and quantity of materials may make them more economical, but they are more vulnerable to damage from movement in their supports.
One of the earliest types of ribbed vault, the first known examples are found in the Great Mosque of Córdoba in the 10th century. Rather than meeting in the center of the dome, the ribs characteristically intersect one another off-center, forming an empty polygonal space in the center. Geometry is a key element of the designs, with the octagon being perhaps the most popular shape used. Whether the arches are structural or purely decorative remains a matter of debate. The type may have an eastern origin, although the issue is also unsettled. Examples are found in Spain, North Africa, Armenia, Iran, France, and Italy.
The dual sepulchral and heavenly symbolism was adopted by early Christians in both the use of domes in architecture and in the ciborium, a domical canopy like the baldachin used as a ritual covering for relics or the church altar. The celestial symbolism of the dome, however, was the preeminent one by the Christian era. In the early centuries of Islam, domes were closely associated with royalty. A dome built in front of the mihrab of a mosque, for example, was at least initially meant to emphasize the place of a prince during royal ceremonies. Over time such domes became primarily focal points for decoration or the direction of prayer. The use of domes in mausoleums can likewise reflect royal patronage or be seen as representing the honor and prestige that domes symbolized, rather than having any specific funerary meaning. The wide variety of dome forms in medieval Islam reflected dynastic, religious, and social differences as much as practical building considerations.
Domes and tent-canopies were also associated with the heavens in Ancient Persia and the Hellenistic-Roman world. A dome over a square base reflected the geometric symbolism of those shapes. The circle represented perfection, eternity, and the heavens. The square represented the earth. An octagon was intermediate between the two. The distinct symbolism of the heavenly or cosmic tent stemming from the royal audience tents of Achaemenid and Indian rulers was adopted by Roman rulers in imitation of Alexander the Great, becoming the imperial baldachin. This probably began with Nero, whose "Golden House" also made the dome an essential feature of palace architecture.
The new building materials of the 19th century and a better understanding of the forces within structures from the 20th century has opened up new possibilities. Iron and steel beams, steel cables, and pre-stressed concrete have eliminated the need for external buttressing and enabled far thinner domes. Whereas earlier masonry domes may have had a radius to thickness ratio of 50, the ratio for modern domes can be in excess of 800. The lighter weight of these domes has not only permitted far greater spans, but also allowed for the creation of large movable domes over modern sports stadiums.
The earliest domes in the Middle East were built with mud-brick and, eventually, with baked brick and stone. Domes of wood allowed for wide spans due to the relatively light and flexible nature of the material and were the normal method for domed churches by the 7th century, although most domes were built with the other less flexible materials. Wooden domes were protected from the weather by roofing, such as copper or lead sheeting. Domes of cut stone were more expensive and never as large, and timber was used for large spans where brick was unavailable.[31] Brick domes were the favored choice for large-space monumental coverings until the Industrial Age, due to their convenience and dependability.
Cavities in the form of jars built into the inner surface of a dome may serve to compensate for this interference by diffusing sound in all directions, eliminating echoes while creating a "divine effect in the atmosphere of worship." This technique was written about by Vitruvius in his Ten Books on Architecture, which describes bronze and earthenware resonators. The material, shape, contents, and placement of these cavity resonators determine the effect they have: reinforcing certain frequencies or absorbing them.