Module:WikiProject banner/auxiliary/sandbox explained

require('strict')local p = local sandbox = '/sandbox'local cfg = mw.loadData('Module:WikiProject banner/config' .. (sandbox or ))local yesno = require('Module:Yesno')local lang = mw.getLanguage(cfg.language)

p.b_checklist = function(args, raw_args, class, demo, assessment_link)----------------------------- B-class checklist ---------------------------------local show_checklist = falselocal parameters_used = args.b1 or args.b2 or args.b3 or args.b4 or args.b5 or args.b6if (class

'B' or class

'C' or class

'BL' or class

'CL')-- always displayed on C or B or ((class

'Start' or class

'List') and yesno(args.B_DISPLAY_ON_START))-- show on Start/List if option selected or ((class

'Start' or class

'Stub') and parameters_used) then-- show on Start or Stub if any parameters used show_checklist = trueendif show_checklist then local scale = args.QUALITY_CRITERIA

'custom' and assessment_link and assessment_link..'#'..lang:ucfirst(cfg.quality.name) or cfg.b_checklist.default_scale local text = string.format(cfg.b_checklist.text, parameters_used and cfg.b_checklist.checked or cfg.b_checklist.not_checked, scale ) local syntax = local criteria = mw.html.create('ol') for i = 1, 6 do local b = raw_args['b'..i] if b and b~='unused' then -- crtierion in use b = cfg.b_checklist.mask[string.lower(b)] or cfg.b_checklist.mask.default local image = '' local failed_cat = args['B'..i..'_CAT'] local category = if b~='y' and b~='x' and failed_cat and not demo then -- criterion failed category = '' end if (b

'u' or b

'i') and args.B_MAIN_CAT and not demo then -- unevaluated or invalid parameter category = category .. '' end criteria:tag('li') :wikitext(image .. ' ' .. cfg.b_checklist.criteria[i] .. ': ') :tag('span') :css('font-style', 'italic') :wikitext(cfg.b_checklist.status[b]) :wikitext(category) :allDone local new_syntax = mw.html.create('li') :addClass('nowrap') :wikitext(string.format(cfg.b_checklist.syntax.prompt, tostring(i), cfg.b_checklist.criteria[i] .. string.rep(' ', cfg.b_checklist.syntax.max_width-#cfg.b_checklist.criteria[i]) )) :done table.insert(syntax, tostring(new_syntax)) end end local prompt if not parameters_used then prompt = mw.html.create('span') :wikitext(string.format(cfg.b_checklist.syntax.text, tostring(mw.title.getCurrentTitle:fullUrl) )) :tag('ul') :css('font-size', '88%'):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)) :done :wikitext(cfg.b_checklist.syntax.assess) :done end local checklist = mw.html.create('tr') :tag('td') :addClass('assess-b') :css('background', cfg.quality.colour.B):css('padding-bottom', '5px') :wikitext(cfg.b_checklist.image) :done :tag('td') :addClass('wpb-collapsed-notes') :tag('table') :addClass('plainlinks mw-collapsible mw-collapsed') :tag('tr') :tag('th'):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 :tag('tr') :tag('td'):css('font-size', '90%'):node(criteria):done :tag('td'):css('font-size', '88%'):node(prompt):done :tag('td'):addClass('empty-cell'):done :done :done :done :done return checklistendend

p.todo_list = function(args, frame)----------------------------- To-do list ----------------------------------------local listif args.TODO_LINK then local link = function(action) local url = mw.uri.fullUrl(args.TODO_LINK,) return mw.html.create('li'):wikitext('[' .. tostring(url) .. ' ' .. cfg.todo_list[action] .. ']') end local links = yesno(args.TODO_EDITLINKS or true, 'true') and frame:expandTemplate or list = links .. '\n' .. frame:expandTemplateelse list = ('\n' .. args.TODO_TEXT) or endlocal todo_list = mw.html.create('tr') :tag('td'):attr('colspan', '3'):css('padding', '0') :tag('table'):addClass('mw-collapsible mw-collapsed'):css('background', 'transparent'):css('width', '100%') :tag('tr') :tag('th'):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('td'):css('text-align', 'left'):css('padding', '5px'):css('background-color', 'white') :css('border', '1px solid #c0c090'):css('margin-top', '5px') :cssText(args.TODO_STYLE):wikitext(list)

allDonereturn todo_listendp.todo_list_ = function(frame) return p.todo_list(frame.args, frame)end

p.quality_importance_insection = function(args, class, importance, importance_name, tf_prefix)----------------------------- Category intersection -----------------------------local suppress = falselocal prefix = tf_prefix or if class

'NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_CLASS'])) then suppress = trueendif importance

'NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_IMPORTANCE'])) then suppress = trueendif not class or not importance then suppress = trueendlocal format = args[prefix..'QII_FORMAT']:gsub('C', '_C_'):gsub('I', '_I_'):gsub('T', '_T_')if format and not suppress then local new_class if class

then new_class = 'Unassessed' .. (args[prefix..'QII_UNASSESSED_APPENDIX'] or ) else new_class = class .. '-Class' end local assessment_cat = args[prefix..'ASSESSMENT_CAT'] or args.PROJECT..' articles' local cat_name = format:gsub('_C_', new_class):gsub('_I_', importance .. '-' .. importance_name):gsub('_T_', assessment_cat) local cat = mw.title.new('Category:' .. cat_name) return cat.exists and #cat:getContent>0 and cat_nameendend

p.image_needed = function(args, pagetype)----------------------------- Image needed --------------------------------------local type = cfg.image_needed.default_typeif args['image-type'] then local add_article = function(word) local article = cfg.image_needed.article.consonant if cfg.image_needed.vowels[string.sub(word, 1, 1)] then article = cfg.image_needed.article.vowel end return article .. ' ' .. word .. '' end type = add_article(args['image-type'])endlocal details = if args['image-details'] then details = ' ' .. string.format(cfg.image_needed.details, args['image-details'])endlocal location = if args['image-location'] then local location_cat = mw.title.new('Category:Wikipedians in ' .. args['image-location']) if location_cat.exists then location = ' ' .. string.format(cfg.image_needed.help, '' .. location_cat.text .. '' ) endendlocal category_exists = function(category) local title = mw.title.new('Category:' .. category) if title.exists then return category endendreturn end

p.collaboration = function(args, pagetype, title)----------------------------- Collaboration -------------------------------------local image = args.COLL_IMAGE or cfg.collaboration.default_imagelocal link = '' .. (args.COLL_TEXT or cfg.collaboration.default_text) .. ''local note_args = if yesno(args['collaboration-candidate'], true) then local subpage_link = (args.COLL_LINK or ) .. '#' .. title.subjectPageTitle.text note_args.candidate = endif yesno(args['collaboration-current'], true) then note_args.current = endif yesno(args['collaboration-past'], true) then note_args.past = endreturn note_argsend

p.a_class = function(args, lang)----------------------------- A-class review ------------------------------------local status = cfg.a_class.mask[lang:lc(args['a class'])]if status

nil then return endlocal subpage = args.ACR_SUBPAGE_LINK or local link_exists = args.ACR_SUBPAGE_LINK and mw.title.new(subpage).exists or falselocal category = return end

p.peer_review = function(args, title)----------------------------- Peer review ---------------------------------------local image = args.PR_IMAGE or cfg.peer_review.default_imagelocal size = args.PR_SIZE or cfg.peer_review.sizelocal link = args.PR_LINK or local pr_title = args['peer review title'] and mw.title.new(args['peer review title']) or titlelocal subpage_link = link .. '/' .. pr_title.subjectPageTitle.textlocal invalid_cat = not mw.title.new(subpage_link).exists and args.PR_INVALID_CATlocal note_args = if yesno(args['peer review'], true) then note_args.current = endif yesno(args['old peer review'], true) then note_args.past = endreturn note_args

endreturn p