Module:WikidataCheck
Apparence
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local p = {}
local function categorize(wikipediavalue, wikidatavalue, catbase)
if not wikidatavalue then
return "[[Category:" .. catbase .. " absent de Wikidata]]"
end
if not wikipediavalue then
return "[[Category:" .. catbase .. " fourni par Wikidata]]"
end
if wikipediavalue == wikidatavalue then
return "[[Category:" .. catbase .. " identique sur Wikidata]]" -- yay!
end
return "[[Category:" .. catbase .. " différent sur Wikidata]]" -- needs human review :(
end
local function wikidatacheck(wikipediavalue, wikidatavalue, catbase, namespaces)
-- exit if cat disabled in this namesapce
local ok = false -- one-way flag to check if we're in a good namespace
local ns = mw.title.getCurrentTitle().namespace
for v in mw.text.gsplit( namespaces, ",", true) do
if tonumber(v) == ns then
ok = true
end
end
if not ok then -- not in one of the approved namespaces
return ""
end
return categorize(wikipediavalue, wikidatavalue, catbase)
end
function p.wikidatacheck(frame)
local args= frame.args
local namespaces = args.namespaces
local wikipediavalue = args.value
local property = args.property
local catbase = args.category
local wikidatavalue = require('Module:Wikidata')._formatStatements({item= item, property=property})
return wikidatacheck(wikipediavalue, wikidatavalue, catbase, namespaces)
end
function p.checkedlink(frame)
local args = frame.args
local property = args.property
local item = args.item
local namespaces = args.namespaces or '0'
local catname = args.category
local wikipediavalue = args.id
local wikidatavalue = require('Module:Wikidata')._formatStatements({item = item, property = property})
local val = wikipediavalue or wikidatavalue
if not val then
return nil
end
local title = args.title or val
local link = args.url .. val
local realcat = categorize(wikipediavalue, wikidatavalue)
local title = args.title or 'entrée ' .. val
local accessdate = args.accessdate
local website = ''
if args.website then
website = ' sur le site ' .. website
end
local accessdate = ''
if args.accessdate then
accessdate = ', consulté le ' .. accessdate
end
return '[' .. link .. ' ' .. title .. ']' .. website .. accessdate .. '.', realcat
end
return p