Module:Coordinates: Difference between revisions
add support for optional qid for template:infobox observatory
m (1 revision imported) |
(add support for optional qid for template:infobox observatory) |
||
Line 485: | Line 485: | ||
Generate Wikidata tracking categories. | Generate Wikidata tracking categories. | ||
]] | ]] | ||
local function makeWikidataCategories() | local function makeWikidataCategories(qid) | ||
local ret | local ret | ||
if mw.wikibase and current_page.namespace == 0 then | if mw.wikibase and current_page.namespace == 0 then | ||
local entity = mw.wikibase.getEntityObject() | local entity = qid and mw.wikibase.getEntityObject(qid) or mw.wikibase.getEntityObject() | ||
if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1] then | if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1] then | ||
local snaktype = entity.claims.P625[1].mainsnak.snaktype | local snaktype = entity.claims.P625[1].mainsnak.snaktype | ||
Line 609: | Line 609: | ||
if (not args[1] or not tonumber(args[1])) and not args[2] and mw.wikibase.getEntityObject() then | if (not args[1] or not tonumber(args[1])) and not args[2] and mw.wikibase.getEntityObject() then | ||
args[3] = args[1]; args[1] = nil | args[3] = args[1]; args[1] = nil | ||
local entity = mw.wikibase.getEntityObject() | local entity = args.qid and mw.wikibase.getEntityObject(args.qid) or mw.wikibase.getEntityObject() | ||
if entity | if entity | ||
and entity.claims | and entity.claims | ||
Line 651: | Line 651: | ||
text = text | text = text | ||
.. displaytitle(contents, Notes) | .. displaytitle(contents, Notes) | ||
.. makeWikidataCategories() | .. makeWikidataCategories(args.qid) | ||
end | end | ||
if not args.nosave then | if not args.nosave then |