Anonymous user
Module:Portal: Difference between revisions
Jump to navigation
Jump to search
add two entry points to simplify Module:Portal bar, clean up tracking logic. No behavior changes.
Richardpruen (talk | contribs) m (1 revision imported) |
(add two entry points to simplify Module:Portal bar, clean up tracking logic. No behavior changes.) |
||
Line 50: | Line 50: | ||
-- Check whether to do tracking in this namespace | -- Check whether to do tracking in this namespace | ||
-- Returns true unless the page is one of the banned namespaces | -- Returns true unless the page is one of the banned namespaces | ||
local function checkTrackingNamespace() | local function checkTrackingNamespace(title) | ||
local thisPage = mw.title.getCurrentTitle() | local thisPage = title or mw.title.getCurrentTitle() | ||
return not( (thisPage.namespace == 1) -- Talk | |||
or (thisPage.namespace == 2) -- User | or (thisPage.namespace == 2) -- User | ||
or (thisPage.namespace == 3) -- User talk | or (thisPage.namespace == 3) -- User talk | ||
Line 63: | Line 63: | ||
or (thisPage.namespace == 118) -- Draft | or (thisPage.namespace == 118) -- Draft | ||
or (thisPage.namespace == 119) -- Draft talk | or (thisPage.namespace == 119) -- Draft talk | ||
or (thisPage.namespace == 829) -- Module talk | or (thisPage.namespace == 829)) -- Module talk | ||
end | end | ||
Line 73: | Line 69: | ||
-- Returns false if the page title matches one of the banned strings | -- Returns false if the page title matches one of the banned strings | ||
-- Otherwise returns true | -- Otherwise returns true | ||
local function checkTrackingPagename() | local function checkTrackingPagename(title) | ||
local thisPage = mw.title.getCurrentTitle() | local thisPage = title or mw.title.getCurrentTitle() | ||
local thisPageLC = mw.ustring.lower(thisPage.text) | local thisPageLC = mw.ustring.lower(thisPage.text) | ||
return not( mw.ustring.match(thisPageLC, "/archive") | |||
or mw.ustring.match(thisPageLC, "/doc") | |||
or mw.ustring.match(thisPageLC, "/test")) | |||
end | end | ||
--Entry point to check if page should be category tracked | |||
--Arguments: | |||
-- title (optional): mw.title.Title object to evaluate. Defaults to current page | |||
--Returns: | |||
-- bool whether page should be tracked | |||
function p._checkTracking(title) | |||
title = title or mw.title.getCurrentTitle() | |||
return checkTrackingNamespace(title) and checkTrackingPagename(title) | |||
end | |||
local function matchImagePage(s) | local function matchImagePage(s) | ||
Line 134: | Line 132: | ||
:attr('role', 'navigation') | :attr('role', 'navigation') | ||
:attr('aria-label', 'Portals') | :attr('aria-label', 'Portals') | ||
:addClass('noprint | :addClass('noprint portalbox plainlist') | ||
:addClass(args.left and 'tleft' or 'tright') | :addClass(args.left and 'tleft' or 'tright') | ||
:css('margin', args.margin or nil) | :css('margin', args.margin or nil) | ||
Line 290: | Line 288: | ||
end | end | ||
return portals, namedArgs | return portals, namedArgs | ||
end | |||
-- Entry point for sorting portals from other named arguments | |||
function p._processPortalArgs(args) | |||
return processPortalArgs(args) | |||
end | end | ||