మాడ్యూల్:Authority control: కూర్పుల మధ్య తేడాలు

Content deleted Content added
added Wikidata parsing per lack of objections at Template talk:Authority control/Archive 3#Wikidata support
Undid revision 569546376 by Gabbe (talk): Seems to have caused errors to some articles, reverted.
పంక్తి 9:
return '[[Category:Miscellaneous pages with ' .. id .. ' identifiers]]'
end
end
 
function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
table.insert( ids, statement.mainsnak.datavalue.value )
end
return ids
end
 
Line 146 ⟶ 135:
return '* <span class="error">The ' .. id .. ' id ' .. rawValue .. ' is not valid.</span>[[Category:Wikipedia articles with faulty authority control identifiers (' .. id .. ')]]\n'
end
end
 
function inArray( value, array )
for _, element in pairs( array ) do
if value == element then
return true
end
end
return false
end
 
Line 172 ⟶ 152:
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink }
}
end
 
local p = {}
 
Line 179 ⟶ 159:
--Create rows
local elements = {}
 
--Item
local item = mw.wikibase.getEntity()
 
--Worldcat
Line 196 ⟶ 173:
for k, params in pairs( conf ) do
local val = parentArgs[params[1]]
local text = ''
 
--Wikidata
if item ~= nil and params[3] ~= 0 then
local wikidataIds = getIdsFromWikidata( item, 'p' .. params[3] )
if wikidataIds[1] then
if val and val ~= '' then
--[[TODO Consistency check
if not inArray( val, wikidataIds ) then
text = text .. '[Category:Inconsistent Authority identifier between Wikidata and Wikipedia]'
end]]--
else
--Fallback
val = wikidataIds[1]
end
end
end
 
if val and val ~= '' then
table.insert( elements, createRow( params[1], params[2] .. ':', val, params[4]( val ), true ) )
"https://te.wikipedia.org/wiki/మాడ్యూల్:Authority_control" నుండి వెలికితీశారు