Changes

278 bytes added ,  11:45, 10 January 2022
m
KS update 1.2
Line 23: Line 23:  
local current_page = mw.title.getCurrentTitle()
 
local current_page = mw.title.getCurrentTitle()
 
local page_name = mw.uri.encode( current_page.prefixedText, 'WIKI' );
 
local page_name = mw.uri.encode( current_page.prefixedText, 'WIKI' );
local coord_link = '//tools.wmflabs.org/geohack/geohack.php?pagename=' .. page_name .. '&params='
+
local coord_link = '//geohack.toolforge.org/geohack.php?pagename=' .. page_name .. '&params='
 +
local templatestyles = 'Module:Coordinates/styles.css'
    
--[[ Helper function, replacement for {{coord/display/title}} ]]
 
--[[ Helper function, replacement for {{coord/display/title}} ]]
Line 156: Line 157:  
end
 
end
   −
return '<span class="plainlinks nourlexpansion">' ..
+
return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = templatestyles} }
'[' .. coord_link .. uriComponents .. ' ' .. inner .. ']' .. '</span>'
+
      .. '<span class="plainlinks nourlexpansion">'
 +
      .. '[' .. coord_link .. uriComponents .. ' ' .. inner .. ']'
 +
      .. '</span>'
 
end
 
end
   Line 464: Line 467:  
else
 
else
 
-- Error
 
-- Error
return errorPrinter({{"formatTest", "Unknown argument format"}})
+
return errorPrinter({{"formatTest", "Unknown argument format"}}) .. '[[Category:Pages with malformed coordinate tags]]'
 
end
 
end
 
result.name = args.name
 
result.name = args.name
Line 487: Line 490:  
local function makeWikidataCategories(qid)
 
local function makeWikidataCategories(qid)
 
local ret
 
local ret
 +
local qid = qid or mw.wikibase.getEntityIdForCurrentPage()
 
if mw.wikibase and current_page.namespace == 0 then
 
if mw.wikibase and current_page.namespace == 0 then
local entity = qid and mw.wikibase.getEntityObject(qid) or mw.wikibase.getEntityObject()
+
if qid and mw.wikibase.entityExists(qid) and mw.wikibase.getBestStatements(qid, "P625") and mw.wikibase.getBestStatements(qid, "P625")[1] then
if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1] then
+
local snaktype = mw.wikibase.getBestStatements(qid, "P625")[1].mainsnak.snaktype
local snaktype = entity.claims.P625[1].mainsnak.snaktype
   
if snaktype == 'value' then
 
if snaktype == 'value' then
 
-- coordinates exist both here and on Wikidata, and can be compared.
 
-- coordinates exist both here and on Wikidata, and can be compared.