Changes

1,389 bytes removed ,  02:54, 19 May 2023
Edit module to remove links to Wikidata
Line 483: Line 483:  
end
 
end
 
return ret, backward
 
return ret, backward
end
  −
  −
--[[
  −
Generate Wikidata tracking categories.
  −
]]
  −
local function makeWikidataCategories(qid)
  −
local ret
  −
local qid = qid or mw.ext.UnlinkedWikibase.getEntityId('enwiki')
  −
-- TODO: Remove call to mw.wikibase
  −
if mw.wikibase and current_page.namespace == 0 then
  −
-- TODO: Remove call to mw.wikibase
  −
if qid and mw.wikibase.entityExists(qid) and mw.wikibase.getBestStatements(qid, "P625") and mw.wikibase.getBestStatements(qid, "P625")[1] then
  −
-- TODO: Remove call to mw.wikibase
  −
local snaktype = mw.wikibase.getBestStatements(qid, "P625")[1].mainsnak.snaktype
  −
if snaktype == 'value' then
  −
-- coordinates exist both here and on Wikidata, and can be compared.
  −
ret = 'Coordinates on Wikidata'
  −
elseif snaktype == 'somevalue' then
  −
ret = 'Coordinates on Wikidata set to unknown value'
  −
elseif snaktype == 'novalue' then
  −
ret = 'Coordinates on Wikidata set to no value'
  −
end
  −
else
  −
-- We have to either import the coordinates to Wikidata or remove them here.
  −
ret = 'Coordinates not on Wikidata'
  −
end
  −
end
  −
if ret then
  −
return string.format('[[Category:%s]]', ret)
  −
else
  −
return ''
  −
end
   
end
 
end
   Line 615: Line 583:  
if not tonumber(args[1]) and not args[2] then
 
if not tonumber(args[1]) and not args[2] then
 
args[3] = args[1]; args[1] = nil
 
args[3] = args[1]; args[1] = nil
-- TODO: Remove call to mw.wikibase
+
 
local entity = mw.wikibase.getEntityObject(args.qid)
+
local precision = entity.claims.P625[1].mainsnak.datavalue.value.precision
if entity
+
args[1] = entity.claims.P625[1].mainsnak.datavalue.value.latitude
and entity.claims
+
args[2] = entity.claims.P625[1].mainsnak.datavalue.value.longitude
and entity.claims.P625
+
if precision then
and entity.claims.P625[1].mainsnak.snaktype == 'value'
+
precision = -math_mod._round(math.log(precision)/math.log(10),0)
then
+
args[1] = math_mod._round(args[1],precision)
local precision = entity.claims.P625[1].mainsnak.datavalue.value.precision
+
args[2] = math_mod._round(args[2],precision)
args[1] = entity.claims.P625[1].mainsnak.datavalue.value.latitude
  −
args[2] = entity.claims.P625[1].mainsnak.datavalue.value.longitude
  −
if precision then
  −
precision = -math_mod._round(math.log(precision)/math.log(10),0)
  −
args[1] = math_mod._round(args[1],precision)
  −
args[2] = math_mod._round(args[2],precision)
  −
end
   
end
 
end
 
end
 
end
Line 658: Line 619:  
text = text
 
text = text
 
.. displaytitle(contents, Notes)
 
.. displaytitle(contents, Notes)
.. makeWikidataCategories(args.qid)
   
end
 
end
 
if not args.nosave then
 
if not args.nosave then