Module:WikiProject banner/sandbox: Difference between revisions

Content deleted Content added
simplify if/else tree
m Removed protection from "Module:WikiProject banner/sandbox"
 
(261 intermediate revisions by 8 users not shown)
Line 1:
require('strict')
local p = {}
local sandbox = '/sandbox' -- BE SURE TO COMMENT OUT this definition when deploying to live
local cfg = mw.loadData('Module:WikiProject banner/config' .. (sandbox or ''))
local auxiliary = cfg.auxiliary_module .. (sandbox or '')
Line 21:
end
end
 
local display_error = function(text)
local span = mw.html.create('div')
Line 46 ⟶ 47:
end
 
local isarticleimportance_mask = function(raw_importance, scale, banner_name, pagetype, class)
local article = true
for _,v in ipairs(cfg.quality.non_article_classes) do
if class==v then -- class matches one of the non-article classes
article = false
break
end
end
return article
end
 
---------------------------
-- Importance mask --------
---------------------------
local importance
local importance_mask = function(raw_importance, class, scale, banner_name)
if scale=='inline' then -- pass importance without change
local importance
importance = raw_importance
if scale=='inline' then -- pass importance without change
elseif scale=='subpage' then
importance = raw_importance
local custom_mask = banner_name:subPageTitle('importance')
elseif scale=='subpage' then
if custom_mask.exists and #custom_mask:getContent()>1 then -- pass to custom importance mask
local custom_mask = banner_name:subPageTitle('importance')
importance = mw.text.trim(frame:expandTemplate{
if custom_mask.exists and #custom_mask:getContent()>1 then -- pass to custom importance mask
title = custom_mask.prefixedText,
importance = mw.text.trim(frame:expandTemplate{
args = {
title = custom_mask.prefixedText,
argsimportance = {importance=raw_importance or '¬', class=class}
class = class,
})
pagetype = pagetype
}
})
end
elseif raw_importance then-- standard importance scale
importance = cfg.importance.na
if pagetype=='article' or pagetype=='set index article' or pagetype=='redirect' or pagetype=='draft' then
local mask = cfg.importance.mask
if mask[raw_importance:lower()] then -- valid importance specified
importance = mask[raw_importance:lower()]
elseif pagetype=='article' or pagetype=='set index article' then -- unspecified or invalid importance, use "Unknown" for articles
importance = cfg.importance.unknown
end
else
importance = frame:expandTemplate{
title = 'Template:Importance mask',
args = {raw_importance or '¬', class=class}}
end
end
if importance=='¬' then
return importance = nil
end
return importance
end
 
Line 95 ⟶ 92:
-- otherwise returns class parameter
end
p.class_mask = function(class, title, FQS, pagetype, article)
local resolveFQSgrade = function(class)
return FQS and lang:ucfirst(class) or 'NA'
Line 103 ⟶ 100:
local ns = title.namespace
class = class:match('^%s*(.-)%s*$'):lower()
-- Define a table that maps namespace IDs to category names
if pagetype=='redirect' or pagetype=='soft redirect' then
out = resolveFQSgrade('redirect')
elseif pagetype=='disambiguation page' or class=='dab' or class=='disambig' or class=='disambiguation' or class=='disamb' then
out = resolveFQSgrade('disambig')
elseif article or pagetype=='article' or pagetype=='set index article' then
if classpagetype=='start'set orindex class=='stubarticle' then -- Ucfirst
out = 'List'
elseif class=='start' or class=='stub' then -- Ucfirst
out = lang:ucfirst(class)
elseif class=='b' or class=='c' or class=='fa' or class=='fl' or class=='a' or class=='ga' then -- Upper-case
Line 119 ⟶ 117:
end
elseif ns==7 or ns==711 then -- File talk
if class=='fm' and FQS then
out = 'FM'
else
Line 125 ⟶ 123:
end
else
local grade = cfg.quality.ns_to_class[ns] or 'NA'
local ns_to_category = {
out = resolveFQSgrade(grade)
[15] = 'category', -- Category talk
[101] = 'portal', -- Portal talk
[11] = 'template', -- Template talk
[829] = 'template', -- Template talk (same as above)
[5] = 'project', -- Wikipedia talk
[119] = 'draft' -- Draft talk
}
local category = ns_to_category[ns] or 'NA'
out = resolveFQSgrade(category)
end
return out
Line 144 ⟶ 134:
end
 
