Diferencia entre revisiones de «Módulo:Authority control»

Ir a la navegación Ir a la búsqueda
m (1 revision imported)
Netflix>Tom.Reding
Línea 36: Línea 36:
if links then -- all links[] use withUid = false; no check needed
if links then -- all links[] use withUid = false; no check needed
local row = '*<span class="nowrap">'..label
local row = '*<span class="nowrap">'..label
local totlen = 0
for i, l in ipairs( links ) do
for i, l in ipairs( links ) do
if i == 1 then row = row..' '
if i == 1 then row = row..' '
Línea 44: Línea 45:
row = row..'<span class="error">The '..id..' id '..rawValues[i]..' is not valid.</span>[[Category:'..catName..']]'..p.redCatLink(catName)
row = row..'<span class="error">The '..id..' id '..rawValues[i]..' is not valid.</span>[[Category:'..catName..']]'..p.redCatLink(catName)
end
end
totlen = totlen + #rawValues[i] + 3 -- 3 chars b/w links
end
if totlen > 79 then
row = string.gsub(row, '"nowrap"', '""') -- avoid [[A–Z Series]]
end
end
return row..'</span>\n'
return row..'</span>\n'
Línea 230: Línea 235:
end
end
return '[https://dblp.org/pid/'..id..' '..id..']'..p.getCatForId( 'DBLP' )
return '[https://dblp.org/pid/'..id..' '..id..']'..p.getCatForId( 'DBLP' )
end
function p.dibLink( id )
--P6829's format regex: a\d{4}\d?(-[A-D])? (e.g. a1953)
if not id:match( '^a%d%d%d%d%d?%-?[A-D]?$' ) then
return false
end
return '[https://dib.cambridge.org/viewReadPage.do?articleId='..id..' '..id..']'..p.getCatForId( 'DIB' )
end
end


Línea 350: Línea 363:
end
end
return '[http://www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1='..id..' '..id..']'..p.getCatForId( 'Léonore' ) --no https as of 9/2019
return '[http://www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1='..id..' '..id..']'..p.getCatForId( 'Léonore' ) --no https as of 9/2019
end
function p.maLink( id )
--P6366's format regex: [1-9]\d{4,9} (e.g. 1498221862)
if not id:match( '^[1-9]%d%d%d%d%d?%d?%d?%d?%d?$' ) then
return false
end
return '[https://academic.microsoft.com/v2/detail/'..id..' '..id..']'..p.getCatForId( 'MA' )
end
end


