Open main menu

Changes

Module:Authority control

1,167 bytes added, 23:25, 11 September 2013
sync with Module:Authority control/sandbox, enable musicbrainz artist links
id = parts[1] .. parts[2] .. append( parts[3], '0', 6 )
return '[http://id.loc.gov/authorities/names/' .. id .. ' ' .. id .. ']' .. getCatForId( 'LCCN' )
end
 
function mbLink( id )
-- TODO Implement some sanity checking regex
return '[//musicbrainz.org/artist/' .. id .. ' ' .. id .. ']'
end
end
return ids
end
 
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.value['numeric-id'] == qid then
return true
end
end
end
end
return false
end
{ 'RID', '[[ResearcherID]]', 0, ridLink },
{ 'BIBSYS', '[[BIBSYS]]', 0, bibsysLink },
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink }, { 'MBA', '[[MusicBrainz]]', 434, mbLink },
}
 -- Check that the Wikidata item has this property-->value before adding itlocal reqs = {}reqs['MBA'] = { { 106, 177220 } -- occupation -> singer} 
local p = {}
local val = parentArgs[params[1]]
if not val or val == '' then
local canUseWikidata = nil if reqs[params[1]] ~= nil then canUseWikidata = matchesWikidataRequirements( item, reqs[params[1]] ) else canUseWikidata = true end if canUseWikidata then local wikidataIds = getIdsFromWikidata( item, 'p' .. params[3] ) if wikidataIds[1] then parentArgs[params[1]] = wikidataIds[1] end
end
end
Anonymous user