local bubble = function(text, colourconflict, conflictstyle)
local out = mw.html.create('span')
:addClass('wpb-header-bubbles')
:addClass(style)
:css('background', colour)
:cssaddClass('border', conflict and cfg.banner_shell.'conflict.border' or (cfg.quality.border..' '..colour)nil)
:wikitext(text)
return tostring(out)
end
 
p._main = function(args, raw_args, demodemo_page, banner_name, inactive)
---------------------------
-- Initialise parameters --
Line 160 ⟶ 150:
local project_name = args.PROJECT_NAME or 'WikiProject ' .. project
local project_link = mw.title.new(args.PROJECT_LINK or 'Wikipedia:' .. project_name)
local pagetype = demo and not args.demo_page==true and 'article' or require('Module:Pagetype' .. (sandbox or ''))._main({
page = args.demo_page,
dab = 'disambiguation page',
sia = 'set index article',
draft = 'draft'
})
local article = pagetype=='article' or pagetype=='set index article'
local rows, nested_ratings, task_forces, notes, categories, taskforce_categories = {}, {}, {}, {}, {}, {}
local add_category = function(category, key)
Line 170 ⟶ 163:
end
end
local parse_textparse_pt = function(text) -- function to replace _PAGETYPE_ with the actual page type
local ptype = article and 'article' or pagetype -- display "article" for articles otherwise page type
return text and text:gsub('_PAGETYPE_', pagetype)
return text and text:gsub('_PAGETYPE_', ptype)
end
for arg_name, arg_value in pairs(args) do
Line 192 ⟶ 186:
table.sort(task_forces, function (x, y) return tonumber(x) < tonumber(y) end)
table.sort(notes, function (x, y) return tonumber(x) < tonumber(y) end)
local assessment_category = function(cat, name)
local warning = ''
if cat then
return cat:gsub(' articles', '') -- remove "articles" from category
else
return name or ''
end
end
local assessment_cat = assessment_category(args.ASSESSMENT_CAT, project)
---------------------------
-- Location warning -------
---------------------------
local warning = ''
local show_namespace_warning = not (current_title.isTalkPage or demo)
if not current_title.isTalkPage and not demo_page then
if show_namespace_warning then
local text = cfg.namespace_warning.text:format(
pagetype,
current_title.talkPageTitle.fullText,
parameter_format('category', 'no')
Line 213:
image = '[[File:' .. cfg.namespace_warning.image .. '|40px]]',
type = cfg.namespace_warning.type_,
text = parse_pt(text)
})
if not current_title.subjectPageTitle:inNamespace(2) then
Line 236:
-- Primary image/text -----
---------------------------
local assessment_cat = args.ASSESSMENT_CAT or project .. ' articles'
local primary_image = function(image_name, size)
local cell = mw.html.create('td')
if image_name and image_name~='' then
cell:addClass('mbox-image wpb-image')
:wikitext(image(image_name, size, cfg.image.alt))
else
cell:addClass('mbox-empty-cell')
Line 249 ⟶ 248:
local portal = args.PORTAL
local portal_box = portal and frame:expandTemplate{title='Portal', args={portal}} or ''
local main_text = portal_box .. (parse_textparse_pt(args.MAIN_TEXT) or cfg.main_text:format(
pagetype,
project_link.prefixedText,
project_name,
Line 258 ⟶ 256:
local image_left_size = args.IMAGE_LEFT_SIZE or cfg.image.default_size
local metadata = function(class, data)
return mw.html.create('span')
:addClass(class)
:wikitext(data)
end
local text_cell = mw.html.create('td')
:addClass('mbox-text')
:wikitext(main_text)
:tag('span')
:addClass('metadata wpb-metadata')
:node(metadata('wpb-project', project))
:node(metadata('wpb-project_link', project_link.prefixedText))
Line 274 ⟶ 275:
:node(primary_image(args.IMAGE_RIGHT, args.IMAGE_RIGHT_SIZE or cfg.image.default_size))
table.insert(rows, primary_row)
---------------------------
-- Banner shell checks ----
---------------------------
local title = demo_page and demo_page~=true and mw.title.new(demo_page) or current_title
local article_class = p.readarticleclass({ignore_subtemplates=true}, title.prefixedText)
if article_class then -- banner shell exists
local special_chars = '([%%%(%)%.%+%-%*%?%[%]%^%$])'
local banner_name_escaped = banner_name.text
local page_content = require('Module:Wikitext Parsing').PrepareText(title:getContent()) -- get content of current page
local content_without_shell
for capture in mw.ustring.gmatch(page_content, '%b{}') do -- look for possible templates on page
for _, redirect in ipairs(cfg.banner_shell.redirects) do
if mw.ustring.find(capture, '^{{%s*' .. redirect .. '%s*[|}].*}}$') then -- found a banner shell
banner_name_escaped = banner_name_escaped:gsub(special_chars, '%%%1') -- escape each special character
capture = capture:gsub(special_chars, '%%%1')
content_without_shell = mw.ustring.gsub(page_content, capture, '') -- remove banner shell content from page content
end
if content_without_shell then break end
end
if content_without_shell then break end
end
local template_outside_shell
if content_without_shell and mw.ustring.find(content_without_shell, '{{%s*' .. banner_name_escaped .. '%s*[|}]') then -- found banner template outside of the shell
add_category(cfg.banner_shell.category.outside_shell)
end
else -- no banner shell on page
if article then
add_category(cfg.banner_shell.category.no_banner_shell_articles)
elseif title.namespace==3 then --User talk namespace
for _, user in ipairs(cfg.banner_shell.valid_users) do
if string.find(title.rootText, user) then
add_category(cfg.banner_shell.category.no_banner_shell)
end
end
elseif title.namespace~=2 then --User namespace
add_category(cfg.banner_shell.category.no_banner_shell)
end
end
---------------------------
-- Quality assessment -----
Line 284 ⟶ 323:
assessment_link = nil
end
local check_existscheck_fallbacks = function(class, assessment_catcategory) -- check if category exists and is not blank
if article or args.QUALITY_CRITERIA=='custom' then -- no fallbacks for articles or projects with custom quality scales
if not isarticle(class) then
local cat = mw.title.new('Category:' .. class .. '-Class' .. ' ' .. assessment_cat)
return (cat.exists and #cat:getContent()>0) and class or 'NA' -- automatically use NA for non-article pages if category does not exist
else
return class
else -- check fallbacks for non-article classes
end
local new_class = class
end
local classcategory_exists = raw_args.function(class)
local cat = mw.title.new(cfg.quality.assessment_category:format(class, category .. ' ' .. (article and 'articles' or 'pages')))
local title = args.demo_page and mw.title.new(args.demo_page) or current_title
return cat.exists and #cat:getContent()>0 -- check if category exists and is not blank
local article_class = p.readarticleclass({ignore_subtemplates=true}, title.prefixedText)
if not article_class then
if pagetype=='article' then
add_category(cfg.banner_shell.category.no_banner_shell_articles)
elseif title.namespace==3 then --User talk namespace
for _, user in ipairs(cfg.banner_shell.valid_users) do
if string.find(title.rootText, user) then
add_category(cfg.banner_shell.category.no_banner_shell)
end
end
if class=='FM' and not category_exists('FM') then
else
new_class = 'File' -- fall back to File-class if FM category does not exist
add_category(cfg.banner_shell.category.no_banner_shell)
end
if not category_exists(new_class) then
new_class = 'NA' -- use NA for non-article pages if category does not exist
end
return new_class
end
end
local class = raw_args.class
if class then -- banner gives quality ratings
article_class = article_class and p.class_mask(article_class, title, false, pagetype, article)
local show_quality, conflict = true, false
if args.QUALITY_CRITERIA=='custom' then -- project has opted out of standard assessment scale and uses a custom mask
local custom_mask = banner_name:subPageTitle('class')
if custom_mask.exists and #custom_mask:getContent()>1 then
raw_args.demo_page = args.demo_page -- send demo_page to custom mask
class = mw.text.trim(frame:expandTemplate{
title = custom_mask.prefixedText,
Line 337 ⟶ 370:
end
else
class = p.class_mask(class, title, true, pagetype, article)
end
local check_redundant = function()
if raw_args.class~='' and args.QUALITY_CRITERIA~='custom' then -- banner has a non-blank class value which is ignored
add_category(cfg.banner_shell.category.redundant_class)
end
end
class = check_fallbacks(class, assessment_cat)
local show = false -- hide quality class in project banner by default
if article_class then -- banner shell exists
if article_classclass=='' then -- no articlelocal class definedis blank
class = check_fallbacks(article_class, assessment_cat) -- check fallbacks again now that class may have changed
if class=='' then -- local class also does not exist, check whether any other class parameters are defined inside the shell
check_redundant()
local classparam = p.readarticleclass({ignore_blank=true, only_subtemplates=true}, title.prefixedText)
ifelseif classparamclass==''article_class then -- nolocal class parametersmatches defined,article display as globally unassessedclass
check_redundant()
show_quality = false -- hide quality class in project banner
elseif article_class=='' then -- local class defined and no article class defined
end
elseifshow not= demo thentrue
add_category(cfg.banner_shell.category.no_quality_rating)
if args.QUALITY_CRITERIA~='custom' then
warning = warning .. display_error(cfg.banner_shell.piqa_warning)
end
elseif article_class=='FM' and args.QUALITY_CRITERIA~='custom' then
elseif class=='' or class==article_class then -- local class matches article class or is blank
class = check_fallbacks('FM', assessment_cat)
show_quality = false -- hide quality class in project banner
check_redundant()
class = article_class
elseif not article and class~='FM' then -- article class and local class are both non-article classes
if raw_args.class~='' and args.QUALITY_CRITERIA~='custom' then
check_redundant()
add_category(cfg.banner_shell.category.redundant_class)
elseif args.QUALITY_CRITERIA=='custom' then -- project uses custom criteria and class differs
end
show = true -- show quality class in project banner
elseif (article_class=='NA') and not isarticle(class) then -- article class and local class are both non-article classes
show_quality = false
else -- article class exists and differs from local class
show = 'conflict'
if args.QUALITY_CRITERIA~='custom' then
add_category(cfg.banner_shell.conflict.category2:format(class, article_class))
conflict = true
add_category(cfg.banner_shell.conflict.category)
end
end
elseif class~='' and not demo then
warning = warning .. display_error(cfg.banner_shell.no_banner_shell_warning)
end
if not isarticle(class) then
local cat = mw.title.new(cfg.quality.assessment_category:format(class, assessment_cat))
if not (cat.exists and #cat:getContent()>0) then --check if category exists and is not blank
class = 'NA' -- automatically use NA for non-article pages if category does not exist
end
else -- banner shell does not exist
show = true
end
local category = (class=='' and 'Unassessed' or class..'-Class') .. ' ' .. assessment_cat .. ' ' .. (article and 'articles' or 'pages')
if show_qualityshow then -- quality rating shown in banner
local rating
if pagetype=='article' then
rating = class=='' and cfg.quality.not_yet or cfg.quality.rated:format(class)
else
Line 385 ⟶ 417:
and cfg.quality.project_scale:format(wikilink(assessment_link..'#'..lang:ucfirst(cfg.quality.name), cfg.quality.name))
or cfg.quality.default_scale
local quality_rating = show=='conflict '
and cfg.banner_shell.conflict.text
or cfg.quality.rating:format(pagetype, rating, scale)
local colourcssClass = cfg'class-' .quality.colour[ (class]=='' and 'unassessed' or cfg.quality.colour.defaultclass:lower())
local class_row = mw.html.create('tr')
:tag('td')
:addClass('assess')
:addClass('assess-' .. classcssClass)
:addClass(show=='conflict' and 'conflict' or nil)
:css('background', colour)
:wikitext(wikilink(':Category:' .. category, class=='' and '???' or class))
:css('border', conflict and cfg.banner_shell.conflict.border or (cfg.quality.border..' '..colour))
:done()
:tag('td')
:addClass('mbox-text')
:attr('colspan', '2')
:wikitext(parse_pt(quality_rating))
:done()
table.insert(rows, class_row)
Line 404 ⟶ 437:
nested_ratings,
1,
bubble(class=='' and 'Unassessed' or (class..'‑class'), colourshow=='conflict', conflictcssClass)
)
end
Line 413 ⟶ 446:
end
if raw_args.b1 or raw_args.b2 or raw_args.b3 or raw_args.b4 or raw_args.b5 or raw_args.b6 then
local b_checklist = require(auxiliary).b_checklist(args, raw_args, class, demodemo_page, assessment_link)
table.insert(rows, b_checklist)
end
Line 419 ⟶ 452:
-- Importance assessment --
---------------------------
local importance = importance_mask(raw_args.importance or raw_args.priority, class, args.IMPORTANCE_SCALE, banner_name, pagetype, class)
local importance_name = args.IMPN or (raw_args.priority and 'priority' or cfg.importance.default_name)
if importance then -- banner gives importance ratings
local category = importance .. '-' .. importance_name .. ' ' .. assessment_cat .. ' ' .. (importance=='NA' and 'pages' or 'articles')
if importance~='NA' then -- display importance rating
local rating = importance=='Unknown' and cfg.importance.not_yet or cfg.importance.rated:format(importance, importance_name)
Line 429 ⟶ 462:
and cfg.importance.project_scale:format(assessment_link..'#'..lang:ucfirst(scale_name), scale_name)
or cfg.importance.default_scale
local importance_rating = parse_pt(cfg.importance.rating:format(pagetype, rating, scale))
local colourcssClass = 'import-' cfg.importance.colour[importance] or cfg.importance.colour.default:lower()
local importance_row = mw.html.create('tr')
:tag('td')
:addClass('assess')
:addClass('import'cssClass)
:addClass('import-' .. importance)
:css('background', colour)
:wikitext(wikilink(':Category:' .. category, importance=='Unknown' and '???' or importance))
:done()
Line 448 ⟶ 479:
table.insert(
nested_ratings,
bubble(importance .. '‑' .. importance_name, colourfalse, cssClass)
)
end
Line 454 ⟶ 485:
add_category(category)
end
page_assessment(project,if class, or importance) then
page_assessment(project, class, importance)
end
if args.HOOK_IMPORTANCE then
table.insert(rows, args.HOOK_IMPORTANCE)
end
if args.QII_FORMAT then
add_category(require(auxiliary).quality_importance_insection(args, class, importance, importance_name, assessment_cat, article))
end
---------------------------
Line 477 ⟶ 510:
:css('min-width', image_left_size)
:tag('span')
:addClass('wpb-iefix')
:wikitext('/&nbsp;')
:done() --TO FIX IE
:done()
:tag('td'):done()
Line 510 ⟶ 543:
for _, k in ipairs(task_forces) do
local tf_prefix = 'TF_' .. k .. '_'
local tf_assessment_cat = assessment_category(
args[tf_prefix..'ASSESSMENT_CAT'] or (,
args[tf_prefix..'NAME'] or '')..' articles'
)
local tf_importance
if yesno(args[tf_prefix..'QUALITY']) and class then
local tf_class = check_fallbacks(class, tf_assessment_cat)
add_category((tf_class=='' and 'Unassessed' or tf_class..'-Class') .. ' ' .. tf_assessment_cat .. ' ' .. (article and 'articles' or 'pages'))
end
local tf_importance, tf_importance_category
if raw_args['tf '..k..' importance'] then
tf_importance = importance_mask(raw_args['tf '..k..' importance'], class, args.IMPORTANCE_SCALE, banner_name, pagetype, class)
if tf_importance=='Unknown' and yesno(args.INHERIT_IMPORTANCE) then
tf_importance = importance
end
tf_importance_category = tf_importance .. '-' .. importance_name .. ' ' .. tf_assessment_cat .. ' ' .. (tf_importance=='NA' and 'pages' or 'articles')
add_category(tf_importance_category)
end
if args[tf_prefix .. 'TEXT']~='none' then
Line 530 ⟶ 572:
:gsub('_LINK_', args[tf_prefix .. 'LINK'] or '')
:gsub('_IMPORTANCE_', tf_importance or '')
:gsub('_PAGETYPE_', pagetype)
else
local tf_importance_text = tf_importance
Line 536 ⟶ 577:
and tf_importance~='Unknown'
and ' ' .. cfg.task_force.importance:format(
wikilink(
wikilink(':Category:' .. tf_importance .. '-' .. importance_name .. ' ' .. tf_assessment_cat, tf_importance .. '-' .. importance_name)
':Category:' .. tf_importance_category,
tf_importance .. '-' .. importance_name
)
) or ''
text = portal .. cfg.task_force.text:format(
pagetype,
wikilink(args[tf_prefix .. 'LINK'], args[tf_prefix .. 'NAME']),
tf_importance_text
Line 556 ⟶ 599:
:addClass('mbox-text')
:attr('colspan','2')
:wikitext(parse_pt(text))
:done()
table.insert(taskforce_output, taskforce)
Line 562 ⟶ 605:
if args[tf_prefix..'HOOK'] then
table.insert(taskforce_output, args[tf_prefix..'HOOK'])
end
if yesno(args[tf_prefix..'QUALITY']) and class then
local tf_class = check_exists(class, tf_assessment_cat)
add_category((tf_class=='' and 'Unassessed' or tf_class..'-Class') .. ' ' .. tf_assessment_cat)
end
if tf_importance then
add_category(tf_importance .. '-' .. importance_name .. ' ' .. tf_assessment_cat)
end
if args[tf_prefix..'QII_FORMAT'] then
add_category(require(auxiliary).quality_importance_insection(args, class, tf_importance, importance_name, tf_assessment_cat, article, tf_prefix))
end
if args[tf_prefix..'NAME'] then
Line 605 ⟶ 641:
add_category(note_args.category2, sort)
if note_args.text then
local note_image = image(
note_args.image_name,
note_args.size or note_default_size,
cfg.note.icon_alt,
'center')
)
local new_note = mw.html.create('tr')
:tag('td')
Line 614 ⟶ 655:
:addClass('mbox-text')
:attr('colspan', '2')
:wikitext(parse_pt(note_args.text))
:done()
table.insert(note_output, new_note)
Line 620 ⟶ 661:
local icon = mw.html.create('span')
:addClass('wpb-header-bubbles')
:wikitext('[[File:' .. note_args.image_name .. '|' .. cfg.note.header_icon .. '|' .. parse_pt(note_args.text) .. '|link=|alt=]]')
table.insert(nested_ratings, tostring(icon))
end
Line 635 ⟶ 676:
local auto_cat = args.AUTO_ASSESS_CAT or cfg.auto.default_cat:format(project)
local auto_text = cfg.auto.assessed:format(
pagetype,
cfg.auto[auto], -- method of automatic assessment
parameter_format('auto')
Line 658 ⟶ 698:
local attention_cat = args.ATTENTION_CAT or cfg.attention.default_cat:format(project)
render_note{
text = cfg.attention.text:format(pagetype),
image_name = cfg.attention.icon,
category = attention_cat
Line 666 ⟶ 706:
local infobox_cat = args.INFOBOX_CAT or cfg.infobox.default_cat:format(project)
render_note{
text = cfg.infobox.text:format(pagetype),
image_name = cfg.infobox.icon,
category = infobox_cat
Line 674 ⟶ 714:
local note_prefix = 'NOTE_' .. k .. '_'
render_note{
text = parse_textparse_pt(args[note_prefix..'TEXT']),
image_name = args[note_prefix..'IMAGE'],
size = args[note_prefix..'SIZE'],
Line 681 ⟶ 721:
end
if yesno(args['image-needed'], true) then
local image_needed_args = require(auxiliary).image_needed(args, pagetype)
render_note(image_needed_args)
end
if yesno(args['collaboration-candidate'], true) or yesno(args['collaboration-current'], true) or yesno(args['collaboration-past'], true) then
local collaboration_args = require(auxiliary).collaboration(args, pagetype, current_title)
render_note(collaboration_args.candidate)
render_note(collaboration_args.current)
Line 732 ⟶ 772:
:tag('td')
:attr('colspan','3')
:wikitext(parse_textparse_pt(args.BOTTOM_TEXT))
:done()
table.insert(rows, bottom_text)
Line 765 ⟶ 805:
:addClass('wpb-header-icon')
:wikitext(image(args.IMAGE_LEFT, cfg.image.header_size, cfg.image.alt))
:done()
:tag('td')
:addClass('wpb-header-combined')
:wikitext(wikilink(project_link.prefixedText, project) .. nested_tf_str .. ' ' .. nested_ratings_str)
:done()
---------------------------
-- Prepare categories -----
---------------------------
local categories_formatted = ''
if args.demo_page and demo_page~=true then -- for testing purposes
local category_list = mw.html.create('ul')
for _, cat in ipairs(categories) do
Line 786 ⟶ 826:
:node(category_list)
categories_formatted = tostring(category_box)
elseif not demodemo_page then
local categories_linked = {}
for _, cat in ipairs(categories) do
Line 803 ⟶ 843:
local banner = mw.html.create('table')
:addClass('tmbox tmbox-notice mw-collapsible innercollapse wpb wpb-table')
:addClass(inactive and cfg.statusinactive.inactive_classclass or nil)
:node(header_row)
:tag('tr')
Line 811 ⟶ 851:
:node(banner_rows)
:allDone()
local tstyle = frame:extensionTag('templatestyles', '', {src='Module:Message box/tmbox.css'}) ..
if args.listas then
frame:preprocess('{{DEFAULTSORT:' .. args.listas .. '}}')
end
local tstyle = frame:extensionTag ('templatestyles', '', {src='Module:Message box/tmbox.css'}) ..
frame:extensionTag ('templatestyles', '', {src = 'Module:WikiProject banner' .. (sandbox or '') .. '/styles.css'})
return warning .. tstyle .. tostring(banner) .. categories_formatted, note_count, #taskforce_output, assessment_link
end
 
local parameter_checkinitialise = function(frameargs, banner_nameraw_args, project_nameinactive_status)
---------------------------
-- UnknownInitialise parametersarguments -----
---------------------------
local parent_args = args_module.getArgs(frame, {parentOnly = true})
local category = parent_args.category or args.category or true
local parameters = {}
local demo_page = parent_args.demo_page
for parameter in banner_name:getContent():gmatch('{{{([^|}]+)') do
local config, project
table.insert(parameters, parameter)
if args.project then -- check for config page
project = args.project
local config_file = mw.title.new('Template:WikiProject ' .. args.project .. '/config')
if config_file.exists then
config = mw.loadJsonData(config_file.fullText)
else
return nil
end
end
if config then -- use config file
parameters.preview = cfg.unknown_parameters.preview:format(wikilink(banner_name.fullText))
if parent_args.taskforce then -- split comma-separated list
local unknown_category = cfg.unknown_parameters.tracking:format(project_name)
for taskforce in mw.text.gsplit(parent_args.taskforce, ',%s*') do
if not mw.title.new(unknown_category).exists then
parent_args[taskforce] = 'yes'
unknown_category = cfg.unknown_parameters.default
end
end
args, raw_args = require(auxiliary).map_config(config, parent_args) -- map parameters from config page
args.PROJECT = project
end
local on_template_page = false
parameters.unknown = unknown_category and '[[' .. unknown_category .. '|_VALUE_]]' or ''
local banner_name = mw.title.new(args.BANNER_NAME or 'Template:WikiProject ' .. (args.PROJECT or 'PROJECT'))
return require('Module:Check for unknown parameters')._check(parameters, parent_args)
if not demo_page then
end
if yesno(category, true) then
 
on_template_page = current_title.rootPageTitle==banner_name.rootPageTitle
local initialise = function(args, raw_args, inactive_status)
args.demo_page = args_module.getArgs(frame, {parentOnly = true}).demo_page
local project_name = args.PROJECT_NAME or 'WikiProject ' .. (args.PROJECT or 'PROJECT')
local banner_name = mw.title.new(args.BANNER_NAME or 'Template:WikiProject ' .. (args.PROJECT or 'PROJECT'))
local demo = not yesno(args.category or true, true) or args.demo_page
local on_template_page = not demo and current_title.rootPageTitle==banner_name.rootPageTitle
local unknown_parameters = banner_name.exists and not demo and parameter_check(frame, banner_name, project_name) or ''
if on_template_page then
local templatepage = require('Module:WikiProject banner/templatepage' .. (sandbox or '')).templatepage
return templatepage(args, raw_args, inactive_status)
else
demo_page = true
return unknown_parameters
.. p._main(args, raw_args, demo or inactive_status, banner_name, inactive_status and true or false), nil -- nil to disregard subsequent returned values
end
end
local project_name = args.PROJECT_NAME or 'WikiProject ' .. (args.PROJECT or 'PROJECT')
local unknown_parameters = ''
if banner_name.exists and not demo_page then -- check for unknown parameters
local parameters = {}
for parameter in banner_name:getContent():gmatch('{{{([^|}]+)') do
table.insert(parameters, parameter)
end
parameters.showblankpositional = "1"
local check_for_unknown = require('Module:Check for unknown parameters')._check
local unknowns = check_for_unknown(parameters, parent_args)
if unknowns and unknowns~='' then -- there are some unknown parameters
parameters.preview = cfg.unknown_parameters.preview:format(wikilink(banner_name.fullText))
local unknown_category = cfg.unknown_parameters.tracking:format(project_name)
if not mw.title.new(unknown_category).exists then
unknown_category = cfg.unknown_parameters.default
end
parameters.unknown = unknown_category and '[[' .. unknown_category .. '|_VALUE_]]' or ''
unknown_parameters = check_for_unknown(parameters, parent_args)
end
end
if on_template_page then
local templatepage = require('Module:WikiProject banner/templatepage' .. (sandbox or '')).templatepage
return templatepage(args, raw_args, inactive_status, config)
else
return unknown_parameters
.. p._main(args, raw_args, demo_page, banner_name, inactive_status and true or false), nil -- nil to disregard subsequent returned values
end
end
 
Line 865 ⟶ 932:
local project_name = args.PROJECT_NAME or 'WikiProject ' .. (args.PROJECT or 'PROJECT')
local project_link = mw.title.new(args.PROJECT_LINK or 'Wikipedia:' .. project_name)
local _status = cfg.inactive.status[args.PROJECT_STATUS] or cfg.statusinactive.default_inactivedefault
local main_text = cfg.inactive.text:format(
'_PAGETYPE_',
project_link.prefixedText,
project_name,
_status
)
return initialise({
{
PROJECT = args.PROJECT,
BANNER_NAME = args.BANNER_NAME,
Line 881 ⟶ 948:
substcheck = args.substcheck,
category = args.category
}, {
{
class = frame.args.class,
substcheck = '' -- to prevent warning on templatepage
}, _status
_status
)
end