Module:WikiProject banner/auxiliary/sandbox: Difference between revisions

Content deleted Content added
use nil for non-existent category
marking css that needs to be moved
 
(35 intermediate revisions by 2 users not shown)
Line 10:
-- B-class checklist ------
---------------------------
local show_checklist = false
if raw_args.HOOK_ASSESS then return nil end -- temporary transition code to prevent two checklists appearing
local show_checklist, parameters_used = false,args.b1 or args.b2 or args.b3 or args.b4 or args.b5 or nilargs.b6
if (class=='B' or class=='C' or class=='BL' or class=='CL')-- always displayed on C or B
parameters_used = args.b1 or args.b2 or args.b3 or args.b4 or args.b5 or args.b6
if or ((class=='BStart' or class=='CList') and yesno(args.B_DISPLAY_ON_START))-- always displayedshow on CStart/List orif option Bselected
or (class=='Start' and yesno(args.B_DISPLAY_ON_START))-- show on Start if option selected
or ((class=='Start' or class=='Stub') and parameters_used) then-- show on Start or Stub if any parameters used
show_checklist = true
Line 44 ⟶ 43:
:wikitext(image .. ' ' .. cfg.b_checklist.criteria[i] .. ': ')
:tag('span')
:css('font-style', 'italic') --TODO add to styles.css
:wikitext(cfg.b_checklist.status[b])
:wikitext(category)
Line 66 ⟶ 65:
tostring(mw.title.getCurrentTitle():fullUrl({action = 'edit'}))
))
:tag('ul') --TODO add to styles.css
: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()
Line 77 ⟶ 82:
:tag('td')
:addClass('assess-b')
:css('background', cfg.b_checklistquality.background):css('padding-bottom', '5px'colour.B)
:css('padding-bottom', '5px') --TODO add to styles.css
:wikitext(cfg.b_checklist.image)
:done()
Line 85 ⟶ 91:
:addClass('plainlinks mw-collapsible mw-collapsed')
:tag('tr')
:tag('th')
:addClass('wpb-collapsed-head mbox-text')
:attr('colspan', '3')
:css('font-weight', 'normal') --TODO add to styles.css
:wikitext(text):done()
:tag('td')
:css('min-width', '3em') --TODO add to styles.css
:done() -- empty cell for show/hide toggle
:done()
:tag('tr')
:tag('td')
:css('font-size', '90%') --TODO add to styles.css
:node(criteria):done()
:tag('td')
:css('font-size', '88%') --TODO add to styles.css
:node(prompt):done()
:tag('td')
:addClass('empty-cell')
:done()
:done()
:done()
Line 125 ⟶ 143:
end
local todo_list = mw.html.create('tr')
:tag('td')
: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('th') --TODO add to styles.css
: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') --TODO add to styles.css
: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)
:allDone()
return todo_list
Line 142 ⟶ 174:
end
 
p.quality_importance_insection = function(args, class, importance, importance_name, tf_prefix)
---------------------------
-- Category intersection --
---------------------------
local suppress = false
local prefix = tf_prefix or ''
if class=='NA' and (yesno(args.QII_SUPPRESS_NA) or yesno(args.QII_SUPPRESS_NA_CLASS)) then
if class=='NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_CLASS'])) then
suppress = true
end
if importance=='NA' and (yesno(args[prefix..'QII_SUPPRESS_NA']) or yesno(args[prefix..'QII_SUPPRESS_NA_IMPORTANCE'])) then
suppress = true
end
if not class or not importance then
local format = args.QII_FORMAT
suppress = true
end
local format = args[prefix..'QII_FORMAT']:gsub('C', '_C_'):gsub('I', '_I_'):gsub('T', '_T_')
if format and not suppress then
local new_class
local assessment_cat = args.ASSESSMENT_CAT or args.PROJECT..' articles'
if class=='' then
format = string.gsub(format, 'C', '_C_')
new_class = 'Unassessed' .. (args[prefix..'QII_UNASSESSED_APPENDIX'] or '')
format = string.gsub(format, 'I', '_I_')
else
format = string.gsub(format, 'T', '_T_')
local cat new_class = string.gsub(format, '_C_', class=='' and 'Unassessed' or class.. '-Class')
end
cat = string.gsub(cat, '_I_', importance .. '-' .. importance_name)
local assessment_cat = args[prefix..'ASSESSMENT_CAT'] or args.PROJECT..' articles'
cat = string.gsub(cat, '_T_', assessment_cat)
local cat_name = format:gsub('_C_', new_class):gsub('_I_', importance .. '-' .. importance_name):gsub('_T_', assessment_cat)
return cat
local cat = mw.title.new('Category:' .. cat_name)
return cat.exists and #cat:getContent()>0 and cat_name
end
end
 
