Module:Portal maintenance status
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module searches a Portal_talk: page's portal page, and returns an appropriate message based if {{Portal maintenance status}} is found in the page's wikitext, and which parameters are used.
An error is reported if this module is used outside of the Portal_talk namespace. It can be demonstrated, in any namespace, with the |demo=
and |demo2=
parameters, which take the name of templates to "find" (instead of actually searching a page).
Usage
{{#invoke:Portal maintenance status|main}}
- Looks for {{Portal maintenance status}} on a Portal_talk: page's related portal page.
- Returns an appropriate message string if found or an empty string if not found, or an error if used in the wrong namespace.
{{#invoke:Portal maintenance status|historical}}
- Looks for {{Historical}} on a Wikipedia_talk: page's related project page.
- Returns yes if found or an empty string if not found, or an error if used in the wrong namespace.
{{#invoke:Portal maintenance status|featured}}
- Looks for {{Featured portal}} on a Wikipedia_talk: page's related project page.
- Returns yes if found or an empty string if not found, or an error if used in the wrong namespace.
Examples
If the portal contains {{Portal maintenance status|date=May 2025|manual=yes}}
If the portal contains {{Portal maintenance status|date=May 2025|nonstandard=yes}}
If the portal contains {{Portal maintenance status|date=May 2025|incomplete=yes}}
If the portal contains {{Portal maintenance status|date=May 2025|subpages=single}}
If the portal contains {{Portal maintenance status|date=May 2025|subpages=checked}}
If the portal contains {{Portal maintenance status|date=May 2025|note=This is an example.}}
If the portal contains {{Portal maintenance status|date=May 2025|manual=yes|nonstandard=yes|subpages=single|incomplete=yes|note=Lorem ipsum dolor sit amet.}}
If the portal does not contain the template, there should be no output
If used in the wrong namespace, an error should be reported
Lua error: Wrong namespace.
See also
local p = {}
function cleanupArgs(argsTable)
local cleanArgs = {}
for key, val in pairs(argsTable) do
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val ~= '' then
cleanArgs[key] = val
end
else
cleanArgs[key] = val
end
end
return cleanArgs
end
p.main = function(frame)
local parent = frame.getParent(frame)
local args = cleanupArgs(frame.args)
local demo = args.demo and true or false
local portalContent
if demo then
portalContent = '{{' .. args.demo .. '}}'
if args.demo2 then
portalContent = portalContent .. '{{' .. args.demo2 .. '}}'
end
else
local talkTitle = mw.title.getCurrentTitle()
if talkTitle.namespace ~= 101 then
return error('Wrong namespace')
end
local portalTitle = mw.title.new("Portal:"..talkTitle.text)
portalContent = portalTitle:getContent()
end
local isMaintained = mw.ustring.find(portalContent, '%{%{%s*[Mm]aintained portal flag%s*%}%}') and true or false
local isNonstandard = mw.ustring.find(portalContent, '%{%{%s*[Nn]on%-standard portal flag%s*%}%}') and true or false
if (not isMaintained) and (not isNonstandard) then
return ''
end
local text = "This portal " .. ( isMaintained and "'''is [[Wikipedia:WikiProject Portals#Specific portal maintainers|maintained]]'''" or '' ) .. ( ( isMaintained and isNonstandard ) and ' and ' or '' ) .. ( isNonstandard and "has a '''non-standard layout'''" or '' ) .. '.'
local subtext = "Please [[WP:CAREFUL|take care]] when editing, especially if using [[WP:ASSISTED|automated editing software]]" .. ( isMaintained and ", and seek [[Wikipedia:Consensus|consensus]] before making major changes." or '.')
return text .. '<br>' .. '<span style="font-size:90%">' .. subtext .. '</span>'
end
return p