Línea 934: Línea 955:
{ 'DAAO', '[[DAAO (identifier)|DAAO]]', 1707, p.daaoLink },
{ 'DAAO', '[[DAAO (identifier)|DAAO]]', 1707, p.daaoLink },
{ 'DBLP', '[[DBLP (identifier)|DBLP]]', 2456, p.dblpLink },
{ 'DBLP', '[[DBLP (identifier)|DBLP]]', 2456, p.dblpLink },
{ 'DIB', '[[DIB (identifier)|DIB]]', 6829, p.dibLink },
{ 'DSI', '[[DSI (identifier)|DSI]]', 2349, p.dsiLink },
{ 'DSI', '[[DSI (identifier)|DSI]]', 2349, p.dsiLink },
{ 'FNZA', '[[FNZA (identifier)|FNZA]]', 6792, p.fnzaLink }, --wd
{ 'FNZA', '[[FNZA (identifier)|FNZA]]', 6792, p.fnzaLink }, --wd
Línea 949: Línea 971:
{ 'LNB', '[[LNB (identifier)|LNB]]', 1368, p.lnbLink },
{ 'LNB', '[[LNB (identifier)|LNB]]', 1368, p.lnbLink },
{ 'Léonore', '[[Léonore (identifier)|Léonore]]', 640, p.leonoreLink },
{ 'Léonore', '[[Léonore (identifier)|Léonore]]', 640, p.leonoreLink },
{ 'MA', '[[MA (identifier)|MA]]', 6366, p.maLink },
{ 'MBA', '[[MBA (identifier)|MBA]]', 434, p.mbaLink, category = 'MusicBrainz' }, --special category name
{ 'MBA', '[[MBA (identifier)|MBA]]', 434, p.mbaLink, category = 'MusicBrainz' }, --special category name
{ 'MBAREA', '[[MBAREA (identifier)|MBAREA]]', 982, p.mbareaLink, category = 'MusicBrainz area' }, --special category name
{ 'MBAREA', '[[MBAREA (identifier)|MBAREA]]', 982, p.mbareaLink, category = 'MusicBrainz area' }, --special category name
Línea 1003: Línea 1026:
-- Format: { 'alias', 'parameter name in p.conf' }
-- Format: { 'alias', 'parameter name in p.conf' }
p.aliases = {
p.aliases = {
{ 'DNB', 'GND' }, --Deutsche Nationalbibliothek -> Gemeinsame Normdatei
{ 'Leonore', 'Léonore' }, --alias name without diacritics
{ 'Leonore', 'Léonore' }, --alias name without diacritics
{ 'leonore', 'Léonore' }, --lowercase variant without diacritics
{ 'leonore', 'Léonore' }, --lowercase variant without diacritics
Línea 1032: Línea 1056:
function p.authorityControl( frame )
function p.authorityControl( frame )
local resolveEntity = require( "Module:ResolveEntityId" )
local resolveEntity = require( "Module:ResolveEntityId" )
local parentArgs = frame:getParent().args
local parentArgs = frame:getParent().args --WD IDs added here later
local iParentArgs = 0 --count original/manual parent args only later
local elements = {} --create/insert rows later
local elements = {} --create/insert rows later
local worldcatCat = ''
local worldcatCat = ''
Línea 1038: Línea 1063:
local suppressedIdCat = ''
local suppressedIdCat = ''
local deprecatedIdCat = ''
local deprecatedIdCat = ''
local differentOnWDCat = ''
local sameOnWDCat = ''
--Redirect aliases to proper parameter names
--Redirect aliases to proper parameter names
Línea 1070: Línea 1097:
end
end
--Wikidata fallback if requested
--Wikidata fallback if available
if itemId then
if itemId then
local iMatches = 0
for _, params in ipairs( p.conf ) do
for _, params in ipairs( p.conf ) do
if params[3] > 0 then
if params[3] > 0 then
Línea 1078: Línea 1106:
local canUseWikidata = nil
local canUseWikidata = nil
if reqs[params[1]] then
if reqs[params[1]] then
--since reqs{} has been nil afaicr, p.matchesWikidataRequirements will never be called
--TODO: reqs{} doesn't seem useful/necessary; appendage of early WD incorporation?
canUseWikidata = p.matchesWikidataRequirements( itemId, reqs[params[1]] )
canUseWikidata = p.matchesWikidataRequirements( itemId, reqs[params[1]] )
else
else
Línea 1088: Línea 1118:
suppressedIdCat = '[[Category:Wikipedia articles with suppressed authority control identifiers|'..params[1]..']]'
suppressedIdCat = '[[Category:Wikipedia articles with suppressed authority control identifiers|'..params[1]..']]'
else
else
parentArgs[params[1]] = wikidataIds[1]
parentArgs[params[1]] = wikidataIds[1] --add ID from WD
end end end end end end end
end
end
end
else
iParentArgs = iParentArgs + 1
local wikidataIds = p.getIdsFromWikidata( itemId, 'P'..params[3] )
if wikidataIds[1] and differentOnWDCat == '' then
local bMatch = false
for _, wd in pairs( wikidataIds ) do
if val == wd then
iMatches = iMatches + 1
bMatch = true
end
end
if bMatch == false then
differentOnWDCat = '[[Category:Pages using authority control with parameters different on Wikidata|'..params[1]..']]'
end end end end end
if iMatches > 0 and iMatches == iParentArgs then
sameOnWDCat = '[[Category:Pages using authority control with parameters all matching Wikidata]]'
end
end
--Configured rows
--Configured rows
Línea 1095: Línea 1145:
for _, params in ipairs( p.conf ) do
for _, params in ipairs( p.conf ) do
local val = parentArgs[mw.ustring.lower(params[1])] or parentArgs[params[1]]
local val = parentArgs[mw.ustring.lower(params[1])] or parentArgs[params[1]]
local tval, tlinks = {}, {}
local tval, tlinks = {}, {} --init tables
if val and val ~= '' and type(params[4]) == 'function' then
if val and val ~= '' and type(params[4]) == 'function' then
table.insert( tval, val )
table.insert( tval, val )
table.insert( tlinks, params[4]( val ) )
table.insert( tlinks, params[4]( val ) )
end
end
-- collect other unique vals (IDs) from WD, if present
--collect other unique vals (IDs) from WD, if present
if itemId and tval[1] then
if itemId and tval[1] then
local wikidataIds = p.getIdsFromWikidata( itemId, 'P'..params[3] )
local wikidataIds = p.getIdsFromWikidata( itemId, 'P'..params[3] )
Línea 1114: Línea 1164:
end
end
end
end
-- assemble
--assemble
if tval[1] then
if tval[1] then
table.insert( elements, p.createRow( params[1], params[2]..':', tval, nil, tlinks, true, params.category ) )
table.insert( elements, p.createRow( params[1], params[2]..':', tval, nil, tlinks, true, params.category ) )
Línea 1172: Línea 1222:
end
end
local auxCats = worldcatCat .. elementsCat .. multipleIdCat .. suppressedIdCat .. deprecatedIdCat
local auxCats = worldcatCat .. elementsCat .. multipleIdCat .. suppressedIdCat ..  
deprecatedIdCat .. differentOnWDCat .. sameOnWDCat
if testcases then
if testcases then
auxCats = mw.ustring.gsub(auxCats, '(%[%[)(Category)', '%1:%2') --for easier checking
auxCats = mw.ustring.gsub(auxCats, '(%[%[)(Category)', '%1:%2') --for easier checking
Usuario anónimo
Las cookies nos ayudan a ofrecer nuestros servicios. Al utilizar nuestros servicios, aceptas nuestro uso de cookies.

Menú de navegación