p.image_needed = function(args, demopagetype)
---------------------------
-- Image needed -----------
Line 202 ⟶ 240:
end
return {
text = string.format(cfg.image_needed.text, type, details, pagetype, location),
image_name = args.IM_IMAGE or cfg.image_needed.default_image,
category = args['image-location'] and category_exists(string.format(
cfg.image_needed.location,
args['image-type'] or 'photograph',
args['image-location'] or ''
)) or args.IM_LOCATION_CATEGORY or nil,
category2 = args['image-topic'] and category_exists(string.format(
cfg.image_needed.topic,
args['image-type'] or 'photograph',
args['image-topic'] or ''
)) or args.IM_TOPIC_CATEGORY or nil
}
end
 
p.collaboration = function(args, pagetype, title)
---------------------------
-- Collaboration ----------
---------------------------
local image = args.COLL_IMAGE or cfg.collaboration.default_image
local link = '[[' .. (args.COLL_LINK or '') .. '|' .. (args.COLL_TEXT or cfg.collaboration.default_text) .. ']]'
local note_args = {candidate = {}, current = {}, past = {}}
if yesno(args['collaboration-candidate'], true) then
local subpage_link = (args.COLL_LINK or '') .. '#' .. title.subjectPageTitle.text
note_args.candidate = {
text = string.format(cfg.collaboration.candidate, pagetype, subpage_link, link),
image_name = image,
size = cfg.collaboration.size,
category = args.COLL_CANDIDATE_CAT
}
end
if yesno(args['collaboration-current'], true) then
note_args.current = {
text = string.format(cfg.collaboration.current, pagetype, link),
image_name = image,
size = cfg.collaboration.size,
category = args.COLL_CURRENT_CAT
}
end
if yesno(args['collaboration-past'], true) then
note_args.past = {
text = string.format(cfg.collaboration.past, pagetype, link),
image_name = image,
size = cfg.collaboration.size,
category = args.COLL_PAST_CAT
}
end
return note_args
end
 
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 {}
end
local subpage = args.ACR_SUBPAGE_LINK or ''
local link_exists = args.ACR_SUBPAGE_LINK and mw.title.new(subpage).exists or false
local category = {
pass = 'ACR_PASS_CAT',
fail = 'ACR_FAIL_CAT',
current = 'ACR_CURRENT_CAT'
}
return {
text = string.format(
cfg.a_class.text,
subpage,
cfg.a_class.status[status],
args.ACR_REVIEW_LINK or ''
),
image_name = args.ACR_IMAGE or cfg.a_class.icon[status],
size = args.ACR_SIZE or '18x18px',
background = cfg.a_class.background,
category = args[category[status]],
category2 = not link_exists and args.ACR_INVALID_CAT
}
end
 
p.peer_review = function(args, title)
---------------------------
-- Peer review ------------
---------------------------
local image = args.PR_IMAGE or cfg.peer_review.default_image
local size = args.PR_SIZE or cfg.peer_review.size
local link = args.PR_LINK or ''
local pr_title = args['peer review title'] and mw.title.new(args['peer review title']) or title
local subpage_link = link .. '/' .. pr_title.subjectPageTitle.text
local invalid_cat = not mw.title.new(subpage_link).exists and args.PR_INVALID_CAT
local note_args = {current = {}, past = {}}
if yesno(args['peer review'], true) then
note_args.current = {
text = string.format(cfg.peer_review.current, subpage_link, link),
image_name = image,
size = size,
category = args.PR_CAT,
category2 = invalid_cat
}
end
if yesno(args['old peer review'], true) then
note_args.past = {
text = string.format(cfg.peer_review.past, link, subpage_link),
image_name = image,
size = size,
category = args.PR_OLD_CAT,
category2 = invalid_cat
}
end
return note_args
 
end
return p