Changes
+p.aliases to more easily redirect 4 params (3 new); +function p.redCatLink for easier redcat checks; +more redcat checks; +QID parameter for testcases; testcases display tweaks; fix RLS -> RSL, will follow up with cats; allow suppression via null params, with tracking cat; from sandbox
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
local cat = '' local redcat catName = ''
if namespace == 0 then
elseif namespace == 2 and not title.isSubpage then
else
end
return '[[Category:' .. catName .. ']]' .. p.redCatLink(catName)end function p.redCatLink( catName ) --catName == 'Blah', not 'Category:Blah', not '[[Category:Blah]]' if catName and mw.title.new(catcatName, 14).exists == false then redcat = return '[[Category:Pages with red-linked authority control categories]]'
end
end
function p.rslLink( id )
-- TODO Implement some sanity checking regex
return '[http://aleph.rsl.ru/F?func=find-b&find_code=SYS&adjacent=Y&local_base=RSL11&request=' .. id .. '&CON_LNG=ENG ' .. id .. ']' .. p.getCatForId( 'RLSRSL' ) --RLS == known typo
end
end
function p.sbnLink( id )--i.e. IT\ICCU\CFIV\000163
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
function p.sudocLink( id )
if not string.match( id, '^%d%d%d%d%d%d%d%d[%dxX]$' ) then--i.e. 026927608
return false
end
function p.lccnLink( id )
local parts = p.splitLccn( id )--i.e. n78039510
if not parts then
return false
end
--Returns the ISNI check digit isni must be a string where the 15 first elements are digits, i.e. 0000000066534145
function p.getIsniCheckDigit( isni )
local total = 0
function p.orcidLink( id )
id = p.validateIsni( id )--i.e. 0000-0002-7398-5483
if not id then
return false
local qid = group[2]
local statements = mw.wikibase.getBestStatements( itemId, property )
if statements ~= nil then
for _, statement in ipairs( statements ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
return '*<span class="nowrap">' .. label .. ' ' .. link .. '</span>\n'
end
local catName = 'Wikipedia articles with faulty authority control identifiers (' .. id .. ')' return '* <span class="error">The ' .. id .. ' id ' .. rawValue .. ' is not valid.</span>[[Category:Wikipedia articles with faulty authority control identifiers (' .. id catName .. ')]]' .. p.redCatLink(catName) .. '\n'
end
local reqs = {}
--In this orderParameter format: { name of the parameter, label, propertyId in Wikidata, formatting function}
p.conf = {
{ 'ACM-DL', '[[ACM Digital Library|ACM DL]]', 864, p.acmLink },
{ 'RKDartists', '[[Netherlands Institute for Art History#Online artist pages|RKD]]', 650, p.rkdartistsLink },
{ 'RKDID', '[[:d:Q17299580|RKDimages ID]]', 350, p.rkdidLink },
{ 'RLSRSL', '[[Russian State Library|RLSRSL]]', 947, p.rslLink },
{ 'SBN', '[[Istituto Centrale per il Catalogo Unico|ICCU]]', 396, p.sbnLink },
{ 'SELIBR', '[[LIBRIS|SELIBR]]', 906, p.selibrLink },
{ 'USCongress', '[[Biographical Directory of the United States Congress|US Congress]]', 1157, p.uscongressLink },
{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 214, p.viafLink },
}
-- Alias format: { alias, parameter name in p.conf }
p.aliases = {
{ 'PND', 'GND' },
{ 'RLS', 'RSL' },
{ 'MusicBrainz', 'MBA' },
{ 'Leonore', 'Léonore' },
}
function p.authorityControl( frame )
local resolve = require( "Module:ResolveEntityId" )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
local talkspace = mw.site.talkNamespaces[namespace] ~= nil
local testcases = (string.sub(title.subpageText,1,9) == 'testcases')
local parentArgs = frame:getParent().args
local elements = {} --Create insert/create rowslater local elements suppressedCats = {}'' --redirect PND Redirect aliases to GNDparameter names for _, a in pairs( p.aliases ) do local alias, param = a[1], a[2] if (parentArgs.GND [param] == nil or parentArgs.GND [param] == '') and parentArgs.PND ~= nil [alias] and parentArgs.PND [alias] ~= '' then parentArgs[param] = parentArgs[alias] end end --Use QID= parameter for testing/example purposes only local itemId = nil if testcases or talkspace then if parentArgs['QID'] then itemId = 'Q' .. mw.GND ustring.gsub(parentArgs['QID'], '^[Qq]', '') itemId = resolve._entityid(frame, itemId) --nil if unresolvable end else itemId = parentArgsmw.wikibase.PNDgetEntityIdForCurrentPage()
end
--Wikidata fallback if requested
for _, params in ipairs( p.conf ) do
if params[3] ~= > 0 then
local val = parentArgs[params[1]]
if not val == nil or val == '' then
local canUseWikidata = nil
if reqs[params[1]] ~= nil then
canUseWikidata = p.matchesWikidataRequirements( itemId, reqs[params[1]] )
else
local wikidataIds = p.getIdsFromWikidata( itemId, 'P' .. params[3] )
if wikidataIds[1] then
if val == '' and (namespace == 0 or testcases) then suppressedCats = '[[Category:Wikipedia articles with suppressed authority control identifiers|' .. params[1] .. ']]' else parentArgs[params[1]] = wikidataIds[1] end end end end end end end end
--Worldcat
if parentArgs['WORLDCATID'] and parentArgs['WORLDCATID'] ~= '' then
end
end
--Configured rows
local rct = 0
end
local Navbox = require('Module:Navbox')
local elementscats elementsCats = ''
if rct > 13 then
end
local outString = ''
if #elements ~= 0 then
name = 'Authority control',
bodyclass = 'hlist',
group1 = '[[Help:Authority control|Authority control]]' .. elementscats,
list1 = table.concat( elements )
} )
elementsCats = elementsCats .. suppressedCats
if testcases then
elementsCats = mw.ustring.gsub(elementsCats, '%[%[Category', '[[:Category')
end
outString = outString .. elementsCats
end
return ""outString
end
return p