Content deleted Content added
add Draft/Draft talk namespaces to list of untracked namespaces |
disable tracking on some pagenames which contain "/archive", "/doc" or "/test" |
||
Line 42:
local p = {}
local
-- Check whether to do tracking in this namespace
local function checkNamespace()▼
-- Returns true unless the page is one of the banned namespaces
local function checkTrackingNamespace()
local thisPage = mw.title.getCurrentTitle()
if (thisPage.namespace == 1) -- Talk
Line 58 ⟶ 60:
or (thisPage.namespace == 829) -- Module talk
then
return true▼
end
end
▲ return false
-- Check whether to do tracking on this pagename
-- Returns false if the page title matches one of the banned strings
-- Otherwise returns true
local thisPage = mw.title.getCurrentTitle()
local thisPageLC = mw.ustring.lower(thisPage.text)
if (string.match(thisPageLC, "/archive") ~= nil) then
end
if (string.match(thisPageLC, "/doc") ~= nil) then
return false
end
if (string.match(thisPageLC, "/test") ~= nil) then
return false
end
return true
end
Line 108 ⟶ 126:
function p._portal(portals, args)
-- This function builds the portal box used by the {{portal}} template.
local root = mw.html.create('div')
:attr('role', 'navigation')
Line 117 ⟶ 134:
:css('border', 'solid #aaa 1px')
:newline()
-- Tracking is on by default.
-- It is disabled if any of the following is true
-- 1/ the parameter "tracking" is set to 'no, 'n', or 'false'
-- 2/ the current page fails the namespace tests in checkTrackingNamespace()
-- 3/ the current page fails the pagename tests in checkTrackingPagename()
if (args.tracking == 'no') or (args.tracking == 'n') or (args.tracking == 'false') then
trackingEnabled = false
end
if (checkTrackingNamespace() == false) then
trackingEnabled = false
end
if (checkTrackingPagename() == false) then
trackingEnabled = false
end
-- If no portals have been specified, display an error and add the page to a tracking category.
Line 126 ⟶ 158:
root:wikitext('<strong class="error">No portals specified: please specify at least one portal</strong>')
end
if
root:wikitext('[[Category:Portal templates without a parameter]]')
end
Line 143 ⟶ 175:
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
root:wikitext('[[Category:Portal templates with redlinked portals]]')
end
Line 155 ⟶ 187:
-- if the length of the table is different, then rows were removed from the table, so portals were removed. If this is the case add the cleanup category
if not (portallen == #portals) then
if
if
▲ return ""
return '[[Category:Portal templates with all redlinked portals]]'
else
root:wikitext('[[Category:Portal templates with redlinked portals]]')▼
end
▲ root:wikitext('[[Category:Portal templates with redlinked portals]]')
end
end
|