Module:WikiProject banner/sandbox: Difference between revisions

Content deleted Content added
simp
m Removed protection from "Module:WikiProject banner/sandbox"
 
(97 intermediate revisions by 6 users not shown)
Line 45:
return fallback or target
end
end
 
local isarticle = function(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
 
Line 115 ⟶ 104:
elseif pagetype=='disambiguation page' 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
out = class:upper()
elseif class=='list' or class=='sia' or class=='si' or class=='sl' then-- List
out = 'List'
elseif pagetype=='set index article' then
out = 'List'
else
Line 164 ⟶ 153:
page = demo_page,
dab = 'disambiguation page',
sia = 'set index article',
draft = 'draft'
})
local article = pagetype=='article' or pagetype=='set index article'
Line 174 ⟶ 164:
end
local parse_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 "set index article"
return text and text:gsub('_PAGETYPE_', ptype)
end
Line 208 ⟶ 198:
---------------------------
local warning = ''
if not( current_title.isTalkPage orand not demo_page) then
local text = cfg.namespace_warning.text:format(
current_title.talkPageTitle.fullText,
Line 333 ⟶ 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 .. ' ' .. (article and 'articles' or 'pages'))
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
local new_class = class
local category_exists = function(class)
local cat = mw.title.new(cfg.quality.assessment_category:format(class, category .. ' ' .. (article and 'articles' or 'pages')))
return cat.exists and #cat:getContent()>0 -- check if category exists and is not blank
end
if class=='FM' and not category_exists('FM') then
new_class = 'File' -- fall back to File-class if FM category does not exist
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
Line 371:
else
class = p.class_mask(class, title, true, pagetype, article)
end
if not isarticle(class) then -- check fallbacks for non-article classes
local category_exists = function(class)
local cat = mw.title.new(cfg.quality.assessment_category:format(class, assessment_cat .. ' ' .. (article and 'articles' or 'pages')))
return cat.exists and #cat:getContent()>0 -- check if category exists and is not blank
end
if class=='FM' and not category_exists('FM') then
class = 'File' -- fall back to File-class if FM category does not exist
end
if not category_exists(class) then
class = 'NA' -- automatically use NA for non-article pages if category does not exist
end
end
local check_redundant = function()
Line 389 ⟶ 377:
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 class=='' or class==article_class then -- local class matches article class or is blank
class = check_fallbacks(article_class, assessment_cat) -- check fallbacks again now that class may have changed
check_redundant()
elseif class==article_class then -- local class matches article class
check_redundant()
elseif article_class=='' then -- local class defined and no article class defined
show = true
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 not article and not isarticle(class) and class~='FM' then -- article class and local class are both non-article classes
class = check_fallbacks('FM', assessment_cat)
check_redundant()
elseif not article and class~='FM' then -- article class and local class are both non-article classes
check_redundant()
elseif args.QUALITY_CRITERIA=='custom' then -- project uses custom criteria and class differs
Line 405 ⟶ 400:
else -- article class exists and differs from local class
show = 'conflict'
add_category(class .. cfg.banner_shell.conflict.categorycategory2:format(class, article_class))
end
else -- banner shell does not exist
Line 460 ⟶ 455:
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 490 ⟶ 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 550 ⟶ 547:
args[tf_prefix..'NAME']
)
if yesno(args[tf_prefix..'QUALITY']) and class then
local tf_importance
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'], args.IMPORTANCE_SCALE, banner_name, pagetype, class)
Line 556 ⟶ 557:
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 575 ⟶ 578:
and ' ' .. cfg.task_force.importance:format(
wikilink(
':Category:' .. tf_importance .. '-' .. importance_name .. ' ' .. tf_assessment_cat .. ' articles'tf_importance_category,
tf_importance .. '-' .. importance_name
)
Line 602 ⟶ 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 .. ' ' .. (article and 'articles' or 'pages'))
end
if tf_importance then
add_category(tf_importance .. '-' .. importance_name .. ' ' .. tf_assessment_cat .. ' articles')
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 814 ⟶ 810:
:wikitext(wikilink(project_link.prefixedText, project) .. nested_tf_str .. ' ' .. nested_ratings_str)
:done()
---------------------------
-- Default sort -----------
---------------------------
if args.listas then
frame:preprocess('{{DEFAULTSORT:' .. args.listas .. '}}')
if title.namespace~=3 then -- exclude user talk namespace
local success, shell_listas_value = require('Module:Template parameter value').getParameter(
title.prefixedText,
cfg.banner_shell.redirects,
'listas',
{ignore_subtemplates = true, ignore_blank = true}
)
if success and shell_listas_value~='' then
if args.listas==shell_listas_value then -- same value in both (with spacing trimming)
add_category(cfg.banner_shell.category.redundant_listas)
end
else -- listas is blank or not defined in banner shell
add_category(cfg.banner_shell.category.move_listas)
end
end
end
---------------------------
-- Prepare categories -----
Line 888 ⟶ 863:
local category = parent_args.category or args.category or true
local demo_page = parent_args.demo_page
local config, project
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
if parent_args.taskforce then -- split comma-separated list
for taskforce in mw.text.gsplit(parent_args.taskforce, ',%s*') do
parent_args[taskforce] = 'yes'
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
local banner_name = mw.title.new(args.BANNER_NAME or 'Template:WikiProject ' .. (args.PROJECT or 'PROJECT'))
Line 904 ⟶ 898:
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)
Line 918 ⟶ 913:
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