Module:Coordinates: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(check for nil values of entity.claims per protected edit request by User:Hydrox)
(only add Wikidata categories if coordinates are displayed in the title)
Line 580: Line 580:
local text = ''
local text = ''
if string.find( Display, 'inline' ) ~= nil
local valid_Display = false
if string.find( Display, 'inline' ) ~= nil or Display == 'i' or
or Display == 'i'
Display == 'it' or Display == 'ti' then
or Display == 'it'
or Display == 'ti'
then
-- Coordinates are displayed inline.
text = displayinline(contents, Notes)
text = displayinline(contents, Notes)
valid_Display = true
end
end
if string.find( Display, 'title' ) ~= nil or Display == 't' or
if string.find( Display, 'title' ) ~= nil
Display == 'it' or Display == 'ti' then
or Display == 't'
or Display == 'it'
or Display == 'ti'
then
-- Coordinates are displayed in the title.
text = text .. displaytitle(contents, Notes)
text = text .. displaytitle(contents, Notes)
-- Add a Wikidata category for mainspace pages.
valid_Display = true
if mw.wikibase and current_page.namespace == 0 then
end
local wikidata_cat
local wikidata_cat
local entity = mw.wikibase.getEntity()
if valid_Display and mw.wikibase and current_page.namespace == 0 then -- add the appropriate Wikidata category for main namespace pages
local entity = mw.wikibase.getEntity()
if entity and entity.claims and entity.claims.p625 then
if entity and entity.claims and entity.claims.p625 then
local snaktype = entity.claims.p625[0].mainsnak.snaktype
local snaktype = entity.claims.p625[0].mainsnak.snaktype
if snaktype == 'value' then
wikidata_cat = '[[Category:Coordinates on Wikidata]]' -- coordinates exist both here and on Wikidata, and can be compared
if snaktype == 'value' then
elseif snaktype == 'somevalue' then
wikidata_cat = '[[Category:Coordinates on Wikidata]]' -- coordinates exist both here and on Wikidata, and can be compared
wikidata_cat = '[[Category:Coordinates on Wikidata set to unknown value]]'
elseif snaktype == 'somevalue' then
elseif snaktype == 'novalue' then
wikidata_cat = '[[Category:Coordinates on Wikidata set to unknown value]]'
wikidata_cat = '[[Category:Coordinates on Wikidata set to no value]]'
elseif snaktype == 'novalue' then
end
wikidata_cat = '[[Category:Coordinates on Wikidata set to no value]]'
else
wikidata_cat = '[[Category:Coordinates not on Wikidata]]' -- we have to either import the coordinates to Wikidata or remove them here
end
if wikidata_cat then
text = text .. wikidata_cat
end
end
else
wikidata_cat = '[[Category:Coordinates not on Wikidata]]' -- we have to either import the coordinates to Wikidata or remove them here
end
end
end
end

wikidata_cat = wikidata_cat or ''
text = text .. wikidata_cat
return text
return text
end
end