Module:WikiProject banner/auxiliary and Module:WikiProject banner/auxiliary/sandbox: Difference between pages
Appearance
(Difference between pages)
Tungstenchan (talk | contribs) m Text replacement - "BattleTechWiki" to "BattleIntelligence" |
imported>Deadfire Created page with "require('strict') local p = {} local sandbox = '/sandbox' local cfg = mw.loadData('Module:WikiProject banner/config' .. (sandbox or '')) local yesno = require('Module:Yesno')..." |
||
| Line 1: | Line 1: | ||
require('strict') | require('strict') | ||
local p = {} | local p = {} | ||
local 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 yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
| Line 20: | Line 20: | ||
local scale = args.QUALITY_CRITERIA=='custom' and assessment_link and assessment_link..'#'..lang:ucfirst(cfg.quality.name) | local scale = args.QUALITY_CRITERIA=='custom' and assessment_link and assessment_link..'#'..lang:ucfirst(cfg.quality.name) | ||
or cfg.b_checklist.default_scale | or cfg.b_checklist.default_scale | ||
local text = | local text = cfg.b_checklist.text:format( | ||
parameters_used and cfg.b_checklist.checked or cfg.b_checklist.not_checked, | parameters_used and cfg.b_checklist.checked or cfg.b_checklist.not_checked, | ||
scale | scale | ||
| Line 30: | Line 29: | ||
local b = raw_args['b'..i] | local b = raw_args['b'..i] | ||
if b and b~='unused' then -- crtierion in use | if b and b~='unused' then -- crtierion in use | ||
b = cfg.b_checklist.mask[ | b = cfg.b_checklist.mask[b:lower()] or cfg.b_checklist.mask.default | ||
local image = '[[File:' .. cfg.b_checklist.icon[b] .. '.svg|16x16px|link=|alt=]]' | local image = '[[File:' .. cfg.b_checklist.icon[b] .. '.svg|16x16px|link=|alt=]]' | ||
local failed_cat = args['B'..i..'_CAT'] | local failed_cat = args['B'..i..'_CAT'] | ||
| Line 49: | Line 48: | ||
local new_syntax = mw.html.create('li') | local new_syntax = mw.html.create('li') | ||
:addClass('nowrap') | :addClass('nowrap') | ||
:wikitext( | :wikitext(cfg.b_checklist.syntax.prompt:format( | ||
tostring(i), | tostring(i), | ||
cfg.b_checklist.criteria[i] .. string.rep(' ', cfg.b_checklist.syntax.max_width-#cfg.b_checklist.criteria[i]) | cfg.b_checklist.criteria[i] .. string.rep( | ||
' ', | |||
cfg.b_checklist.syntax.max_width-#cfg.b_checklist.criteria[i] | |||
) | |||
)) | |||
:done() | :done() | ||
table.insert(syntax, tostring(new_syntax)) | table.insert(syntax, tostring(new_syntax)) | ||
| Line 61: | Line 62: | ||
if not parameters_used then | if not parameters_used then | ||
prompt = mw.html.create('span') | prompt = mw.html.create('span') | ||
:wikitext( | :wikitext(cfg.b_checklist.syntax.text:format(tostring(mw.title.getCurrentTitle():fullUrl({action = 'edit'})))) | ||
:tag('ul') | :tag('ul') | ||
:css('font-size', '88%'):css('margin', '0px'):css('font-family', 'monospace, sans-serif'):css('padding', '1em'):css('border', '1px dashed #2f6fab') | :css('font-size', '88%') | ||
:css('background-color', '#f9f9f9'):css('line-height', '1.1em'):css('list-style', 'none') | :css('margin', '0px') | ||
:css('font-family', 'monospace, sans-serif') | |||
:css('padding', '1em') | |||
:css('border', '1px dashed #2f6fab') | |||
:css('background-color', '#f9f9f9') | |||
:css('line-height', '1.1em') | |||
:css('list-style', 'none') | |||
:node(table.concat(syntax)) | :node(table.concat(syntax)) | ||
:done() | :done() | ||
| Line 76: | Line 80: | ||
:tag('td') | :tag('td') | ||
:addClass('assess-b') | :addClass('assess-b') | ||
:css('padding-bottom', '5px') --TODO add to styles.css | |||
:wikitext(cfg.b_checklist.image) | :wikitext(cfg.b_checklist.image) | ||
:done() | :done() | ||
| Line 84: | Line 88: | ||
:addClass('plainlinks mw-collapsible mw-collapsed') | :addClass('plainlinks mw-collapsible mw-collapsed') | ||
:tag('tr') | :tag('tr') | ||
:tag('th'):addClass('wpb-collapsed-head mbox-text'):attr('colspan', '3'):css('font-weight', 'normal'):wikitext(text):done() | :tag('th') | ||
:tag('td'):css('min-width', '3em'):done() -- empty cell for show/hide toggle | :addClass('wpb-collapsed-head mbox-text') | ||
:attr('colspan', '3') | |||
:css('font-weight', 'normal') | |||
:wikitext(text):done() | |||
:tag('td') | |||
:css('min-width', '3em') | |||
:done() -- empty cell for show/hide toggle | |||
:done() | :done() | ||
:tag('tr') | :tag('tr') | ||
:tag('td'):css('font-size', '90%'):node(criteria):done() | :tag('td') | ||
:tag('td'):css('font-size', '88%'):node(prompt):done() | :css('font-size', '90%') | ||
:tag('td'):addClass('empty-cell'):done() | :node(criteria):done() | ||
:tag('td') | |||
:css('font-size', '88%') | |||
:node(prompt):done() | |||
:tag('td') | |||
:addClass('empty-cell') | |||
:done() | |||
:done() | :done() | ||
:done() | :done() | ||
| Line 124: | Line 140: | ||
end | end | ||
local todo_list = mw.html.create('tr') | local todo_list = mw.html.create('tr') | ||
:tag('td'):attr('colspan', '3'):css('padding', '0') | :tag('td') | ||
:tag('table'):addClass('mw-collapsible mw-collapsed'):css('background', 'transparent') | :attr('colspan', '3') | ||
:css('padding', '0') --TODO add to styles.css | |||
:tag('table') | |||
:addClass('mw-collapsible mw-collapsed') | |||
:css('background', 'transparent') --TODO add to styles.css | |||
:css('width', '100%') | |||
:tag('tr') | :tag('tr') | ||
:tag('th'):css('text-align', 'left'):css('padding', '0.2em 2px 0.2em 0') | :tag('th') --TODO add to styles.css | ||
:cssText(args.TODO_TITLE_STYLE):wikitext((args.TODO_TITLE or cfg.todo_list.default_title) .. ':') | :css('text-align', 'left') | ||
:css('padding', '0.2em 2px 0.2em 0') | |||
:cssText(args.TODO_TITLE_STYLE) | |||
:wikitext((args.TODO_TITLE or cfg.todo_list.default_title) .. ':') | |||
:done() | |||
:done() | |||
:tag('tr') | :tag('tr') | ||
:tag('td'):css('text-align', 'left'):css('padding', '5px'):css('background-color', 'white | :tag('td') --TODO add to styles.css | ||
:css('border', '1px solid #c0c090'):css('margin-top', '5px') | :css('text-align', 'left') | ||
:cssText(args.TODO_STYLE):wikitext(list) | :css('padding', '5px') | ||
:css('background-color', 'white') | |||
:css('border', '1px solid #c0c090') | |||
:css('margin-top', '5px') | |||
:cssText(args.TODO_STYLE) | |||
:wikitext(list) | |||
:allDone() | :allDone() | ||
return todo_list | return todo_list | ||
| Line 141: | Line 171: | ||
end | end | ||
p.quality_importance_insection = function(args, class, importance, importance_name, tf_prefix) | p.quality_importance_insection = function(args, class, importance, importance_name, assessment_cat, article, tf_prefix) | ||
--------------------------- | --------------------------- | ||
-- Category intersection -- | -- Category intersection -- | ||
--------------------------- | --------------------------- | ||
local prefix = tf_prefix or '' | local prefix = tf_prefix or '' | ||
if class=='NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_CLASS'])) then | if class=='NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_CLASS'])) then | ||
return nil | |||
end | end | ||
if importance=='NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_IMPORTANCE'])) then | if importance=='NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_IMPORTANCE'])) then | ||
return nil | |||
end | |||
local form = args[prefix..'QII_FORMAT']:gsub('C', '_C_'):gsub('I', '_I_'):gsub('T', '_T_') | |||
if not class or not importance or not form then | |||
return nil | |||
end | end | ||
if | local new_class | ||
if class=='' then | |||
new_class = 'Unassessed' .. (args[prefix..'QII_UNASSESSED_APPENDIX'] or '') | |||
else | |||
new_class = class .. '-Class' | |||
end | end | ||
local | local check_cat = function (typ) | ||
local cat_name = form:gsub('_C_', new_class):gsub('_I_', importance .. '-' .. importance_name):gsub('_T_', assessment_cat .. ' ' .. typ) | |||
local cat_name = | |||
local cat = mw.title.new('Category:' .. cat_name) | local cat = mw.title.new('Category:' .. cat_name) | ||
return cat.exists and #cat:getContent()>0 and cat_name | return cat.exists and #cat:getContent()>0 and cat_name | ||
end | end | ||
local cat | |||
if not article then | |||
cat = check_cat('pages') | |||
end | |||
if not cat then | |||
cat = check_cat('articles') | |||
end | |||
return cat | |||
end | end | ||
p.image_needed = function(args | p.image_needed = function(args) | ||
--------------------------- | --------------------------- | ||
-- Image needed ----------- | -- Image needed ----------- | ||
| Line 179: | Line 215: | ||
local add_article = function(word) | local add_article = function(word) | ||
local article = cfg.image_needed.article.consonant | local article = cfg.image_needed.article.consonant | ||
if cfg.image_needed.vowels[ | if cfg.image_needed.vowels[word:sub(1, 1)] then | ||
article = cfg.image_needed.article.vowel | article = cfg.image_needed.article.vowel | ||
end | end | ||
| Line 188: | Line 224: | ||
local details = '' | local details = '' | ||
if args['image-details'] then | if args['image-details'] then | ||
details = ' ' .. | details = ' ' .. cfg.image_needed.details:format(args['image-details']) | ||
end | end | ||
local location = '' | local location = '' | ||
if args['image-location'] then | if args['image-location'] then | ||
local location_cat = mw.title.new('Category: | local location_cat = mw.title.new('Category:Wikipedians in ' .. args['image-location']) | ||
if location_cat.exists then | if location_cat.exists then | ||
location = ' ' .. | location = ' ' .. cfg.image_needed.help:format('[[:' .. location_cat.fullText .. '|' .. location_cat.text .. ']]') | ||
end | end | ||
end | end | ||
| Line 207: | Line 240: | ||
end | end | ||
return { | return { | ||
text = | text = cfg.image_needed.text:format(type, details, location), | ||
image_name = args.IM_IMAGE or cfg.image_needed.default_image, | image_name = args.IM_IMAGE or cfg.image_needed.default_image, | ||
category = args['image-location'] and category_exists | category = args['image-location'] and category_exists( | ||
cfg.image_needed.location | cfg.image_needed.location:format( | ||
args['image-type'] or 'photograph', | |||
args['image-location'] | |||
) | |||
category2 = args['image-topic'] and category_exists | ) or args.IM_LOCATION_CATEGORY, | ||
cfg.image_needed.topic | category2 = args['image-topic'] and category_exists( | ||
cfg.image_needed.topic:format( | |||
args['image-type'] or 'photograph', | |||
args['image-topic'] | |||
) | |||
) or args.IM_TOPIC_CATEGORY | |||
} | } | ||
end | end | ||
p.collaboration = function(args | p.collaboration = function(args, title) | ||
--------------------------- | --------------------------- | ||
-- Collaboration ---------- | -- Collaboration ---------- | ||
| Line 232: | Line 267: | ||
local subpage_link = (args.COLL_LINK or '') .. '#' .. title.subjectPageTitle.text | local subpage_link = (args.COLL_LINK or '') .. '#' .. title.subjectPageTitle.text | ||
note_args.candidate = { | note_args.candidate = { | ||
text = | text = cfg.collaboration.candidate:format(subpage_link, link), | ||
image_name = image, | image_name = image, | ||
size = cfg.collaboration.size, | size = cfg.collaboration.size, | ||
| Line 240: | Line 275: | ||
if yesno(args['collaboration-current'], true) then | if yesno(args['collaboration-current'], true) then | ||
note_args.current = { | note_args.current = { | ||
text = | text = cfg.collaboration.current:format(link), | ||
image_name = image, | image_name = image, | ||
size = cfg.collaboration.size, | size = cfg.collaboration.size, | ||
| Line 248: | Line 283: | ||
if yesno(args['collaboration-past'], true) then | if yesno(args['collaboration-past'], true) then | ||
note_args.past = { | note_args.past = { | ||
text = | text = cfg.collaboration.past:format(link), | ||
image_name = image, | image_name = image, | ||
size = cfg.collaboration.size, | size = cfg.collaboration.size, | ||
| Line 265: | Line 300: | ||
return {} | return {} | ||
end | end | ||
local link_exists = args.ACR_SUBPAGE_LINK and mw.title.new(args.ACR_SUBPAGE_LINK).exists or false | |||
local link_exists = args.ACR_SUBPAGE_LINK and mw.title.new( | local link = mw.html.create('span'):css('font-weight', 'bold') | ||
local | local label = cfg.a_class.status[status] | ||
if args.ACR_SUBPAGE_LINK and status=='current' and not link_exists and args.ACR_PRELOAD then -- use custom preload template when creating discussion page | |||
local url = mw.uri.fullUrl(args.ACR_SUBPAGE_LINK, { | |||
action = 'edit', | |||
preload = args.ACR_PRELOAD, | |||
summary = cfg.a_class.create_summary | |||
}) | |||
link:wikitext('[' .. tostring(url) .. ' ' .. label .. ']') | |||
else | |||
link:wikitext('[[' .. (args.ACR_SUBPAGE_LINK or '') .. '|' .. label .. ']]') | |||
end | |||
return { | return { | ||
text = | text = cfg.a_class.text:format( | ||
tostring(link), | |||
args.ACR_REVIEW_LINK or '' | args.ACR_REVIEW_LINK or '' | ||
), | ), | ||
| Line 282: | Line 321: | ||
size = args.ACR_SIZE or '18x18px', | size = args.ACR_SIZE or '18x18px', | ||
background = cfg.a_class.background, | background = cfg.a_class.background, | ||
category = args[category[status]], | category = args[cfg.a_class.category[status]], | ||
category2 = not link_exists and args.ACR_INVALID_CAT | category2 = not link_exists and args.ACR_INVALID_CAT | ||
} | } | ||
| Line 300: | Line 339: | ||
if yesno(args['peer review'], true) then | if yesno(args['peer review'], true) then | ||
note_args.current = { | note_args.current = { | ||
text = | text = cfg.peer_review.current:format(subpage_link, link), | ||
image_name = image, | image_name = image, | ||
size = size, | size = size, | ||
| Line 309: | Line 348: | ||
if yesno(args['old peer review'], true) then | if yesno(args['old peer review'], true) then | ||
note_args.past = { | note_args.past = { | ||
text = | text = cfg.peer_review.past:format(link, subpage_link), | ||
image_name = image, | image_name = image, | ||
size = size, | size = size, | ||