Jump to content

Module:WikiProject banner/templatepage and Module:WikiProject banner/templatepage/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
redeploy fixed template categories and syntax highlighting
 
mNo edit summary
 
Line 13: Line 13:
-- Initialise variables ---
-- Initialise variables ---
---------------------------
---------------------------
local sandbox-- = '/sandbox'
local sandbox = '/sandbox'
local cfg = mw.loadData('Module:WikiProject banner/config' .. (sandbox or ''))
local cfg = mw.loadData('Module:WikiProject banner/config' .. (sandbox or ''))
local cfg_tp = cfg.template_page -- convenient shortcut for template_page configuration settings
local cfg_tp = cfg.template_page -- convenient shortcut for template_page configuration settings
Line 25: Line 25:
local code = parameter and mw.html.create('code')
local code = parameter and mw.html.create('code')
:addClass('tpl-para')
:addClass('tpl-para')
:css('word-break', 'break-word')
:css('word-break', 'break-word') --TODO: add to css page
:wikitext('|' .. parameter .. '=' .. (value or ''))
:wikitext('|' .. parameter .. '=' .. (value or ''))
:done()
:done()
return tostring(code)
return tostring(code)
end
end
Line 344: Line 344:
local list = mw.html.create('ul')
local list = mw.html.create('ul')
for _, missing in ipairs(missing_cats) do
for _, missing in ipairs(missing_cats) do
list:tag('li'):wikitext(missing):done()
list:tag('li')
:wikitext(missing)
:done()
end
end
list:done()
list:done()
Line 417: Line 419:
return pagetype_module{page = title.fullText}
return pagetype_module{page = title.fullText}
end
end

if on_sandbox then
if on_sandbox then
add_tracking(cfg_tp.template_categories.sandbox, true)
add_tracking(cfg_tp.template_categories.sandbox, true)
Line 430: Line 433:
add_tracking(cfg_tp.template_categories.non_standard)
add_tracking(cfg_tp.template_categories.non_standard)
end
end

local template_category = mw.title.new('Category:' .. project_name .. ' templates')
-- List of categories to check
if template_category.exists and pagetype(template_category)~='redirect' then
local category_suffixes = {
table.insert(tracking_cats, wikilink(template_category.fullText, '*'))
'Wikipedia-' .. project_name .. ' collaboration templates',
else
local template_category2 = mw.title.new('Category:' .. project_name)
'Wikipedia-' .. project_name .. ' collaboration',
project_name .. ' templates',
if template_category2.exists and pagetype(template_category2)~='redirect' then
project_name,
table.insert(tracking_cats, wikilink(template_category2.fullText))
}
else

add_tracking({sort_key='E'})
-- Check each category
local found = false
for _, suffix in ipairs(category_suffixes) do
local category_title = mw.title.new('Category:' .. suffix)
if category_title.exists and pagetype(category_title) ~= 'redirect' then
table.insert(tracking_cats, wikilink(category_title.fullText, '*'))
found = true
break
end
end
end

