Module:WikiProject banner/sandbox: Difference between revisions

Content deleted Content added
don't use class on inactive
banner shell checks
Line 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 = args.demo_page and demo_page~=true and mw.title.new(args.demo_page) or current_title
local article_class = p.readarticleclass({ignore_subtemplates=true}, title.prefixedText)
if not article_class then -- banner shell exists
local special_chars = {'%', '(', ')', '.', '+', '-', '*', '?', '[', '^', '$'}
local banner_name_escaped = banner_name.text
local page_content = 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 _, userredirect in ipairs(cfg.banner_shell.valid_usersredirects) do
if mw.ustring.find(capture, '^{{%s*' .. redirect .. '%s*[|}].*}}$') then -- found a banner shell
for _, char in ipairs(special_chars) do -- escape each special character
banner_name_escaped = banner_name_escaped:gsub('%'..char, '%%'..char)
capture = capture:gsub('%'..char, '%%'..char)
end
content_without_shell = mw.ustring.gsub(page_content, capture, '') -- remove banner shell content from page content
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('WikiProject banner templates outside the banner shell')
end
else
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
else
add_category(cfg.banner_shell.category.no_banner_shell)
end
end
---------------------------
-- Quality assessment -----
Line 294 ⟶ 334:
end
local class = raw_args.class
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 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
else
add_category(cfg.banner_shell.category.no_banner_shell)
end
end
if class then -- banner gives quality ratings
article_class = article_class and p.class_mask(article_class, title, false, pagetype)