Module:Portal: Difference between revisions

Content deleted Content added
add nominimum
omit tracking categories on user pages
Line 41:
 
local p = {}
 
local isUserPage = false
 
local function checkIfUserPage()
local thisPage = mw.title.getCurrentTitle()
if (thisPage.namespace == 2) or (thisPage.namespace == 3) then
isUserPage = true
return true
end
isUserPage = false
return false
end
 
 
local function matchImagePage(s)
Line 84 ⟶ 97:
function p._portal(portals, args)
-- This function builds the portal box used by the {{portal}} template.
checkIfUserPage()
local root = mw.html.create('div')
:attr('role', 'navigation')
Line 96 ⟶ 110:
if not portals[1] then
if (args.nominimum == 'yes') or (args.nominimum == 'y') or (args.nominimum == 'true') then
-- if nominimum as been set to yes (or similar), just addomit the cleanup category without a warning
root:wikitext('[[Category:Portal templates without a parameter]]')
else
root:wikitext('<strong class="error">No portals specified: please specify at least one portal</strong>')
end
if not (isUserPage) then
root:wikitext('[[Category:Portal templates without a parameter]]')
end
return tostring(root)
Line 115 ⟶ 132:
if (args.redlinks == 'yes') or (args.redlinks == 'y') or (args.redlinks == 'true') or (args.redlinks == 'include') then
-- if redlinks as been set to yes (or similar), add the cleanup category and then break the loop before the portal is removed from the list
if not (isUserPage) then
root:wikitext('[[Category:Portal templates with redlinked portals]]')
end
break
end
Line 126 ⟶ 145:
if not (portallen == #portals) then
if #portals == 0 then
if (isUserPage) then
return '[[Category:Portal templates with all redlinked portals]]'
return ""
else
return '[[Category:Portal templates with all redlinked portals]]'
end
end
if not (isUserPage) then
root:wikitext('[[Category:Portal templates with redlinked portals]]')
root:wikitext('[[Category:Portal templates withoutwith aredlinked parameterportals]]')
end
end