Module:Banner shell: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
local
This indeed doesn't work. It appears preprocessing the magic word in any form will make it apply to the page, even if not given in the output, so testing this approach instead
Tag: Reverted
Line 78: Line 78:
end
end
if args.listas and args.listas ~= '' then
if args.listas and args.listas ~= '' then
out = out .. '{{DEFAULTSORT:' .. args.listas .. '}}' -- probably won't work
frame:preprocess('{{DEFAULTSORT:' .. args.listas .. '}}')
end
end
return out
return out

Revision as of 12:05, 4 May 2023

local p = {}
p.main = function(frame)
	local yesno = require('Module:Yesno')
	local classmask = require('Module:Class mask')._main
	local args = frame:getParent().args
	local class = classmask{args.class or ''}
	local pagetype = require('Module:Pagetype')._main{class=class}
	local out = ''
	local ofinterest = function(collapsed)
		local wikiprojects = '[[Wikipedia:WikiProject|WikiProjects]]'
		local text = ' is of interest to '
		if yesno(collapsed) then
			text = text .. 'multiple ' .. wikiprojects .. '.'
		else
			text = text .. 'the following ' .. wikiprojects .. ':'
		end
		return text
	end
	if yesno(args.blp) then
		out = out .. frame:expandTemplate{title = 'BLP'}
	elseif yesno(args.blpo) then
		out = out .. frame:expandTemplate{title = 'BLP others'}
	end
	if yesno(args.activepol) then
		out = 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 get_parameter_value = require("Module:Template parameter value").getValue
		local currentpage = mw.title.getCurrentTitle().prefixedText
		local WPBSredirects = {'WikiProject banner shell','WikiProject banner shell/sandbox','Bannershell','Multiple wikiprojects','Project shell','Scope shell','WPB','WPBS','WPBannerShell','WP Banner Shell','WP banner shell','WikiProjectBannerShell','WikiProjectBanner Shell','WikiProjectBanners','WikiProject BannerShell','WikiProject Banner Shell','WikiProject Banners','WikiProject Banners Shell','WikiProject Shell','WikiProject banner','WikiProject banner shell/redirect','WikiProject shell','WikiprojectBannerShell','Wikiproject banner holder','Wikiproject banner shell','Wikiprojectbanners','Wikiprojectbannershell','Wpb','Wpbannershell','Wpbsgclass'}
		local _,projectclass = get_parameter_value(currentpage, WPBSredirects, 'class', {ignore_blank=true, only_subtemplates=true})
		if projectclass == '' 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 showclass = require('Module:Class')._class
		local header = showclass{class, image='yes'}
		header = header .. '<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] then
			header = header .. 'It' .. ofinterest(args.collapsed)
		end
		header = header .. '</td>'
		bhargs.header = header
	end
	if args.header then
		bhargs.text = args.header
	else
		bhargs.text = 'This ' .. pagetype .. ofinterest(args.collapsed)
	end
	bhargs[1] = args[1] or ''
	out = out .. frame:expandTemplate{title='Banner holder', args=bhargs}
	if not args[1] or args[1] == '' then
		out = out .. '[[Category:Pages using WikiProject banner shell without banner templates]]' --talkother
	end
	if args.listas and args.listas ~= '' then
		frame:preprocess('{{DEFAULTSORT:' .. args.listas .. '}}')
	end
	return out
end
return p