Module:Portal maintenance status/sandbox
< Module:Portal maintenance status
Jump to navigation
Jump to search
Revision as of 00:43, 10 June 2018 by test>Evad37 (Create sandbox version of Module:Portal maintenance status)
Documentation for this module may be created at Module:Portal maintenance status/sandbox/doc
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', 0)
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