-- If no valid category was found, add tracking with sort key 'E'
if not found then
add_tracking({sort_key = 'E'})
end
end
end
end
Line 519: Line 535:
local list = mw.html.create('ul')
local list = mw.html.create('ul')
for _, missing in ipairs(missing_cats) do
for _, missing in ipairs(missing_cats) do
list:tag('li'):wikitext(missing):done()
list:tag('li')
:wikitext(missing)
:done()
end
end
list:done()
list:done()
Line 538: Line 556:
notice_html = mw.html.create('ul')
notice_html = mw.html.create('ul')
for _, notice in ipairs(notices) do
for _, notice in ipairs(notices) do
notice_html:tag('li'):wikitext(notice):done()
notice_html:tag('li')
:wikitext(notice)
:done()
end
end
notice_list = ' ' .. cfg_tp.notice_text .. tostring(notice_html)
notice_list = ' ' .. cfg_tp.notice_text .. tostring(notice_html)
Line 722: Line 742:
local cat = class..'-Class '..assessment_cat
local cat = class..'-Class '..assessment_cat
return mw.html.create('tr')
return mw.html.create('tr')
:tag('th'):wikitext(input or class):done()
:tag('th')
:wikitext(input or class)
:done()
:tag('td'):attr('rowspan', rowspan or 1):css('text-align', 'center'):wikitext(class_module.icon{class}):done()
:tag('td')
:attr('rowspan', rowspan or 1)
:css('text-align', 'center') --TODO: add to css page
:wikitext(class_module.icon{class})
:done()
:node(class_module._class{class, category=assessment_cat, image='no', rowspan=rowspan or 1})
:node(class_module._class{class, category=assessment_cat, image='no', rowspan=rowspan or 1})
:tag('td'):attr('rowspan', rowspan or 1):wikitext(wikilink(':Category:'..cat)):done()
:tag('td')
:attr('rowspan', rowspan or 1)
:wikitext(wikilink(':Category:'..cat))
:done()
:tag('td')
:tag('td'):attr('rowspan', rowspan or 1):css('text-align', 'right'):wikitext(lang:formatNum(mw.site.stats.pagesInCategory(cat))):done()
:attr('rowspan', rowspan or 1)
:css('text-align', 'right') --TODO: add to css page
:wikitext(lang:formatNum(mw.site.stats.pagesInCategory(cat)))
:done()
end
end
local class_table = mw.html.create('table')
local class_table = mw.html.create('table')
:addClass('wikitable')
:addClass('wikitable')
:tag('tr')
:tag('tr')
:tag('th'):wikitext(cfg.auto_doc.quality._table._input):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table._input)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.icon):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.icon)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.class):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.class)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.category):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.category)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.population):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.population)
:done()
:done()
:done()
for _, class in ipairs{'FA', 'A', 'GA'} do
for _, class in ipairs{'FA', 'A', 'GA'} do
Line 764: Line 807:
table.insert(quality, cfg.auto_doc.quality.not_defined)
table.insert(quality, cfg.auto_doc.quality.not_defined)
local list = mw.html.create('ul')
local list = mw.html.create('ul')
:tag('li'):wikitext(redirects):done()
:tag('li')
:wikitext(redirects)
:done()
:tag('li'):wikitext(dabs):done()
:tag('li')
:wikitext(dabs)
:done()
:done()
:done()
table.insert(quality, tostring(list))
table.insert(quality, tostring(list))
Line 771: Line 818:
table.insert(quality, cfg.auto_doc.quality.deduced)
table.insert(quality, cfg.auto_doc.quality.deduced)
local first_col = function(text)
local first_col = function(text)
return mw.html.create('tr'):tag('th'):wikitext(text):allDone()
return mw.html.create('tr'):tag('th')
:wikitext(text)
:allDone()
end
end
local namespace_table = mw.html.create('table')
local namespace_table = mw.html.create('table')
:addClass('wikitable')
:addClass('wikitable')
:tag('tr')
:tag('tr')
:tag('th'):wikitext(cfg.auto_doc.quality._table.namespace):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.namespace)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.icon):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.icon)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.class):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.class)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.category):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.category)
:done()
:tag('th'):wikitext(cfg.auto_doc.quality._table.population):done()
:tag('th')
:wikitext(cfg.auto_doc.quality._table.population)
:done()
:done()
:done()
local na_rowspan = 3
local na_rowspan = 3
Line 823: Line 882:
local cat = importance..'-' .. 'importance ' .. assessment_cat
local cat = importance..'-' .. 'importance ' .. assessment_cat
return mw.html.create('tr')
return mw.html.create('tr')
:tag('th'):wikitext(importance):done()
:tag('th')
:wikitext(importance)
:done()
:node(frame:expandTemplate{title='Template:Importance', args={importance, category=assessment_cat}})
:node(frame:expandTemplate{title='Template:Importance', args={importance, category=assessment_cat}})
:tag('td'):wikitext(wikilink(':Category:'..cat)):done()
:tag('td')
:wikitext(wikilink(':Category:'..cat))
:done()
:tag('td'):css('text-align', 'right'):wikitext(lang:formatNum(mw.site.stats.pagesInCategory(cat))):done()
:tag('td')
:css('text-align', 'right') --TODO: add to css page
:wikitext(lang:formatNum(mw.site.stats.pagesInCategory(cat)))
:done()
end
end
local imp_table = mw.html.create('table')
local imp_table = mw.html.create('table')
:addClass('wikitable')
:addClass('wikitable')
:tag('tr')
:tag('tr')
:tag('th'):wikitext(imp_doc._table._input):done()
:tag('th')
:wikitext(imp_doc._table._input)
:done()
:tag('th'):wikitext(imp_doc._table.importance):done()
:tag('th')
:wikitext(imp_doc._table.importance)
:done()
:tag('th'):wikitext(imp_doc._table.category):done()
:tag('th')
:wikitext(imp_doc._table.category)
:done()
:tag('th'):wikitext(imp_doc._table.population):done()
:tag('th')
:wikitext(imp_doc._table.population)
:done()
:done()
:done()
for _, importance in ipairs(imp_doc.classes) do
for _, importance in ipairs(imp_doc.classes) do