Module:Coordinates: Difference between revisions

Jump to navigation Jump to search
only add Wikidata categories if coordinates are displayed in the title
(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:
local text = ''
if string.find( Display, 'inline' ) ~= nil
local valid_Display = false
if string.find( Display, 'inline' ) ~= nil or Display == 'i' or
Display == 'it' or Display == 'tiit' then
or Display == 'ti'
then
-- Coordinates are displayed inline.
text = displayinline(contents, Notes)
valid_Display = true
end
if string.find( Display, 'title' ) ~= nil or Display == 't' or
Display == 'it' or Display == 'tit' then
or Display == 'it'
or Display == 'ti'
then
-- Coordinates are displayed in the title.
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 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 if entity =and mwentity.wikibaseclaims and entity.getEntity()claims.p625 then
if local entitysnaktype and= entity.claims and entity.claimsp625[0].p625 thenmainsnak.snaktype
local if snaktype == entity.claims.p625[0].mainsnak.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
if elseif snaktype == 'valuenovalue' 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
wikidata_cat = if wikidata_cat or ''then
text = text .. wikidata_cat
end
else
wikidata_cat = '[[Category:Coordinates not on Wikidata]]' -- we have to either import the coordinates to Wikidata or remove them here
end
end
 
wikidata_cat = wikidata_cat or ''
text = text .. wikidata_cat
return text
end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu