Module:Portal: Difference between revisions

Content deleted Content added
rename class to portalbox so that it will work on mobile
add two entry points to simplify Module:Portal bar, clean up tracking logic. No behavior changes.
Line 50:
-- Check whether to do tracking in this namespace
-- Returns true unless the page is one of the banned namespaces
local function checkTrackingNamespace(title)
local thisPage = title or mw.title.getCurrentTitle()
ifreturn not( (thisPage.namespace == 1) -- Talk
or (thisPage.namespace == 2) -- User
or (thisPage.namespace == 3) -- User talk
Line 63:
or (thisPage.namespace == 118) -- Draft
or (thisPage.namespace == 119) -- Draft talk
or (thisPage.namespace == 829)) -- Module talk
then
return false
end
return true
end
 
Line 73 ⟶ 69:
-- Returns false if the page title matches one of the banned strings
-- Otherwise returns true
local function checkTrackingPagename(title)
local thisPage = title or mw.title.getCurrentTitle()
local thisPageLC = mw.ustring.lower(thisPage.text)
ifreturn not(string mw.ustring.match(thisPageLC, "/archive") ~= nil) then
if or (stringmw.ustring.match(thisPageLC, "/doc") ~= nil) then
return false
if or (stringmw.ustring.match(thisPageLC, "/test") ~= 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
 
--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)
Line 290 ⟶ 288:
end
return portals, namedArgs
end
 
-- Entry point for sorting portals from other named arguments
function p._processPortalArgs(args)
return processPortalArgs(args)
end