assessment_link = nil
end
local fallback_suffix
-- if this is non-nil, this is the suffix which must be used with the class check_fallbacks returned
-- returns the most specific class for which the given category exists
-- FM is unusual: FM > File > NA
-- all other non-article classes: Category > NA, Redirect > NA, etc.
-- performance note: this is expensive whenever BOTH article is false AND class is nonempty
local check_fallbacks = function(class, category)
if article then -- no fallbacks for articles
fallback_suffix = nil
if article or class=='' then -- no fallbacks for non-article classes or the absence of a class
return class
else -- check fallbacks for non-article classes ▼
local new_class = class
▲ -- check fallbacks for non-article classes
local new_classcategory_exists = function(class)
local cat = mw.title.new(cfg.quality.assessment_category:format( class, category .. ' ' .. (article and 'articles' or 'pages')))▼
local category_exists = function(class, new_suffix_style)
return cat.exists and #cat:getContent()>0 -- check if category exists and is not blank▼
▲ local cat = mw.title.new(cfg.quality.assessment_category:format(
class,
category .. ' ' .. (new_suffix_style and 'pages' or 'articles')
))
▲ return cat.exists -- check if category exists
local class_works = function(class)
if category_exists(class, true) then -- try preferred suffix ▼
fallback_suffix = 'pages'
elseif category_exists(class, false) then -- fall back to old suffix
fallback_suffix = 'articles'
return true
else
return false
end
if class=='FM' and not category_exists('FM') then
new_class = 'File' -- fall back to File-class if FM -class doesn'tcategory does not workexist▼
▲ if not category_exists( class, truenew_class) then -- try preferred suffix
new_class = 'NA' -- use NA for non-article pages if classcategory doesn'tdoes not workexist▼
end
if class=='FM' and not class_works('FM') and args.QUALITY_CRITERIA~='custom' then
▲ new_class = 'File' -- fall back to File-class if FM-class doesn't work
end
if not class_works(new_class) and args.QUALITY_CRITERIA~='custom' then
▲ new_class = 'NA' -- use NA for non-article pages if class doesn't work
end
return new_class
end
local class = raw_args.class
end
elseif article_class=='FM' and args.QUALITY_CRITERIA~='custom' then
class = check_fallbacks(article_class, assessment_cat) -- TODO performance?
check_redundant()
elseif not article and class~='FM' then -- article class and local class are both non-article classes
show = true
end
local category = (class=='' and 'Unassessed' or class..'-Class') .. ' ' .. assessment_cat .. ' ' .. (article and 'articles' or 'pages')
-- use "pages" for non-articles if the category exists: temporary transition code
if fallback_suffix then
category = category .. ' ' .. fallback_suffix
elseif not article and mw.title.new('Category:' .. category .. ' pages').exists then
category = category .. ' pages'
else
category = category .. ' articles'
end
if show then -- quality rating shown in banner
local rating
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' and mw.title.new('Category:' .. category .. ' pages').exists then
category = category .. ' pages' -- use "pages" for non-articles if the category exists: temporary transition code
else
category = category .. ' articles'
end
if importance~='NA' then -- display importance rating
local rating = importance=='Unknown' and cfg.importance.not_yet or cfg.importance.rated:format(importance, importance_name)
args[tf_prefix..'NAME']
)
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)
tf_importance = importance
end
tf_importance_category = add_category(tf_importance .. '-' .. importance_name .. ' ' .. tf_assessment_cat .. ' ' .. (importance=='NA' and 'pages' or 'articles'))
if tf_importance=='NA' and mw.title.new('Category:' .. tf_importance_category .. ' pages').exists then
tf_importance_category = tf_importance_category .. ' pages' -- use "pages" for non-articles if the category exists: temporary transition code
else
tf_importance_category = tf_importance_category .. ' articles'
end
end
if args[tf_prefix .. 'TEXT']~='none' then
if yesno(args[tf_prefix..'QUALITY']) and class then
local tf_class = check_fallbacks(class, tf_assessment_cat)
local category = add_category((tf_class=='' and 'Unassessed' or tf_class..'-Class') .. ' ' .. tf_assessment_cat .. ' ' .. (article and 'articles' or 'pages'))
-- use "pages" for non-articles if the category exists: temporary transition code
if fallback_suffix then
category = category .. ' ' .. fallback_suffix
elseif not article and mw.title.new('Category:' .. category .. ' pages').exists then
category = category .. ' pages'
else
category = category .. ' articles'
end
add_category(category)
end
if tf_importance then
add_category(tf_importance_category)
end
if args[tf_prefix..'QII_FORMAT'] then
|