Module:Banner shell
Appearance
![]() | 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 Lua module is used on approximately 11,300,000 pages, or roughly 18% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
Banner shell |
---|
Usage
This module implements Template:WikiProject banner shell and Template:Banner holder. Please refer to those templates' documentation.
local p = {}
local DuplicateBanners = function(text)
local capture = '<span class="wpb%-project">([%w%s]*)</span>'
local banners = {}
for project in text:gmatch(capture) do
if banners[project] == true then
return '[[Category:Pages using WikiProject banner shell with duplicate banner templates|' .. project .. ']]'
end
banners[project] = true
end
end
local ofinterest = function(collapsed)
local wikiprojects = '[[Wikipedia:WikiProject|WikiProjects]]'
local text = ' is of interest to '
if collapsed then
text = text .. 'multiple ' .. wikiprojects .. '.'
else
text = text .. 'the following ' .. wikiprojects .. ':'
end
return text
end
p.main = function(frame)
local classmask = require('Module:Class mask')
local readarticleclass = require('Module:WikiProject banner').readarticleclass
local yesno = require('Module:Yesno')
local args = frame:getParent().args
local class = classmask._main{args.class or ''}
local pagetype = require('Module:Pagetype')._main{class=class}
local out = {}
if yesno(args.blp) or yesno(args.living) then
table.insert(out,frame:expandTemplate{title = 'BLP'})
elseif yesno(args.blpo) then
table.insert(out,frame:expandTemplate{title = 'BLP others'})
end
if yesno(args.activepol) then
table.insert(out, frame:expandTemplate{title = 'Active politician'})
end
local bhargs = {
templatestyles = 'WikiProject banner shell/styles.css',
collapsed = args.collapsed,
size = '32',
class = 'wpbs',
image = 'WikiProject Council with transparent background.svg',
alt = 'WikiProject Council',
image_link = 'Wikipedia:WikiProject Council'
}
local globalclass = false
if class == '' then -- check if class parameters is defined by any project banner
local articleclass = readarticleclass{ignore_blank=true, only_subtemplates=true}
if articleclass == '' then -- no class parameters are defined by any project banner, so globally unassessed
globalclass = true
end
else -- global class defined, so display it
globalclass = true
end
if globalclass then
local icon = require('Module:Class')._icon{class,size='35px'}
local header = '<td style="text-align: center;">' .. icon .. '</td><td class="banner-shell-header" style="text-align: left; font-weight: normal;">This '
if args.category == 'no' then
header = header .. 'article '
else
header = header .. pagetype .. ' '
end
if class == '' then
header = header .. 'has not yet been rated'
else
header = header .. 'is rated <span style="font-weight:bold;">' .. class .. '-class</span>'
end
header = header .. " on Wikipedia's [[Wikipedia:Content assessment|content assessment]] scale.<br>"
if args[1] and args[1]~='' then
header = header .. 'It' .. ofinterest(yesno(args.collapsed))
else
if not args.category or args.category=='' then
if mw.title.getCurrentTitle().isTalkPage then
header = header .. '[[Category:' .. (class=='' and 'Unassessed' or (class .. '-Class')) .. ' articles]]'
end
end
end
header = header .. '</td>'
bhargs.header = header
end
if args.header then
bhargs.text = args.header
else
bhargs.text = 'This ' .. pagetype .. ofinterest(yesno(args.collapsed))
end
bhargs[1] = args[1] or ''
table.insert(out,frame:expandTemplate{title='Banner holder', args=bhargs})
if args[1] and args[1]~='' then
local duplicate_cat = DuplicateBanners(args[1])
if duplicate_cat and mw.title.getCurrentTitle().isTalkPage then
table.insert(out, duplicate_cat)
end
elseif mw.title.getCurrentTitle().isTalkPage then
table.insert(out,'[[Category:Pages using WikiProject banner shell without banner templates]]')
end
if args.listas and args.listas ~= '' then
table.insert(out,frame:preprocess('{{DEFAULTSORT:' .. args.listas .. '}}'))
end
return table.concat(out)
end
return p