Open main menu

Changes

Module:Authority control

1,198 bytes added, 13:02, 26 June 2018
+LNB & NSK IDs, per talk; create p.deprecated, similar to p.aliases, but also assigns pages to Category:Wikipedia articles with deprecated authority control identifiers; nolink(Category:Wikipedia articles [...]) if outside mainspace; NARA-person now finally fully deprecated on WD - all IDs migrated to unified NARA ID; var ce; --ce; from sandbox
end
return '[http://bioguide.congress.gov/scripts/biodisplay.pl?index=' .. id .. ' ' .. id .. ']' .. p.getCatForId( 'USCongress' )
end
 
function p.narapersonLink( id )
--P1222's format regex: \d{7} (e.g. 1234567)
if not string.match( id, '^%d%d%d%d%d%d%d$' ) then
return false
end
return '[https://research.archives.gov/person/' .. id .. ' ' .. id .. ']' .. p.getCatForId( 'NARA-person' )
end
function p.leonoreLink( id )
--P640's format regex: LH/\d{1,4}/\d{1,3}|19800035/\d{1,4}/\d{1,5}(Bis)?|C/0/\d{1,2} (e.g. LH/2064/18)
if not id:match( '^LH/%d%d?%d?%d?/%d%d?%d?$' ) and --IDs from LH/1/1 to LH/2794/54 (legionaries)
not id:match( '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) and --IDs from 19800035/1/1 to 19800035/385/51670 (legionnaires who died 1954-1977 & some who died < 1954)
not id:match( '^C/0/%d%d?$' ) then --IDs from C/0/1 to C/0/84 (84 famous legionaries)
return false
end
end
return '[http://balat.kikirpa.be/object/104257' .. id .. ' ' .. id .. ']' .. p.getCatForId( 'BALaT' )
end
 
function p.lnbLink( id )
--P1368's format regex: \d{9} (e.g. 123456789)
if not string.match( id, '^%d%d%d%d%d%d%d%d%d$' ) then
return false
end
return 'https://kopkatalogs.lv/F?func=direct&local_base=lnc10&doc_number=' .. id .. '&P_CON_LNG=ENG ' .. id .. ']' .. p.getCatForId( 'LNB' )
end
 
function p.nskLink( id )
--P1375's format regex: \d{9} (e.g. 123456789)
if not string.match( id, '^%d%d%d%d%d%d%d%d%d$' ) then
return false
end
return 'http://katalog.nsk.hr/F/?func=direct&doc_number=' .. id .. '&local_base=nsk10 ' .. id .. ']' .. p.getCatForId( 'NSK' )
end
{ 'LCCN', '[[Library of Congress Control Number|LCCN]]', 244, p.lccnLink },
{ 'LIR', '[[Historical Dictionary of Switzerland#Lexicon_Istoric_Retic|LIR]]', 886, p.lirLink },
{ 'LNB', '[[National Library of Latvia|LNB]]', 1368, p.lnbLink },
{ 'Léonore', '[[Base Léonore|Léonore]]', 640, p.leonoreLink },
{ 'MBA', '[[MusicBrainz]]', 434, p.mbaLink },
{ 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, p.mgpLink },
{ 'NARA', '[[National Archives and Records Administration|NARA]]', 1225, p.naraLink },
{ 'NARA-person', '[[National Archives and Records Administration|NARA]]', 1222, p.narapersonLink },
{ 'NCL', '[[National Central Library|NCL]]', 1048, p.nclLink },
{ 'NDL', '[[National Diet Library|NDL]]', 349, p.ndlLink },
{ 'NKC', '[[National Library of the Czech Republic|NKC]]', 691, p.nkcLink },
{ 'NLA', '[[National Library of Australia|NLA]]', 409, p.nlaLink },
{ 'NSK', '[[National and University Library in Zagreb|NSK]]', 1375, p.nskLink },
{ 'ORCID', '[[ORCID]]', 496, p.orcidLink },
{ 'PIC', '[[:d:Q23892012|PIC]]', 2750, p.picLink },
}
-- Alias formatLegitimate aliases to p.conf, for convenience-- Format: { alias, parameter name in p.conf }
p.aliases = {
{ 'PND', 'GND' },
{ 'RLS', 'RSL' },
{ 'MusicBrainz', 'MBA' },
{ 'Leonore', 'Léonore' },
}
 
-- Deprecated aliases to p.conf, which also get assigned to a tracking cat
-- Format: { deprecated parameter name, replacement parameter name in p.conf }
p.deprecated = {
{ 'GKD', 'GND' },
{ 'PND', 'GND' },
{ 'SWD', 'GND' },
{ 'NARA-organization', 'NARA' },
{ 'NARA-person', 'NARA' },
}
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 rows later local suppressedCats suppressedIdCat = '' local deprecatedIdCat = ''
--Redirect aliases to proper parameter names
for _, a in pairs( p.aliases ) do
local alias, param = a[1], a[2]
if (parentArgs[param] == nil or parentArgs[param] == '') and parentArgs[alias] then
parentArgs[param] = parentArgs[alias]
end
end
 
--Redirect deprecated parameters to proper parameter names, and assign tracking cat
for _, d in pairs( p.deprecated ) do
local dep, param = d[1], d[2]
if (parentArgs[param] == nil or parentArgs[param] == '') and parentArgs[dep] then
parentArgs[param] = parentArgs[dep]
deprecatedIdCat = '[[Category:Wikipedia articles with deprecated authority control identifiers|'..dep..']]'
end
end
if wikidataIds[1] then
if val == '' and (namespace == 0 or testcases) then
suppressedCats suppressedIdCat = '[[Category:Wikipedia articles with suppressed authority control identifiers|' .. params[1] .. ']]'
else
parentArgs[params[1]] = wikidataIds[1]
end
local Navbox = require('Module:Navbox')
local elementsCats elementsCat = ''
if rct > 13 then
local catName = 'AC with ' .. rct .. ' elements'
elementsCats elementsCat = '[[Category:' .. catName .. ']]' .. p.redCatLink(catName)
end
local outString = ''
if #elements ~= > 0 then
outString = Navbox._navbox( {
name = 'Authority control',
list1 = table.concat( elements )
} )
elementsCats local auxCats = elementsCats elementsCat .. suppressedCatssuppressedIdCat .. deprecatedIdCat
if testcases then
outString auxCats = mw.ustring.gsub(outStringauxCats, '(%[%[)(Category:Wikipedia articles with faulty)', '%1:%2')--for easier checking end if namespace ~= 0 then elementsCats outString = mw.ustring.gsub(elementsCatsoutString, '(%[%[)(Category:Wikipedia articles)', '%1:%2')--by definition
end
outString = outString .. elementsCatsauxCats
end
Anonymous user