Module:Portal: Difference between revisions

Content deleted Content added
Add tracking category Category:Usage of portal image for non-existent portal
add tracking category for default image
Line 274:
end
 
function p._image(portal,nostripkeep)
-- Wrapper function to allow getImageName() to be accessed through #invoke.
-- backward compatibility: if table passed, take first element
Line 281:
end
local name = getImageName(portal)
-- If nostripkeep is yes (or equivalent), then allow all metadata (like image borders) to be returned
local stripkeepargs = not yesno(nostripkeep)
local args = mw.text.split(name, "|", true)
local result = strip and name:match('^(.-)|') or name -- FIXME: use a more elegant way to separate borders etc. from the image name
local result = {args[1]} -- the filename always comes first
local category = ''
-- parse name, looking for category arguments
for i = 2,#args do
local m = mw.ustring.match(args[i], "^%s*category%s*=%s*(.+)")
if m then
category = category .. m
elseif keepargs then
table.insert(result, args[i])
end
end
-- Temporary tracking category to clear out deleted portals
local portalTitle = mw.title.new(portal,"Portal")
if portalTitle and not portalTitle.exists then
resultcategory = resultcategory .. "|category=[[Category:Usage of portal image for non-existent portal]]"
end
-- reassemble arguments
result = table.concat(result,"|")
-- reappend categories
if #category > 0 then
result = result .. "|category=" .. category
end
return result