Module:WikiProject banner and Module:WikiProject banner/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
fix text color in dark mode; this generally works but may cause problems, in which case revert or try specifying a different CSS value |
move messages to cfg |
||
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 args_module = require('Module:Arguments') |
local args_module = require('Module:Arguments') |
||
Line 19: | Line 19: | ||
return display or '' |
return display or '' |
||
end |
end |
||
end |
|||
local display_error = function(text) |
|||
local span = mw.html.create('div') |
|||
:addClass('error') |
|||
:wikitext(text) |
|||
return tostring(span) |
|||
end |
end |
||
Line 81: | Line 87: | ||
p.readarticleclass = function(options, page) -- used by _main and also Module:Banner shell |
p.readarticleclass = function(options, page) -- used by _main and also Module:Banner shell |
||
page = page or current_title.prefixedText |
page = page or current_title.prefixedText |
||
local get_parameter_value = require('Module:Template parameter value'). |
local get_parameter_value = require('Module:Template parameter value'). |
||
local success, result = get_parameter_value(page, cfg.WPBS_redirects, 'class', options) |
local success, result = get_parameter_value(page, cfg.WPBS_redirects, 'class', options) |
||
return success and result |
return success and result |
||
Line 140: | Line 146: | ||
local out = mw.html.create('span') |
local out = mw.html.create('span') |
||
:addClass('wpb-header-bubbles') |
:addClass('wpb-header-bubbles') |
||
:css('color', '#202122') |
|||
:css('background', colour) |
:css('background', colour) |
||
:css('border', conflict and cfg.quality.conflict.border or (cfg.quality.border..' '..colour)) |
:css('border', conflict and cfg.quality.conflict.border or (cfg.quality.border..' '..colour)) |
||
Line 336: | Line 341: | ||
else |
else |
||
add_category(cfg.category.no_quality_rating) |
add_category(cfg.category.no_quality_rating) |
||
warning = warning .. display_error(cfg.quality.piqa_warning) |
|||
end |
end |
||
elseif class=='' or class==article_class then -- local class matches article class or is blank |
elseif class=='' or class==article_class then -- local class matches article class or is blank |
||
Line 351: | Line 357: | ||
end |
end |
||
end |
end |
||
elseif class~='' then |
|||
warning = warning .. display_error(cfg.quality.no_banner_shell_warning) |
|||
end |
end |
||
if not isarticle(class) then |
if not isarticle(class) then |
||
Line 374: | Line 382: | ||
local class_row = mw.html.create('tr') |
local class_row = mw.html.create('tr') |
||
:tag('td') |
:tag('td') |
||
:addClass('assess'):addClass('assess-' .. class) |
:addClass('assess') |
||
:addClass('assess-' .. class) |
|||
:css('background', colour) |
:css('background', colour) |
||
:wikitext(wikilink(':Category:' .. category, class=='' and '???' or class)) |
|||
:css('border', conflict and cfg.quality.conflict.border or (cfg.quality.border..' '..colour)) |
:css('border', conflict and cfg.quality.conflict.border or (cfg.quality.border..' '..colour)) |
||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
:addClass('mbox-text'):attr('colspan', '2') |
:addClass('mbox-text') |
||
:attr('colspan', '2') |
|||
:wikitext(quality_rating) |
:wikitext(quality_rating) |
||
:done() |
:done() |
||
Line 415: | Line 426: | ||
local importance_row = mw.html.create('tr') |
local importance_row = mw.html.create('tr') |
||
:tag('td') |
:tag('td') |
||
:addClass('assess'):addClass('import'):addClass('import-' .. importance) |
:addClass('assess') |
||
:addClass('import') |
|||
:addClass('import-' .. importance) |
|||
:css(' |
:css('', ) |
||
:wikitext(wikilink(':Category:' .. category, importance=='Unknown' and '???' or importance)) |
|||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
:addClass('mbox-text'):attr('colspan', '2') |
:addClass('mbox-text') |
||
:attr('colspan', '2') |
|||
:wikitext(importance_rating) |
:wikitext(importance_rating) |
||
:done() |
:done() |
||
Line 447: | Line 461: | ||
local header_row = mw.html.create('tr') |
local header_row = mw.html.create('tr') |
||
:tag('th') |
:tag('th') |
||
:attr('colspan','3'):addClass('wpb-collapsed-head'):wikitext(header) |
:attr('colspan','3') |
||
:addClass('wpb-collapsed-head') |
|||
:wikitext(header) |
|||
:done() |
:done() |
||
local blank_row = mw.html.create('tr') |
local blank_row = mw.html.create('tr') |
||
:tag('td') |
:tag('td') |
||
:addClass('mbox-image wpb-gutter'):css('min-width',image_left_size) |
:addClass('mbox-image wpb-gutter') |
||
:css('min-width',image_left_size) |
|||
:tag('span'):addClass('wpb-iefix'):wikitext('/ '):done() --TO FIX IE |
:tag('span') |
||
:addClass('wpb-iefix') |
|||
:wikitext('/ ') |
|||
:done() --TO FIX IE |
|||
:done() |
:done() |
||
:tag('td'):done() |
:tag('td'):done() |
||
Line 465: | Line 485: | ||
local collapsed_section = mw.html.create('tr') |
local collapsed_section = mw.html.create('tr') |
||
:tag('td') |
:tag('td') |
||
:attr('colspan','3'):addClass('wpb-collapsed-notes') |
:attr('colspan','3') |
||
:addClass('wpb-collapsed-notes') |
|||
:node(collapsed_rows) |
:node(collapsed_rows) |
||
:done() |
:done() |
||
Line 491: | Line 512: | ||
end |
end |
||
if args[tf_prefix .. 'TEXT']~='none' then |
if args[tf_prefix .. 'TEXT']~='none' then |
||
local portal = args[tf_prefix..'PORTAL'] and frame:expandTemplate{title='Portal', |
local portal = args[tf_prefix..'PORTAL'] and frame:expandTemplate{ |
||
title='Portal', |
|||
args={args[tf_prefix .. 'PORTAL'], height='15', margin='0'} |
|||
} or '' |
|||
local text = '' |
local text = '' |
||
local tf_text = args[tf_prefix..'TEXT'] or args.TF_TEXT |
local tf_text = args[tf_prefix..'TEXT'] or args.TF_TEXT |
||
Line 519: | Line 543: | ||
end |
end |
||
local taskforce = mw.html.create('tr') |
local taskforce = mw.html.create('tr') |
||
:tag('td'):wikitext(tf_image):done() |
:tag('td') |
||
:wikitext(tf_image) |
|||
:done() |
|||
:tag('td'):addClass('mbox-text'):attr('colspan','2'):wikitext(text):done() |
:tag('td') |
||
:addClass('mbox-text') |
|||
:attr('colspan','2') |
|||
:wikitext(text) |
|||
:done() |
|||
table.insert(taskforce_output, taskforce) |
table.insert(taskforce_output, taskforce) |
||
end |
end |
||
Line 570: | Line 600: | ||
local note_image = image(note_args.image_name, note_args.size or note_default_size, cfg.note.icon_alt, 'center') |
local note_image = image(note_args.image_name, note_args.size or note_default_size, cfg.note.icon_alt, 'center') |
||
local new_note = mw.html.create('tr') |
local new_note = mw.html.create('tr') |
||
:tag('td'):css('background', note_args.background):wikitext(note_image):done() |
:tag('td') |
||
:css('background', note_args.background) |
|||
:wikitext(note_image) |
|||
:done() |
|||
:tag('td'):addClass('mbox-text'):attr('colspan', '2'):wikitext(note_args.text):done() |
:tag('td') |
||
:addClass('mbox-text') |
|||
:attr('colspan', '2') |
|||
:wikitext(note_args.text) |
|||
:done() |
|||
table.insert(note_output, new_note) |
table.insert(note_output, new_note) |
||
if note_image then |
if note_image then |
||
Line 704: | Line 741: | ||
if #nested_tf>0 then |
if #nested_tf>0 then |
||
nested_tf_str = tostring(mw.html.create('span') |
nested_tf_str = tostring(mw.html.create('span') |
||
:addClass('wpb-nested-task-force') |
|||
:css('font-weight', 'normal') --TODO: move to TemplateStyles. |
|||
:wikitext(': ' .. table.concat(nested_tf, ' / ')) |
:wikitext(': ' .. table.concat(nested_tf, ' / ')) |
||
) |
) |
||
Line 719: | Line 756: | ||
:tag('td') |
:tag('td') |
||
:addClass('wpb-header-icon') |
:addClass('wpb-header-icon') |
||
:attr('width', '50px') --TODO: move to TemplateStyles. |
|||
:css('text-align', 'center') --TODO: move to TemplateStyles. |
|||
:wikitext(image(args.IMAGE_LEFT, cfg.image.header_size, cfg.image.alt)) |
:wikitext(image(args.IMAGE_LEFT, cfg.image.header_size, cfg.image.alt)) |
||
:done() |
:done() |
||
Line 739: | Line 774: | ||
end |
end |
||
local category_box = mw.html.create('div') |
local category_box = mw.html.create('div') |
||
:addClass('wpb-category-box') |
|||
:css('background-color', '#F5F5F5'):css('border-width', '1px'):css('color', '#202122') --TODO: move to TemplateStyles. |
|||
:css('width', '500px') --TODO: move to TemplateStyles. |
|||
:wikitext('Categories:') |
:wikitext('Categories:') |
||
:node(category_list) |
:node(category_list) |
||
Line 762: | Line 796: | ||
:addClass('tmbox tmbox-notice mw-collapsible innercollapse wpb') |
:addClass('tmbox tmbox-notice mw-collapsible innercollapse wpb') |
||
:addClass(inactive and cfg.status.inactive_class or nil) |
:addClass(inactive and cfg.status.inactive_class or nil) |
||
:addClass('wpb-table') |
|||
:css('table-layout', 'fixed') --TODO: move to TemplateStyles. |
|||
:node(header_row) |
:node(header_row) |
||
:tag('tr'):tag('td') |
:tag('tr') |
||
:tag('td') |
|||
:addClass('mbox-text wpb-main') |
:addClass('mbox-text wpb-main') |
||
:attr('colspan','2') |
:attr('colspan','2') |
||
:node(banner_rows) |
:node(banner_rows) |
||
:allDone() |
:allDone() |
||
if args.listas then |
if args.listas then |
||
Line 773: | Line 808: | ||
end |
end |
||
local tstyle = frame:extensionTag ('templatestyles', '', {src='Module:Message box/tmbox.css'}) .. |
local tstyle = frame:extensionTag ('templatestyles', '', {src='Module:Message box/tmbox.css'}) .. |
||
frame:extensionTag ('templatestyles', '', {src = 'Module:WikiProject banner' .. (sandbox or '') |
frame:extensionTag ('templatestyles', '', {src = 'Module:WikiProject banner' .. (sandbox or '')}) |
||
return warning .. tstyle .. tostring(banner) .. categories_formatted, note_count, #taskforce_output, assessment_link |
return warning .. tstyle .. tostring(banner) .. categories_formatted, note_count, #taskforce_output, assessment_link |
||
end |
end |