Module:Sandbox/GKFX
Appearance
local banner = {}
local params = {}
--[[
A space to determine the value of parameters considering defaults etc.
It is not obligatory to pass every argument through this function.
]]
function banner.processArguments(args)
local status_table = {
inactive = 'inactive-wikiproject',
['semi-active'] = 'semi-active-wikiproject',
semiactive = 'semi-active-wikiproject',
defunct = 'defunct-wikiproject'
}
params.status = status_table[string.lower(args['PROJECT_STATUS'] or '')] or 'active-wikiproject';
params.project = args['PROJECT']
params.project_link = args['PROJECT_LINK'] or ('Wikipedia:WikiProject ' .. params.project)
params.project_name = args['PROJECT_NAME'] or ('WikiProject ' .. params.project)
params.assessment_cat = args['ASSESSMENT_CAT'] or (params.project .. ' articles')
params.banner_name = args['BANNER_NAME'] or ('Template:WikiProject ' .. params.project)
params.task_forces = {}
for i = 1, 20 do
if args['tf ' .. i] then
params.task_forces[i] = {
image = args['TF_' .. i .. '_IMAGE'],
link = args['TF_' .. i .. '_LINK'],
name = args['TF_' .. i .. '_NAME'],
nested = args['TF_' .. i .. '_NESTED'],
quality = args['TF_' .. i .. '_QUALITY'],
nested = args['TF_' .. i .. '_ASSESSMENT_CAT'],
quality = args['TF_' .. i .. '_MAIN_CAT'],
importance = args['tf_' .. i .. '_importance'],
text = args['TF_' .. i .. '_TEXT']
}
end
end
params.image_left = {name = args['IMAGE_LEFT'], size = args['IMAGE_LEFT_SIZE'] or args['IMAGE_LEFT_LARGE'] or '80px'}
params.image_right = {name = args['IMAGE_RIGHT'], size = args['IMAGE_RIGHT_SIZE'] or args['IMAGE_RIGHT_LARGE'] or '80px'}
end
function banner._main(frame)
banner.processArguments(frame.args)
local result = mw.html.create('table')
local current = result:attr({class = 'tmbox tmbox-notice mw-collapsible innercollapse wpb ' .. params.status, style = 'height:0'})
:tag('tr'):addClass('wpb-header')
:tag('td'):cssText('text-align:right; padding:0.3em 1em 0.3em 0.3em; width:50%; font-weight:bold;')
:wikitext('[[' .. params.project_link .. '|' .. params.project_name .. ']]')
for _, tf in ipairs(params.task_forces) do
if tf.nested then
current:wikitext('/ [[' .. tf.link .. '|' .. tf.nested .. ']] ')
end
end
current = current:done()
:tag('th'):cssText('text-align:left; width:50%; padding:0.3em;')
:wikitext("(Rated etc...)"):done():done()
:tag('tr')
:tag('td'):attr({class='mbox-text', style='padding:3px 0 3px 5px;', colspan='2'})
:tag('table'):cssText('background:transparent; border:none; padding:0; width:100%; border-spacing:0')
:tag('tr')
if params.image_left.name then
current:wikitext('<td class="mbox-image" style="padding:2px 0;">[[File:' .. params.image_left.name ..
'|' .. params.image_left.size .. '|alt=WikiProject icon]]</td>')
else
current:wikitext('<td class=mbox-empty-cell></td>')
end
current = current:tag('td'):addClass('mbox-text')
if frame.args['PORTAL'] then
current:wikitext(frame:expandTemplate{title = 'portal', args = {frame.args['PORTAL']}})
end
current:wikitext(frame:expandTemplate{title = 'navbar', args =
{mini = '1', style = 'float:right; clear:right; margin:-1em 0.1em; display:none;'}})
if frame.args['MAIN_TEXT'] then
current:wikitext(frame.args['MAIN_TEXT'])
else
current:wikitext('This ' .. 'article' ..
[=[ is within the scope of '''[[]=] .. params.project_link .. '|' .. params.project_name ..
[=[]]''', a collaborative effort to improve the coverage of ]=])
if frame.args['MAIN_ARTICLE'] then
current:wikitext(mw.title.new(frame.args['MAIN_ARTICLE']).exists and ('[[' .. frame.args['MAIN_ARTICLE'] .. ']]')
or frame.args['MAIN_ARTICLE'])
else
current:wikitext(mw.title.new(params.project).exists and ('[[' .. params.project .. ']]')
or (params.project .. ' articles'))
end
current:wikitext('on Wikipedia. If you would like to participate, please visit the project page, where you can join the [[',
tostring(mw.title.new(params.project_link).talkPageTitle), '|discussion]] and see a list of open tasks.')
end
current:wikitext('<span class="metadata" style="display:none; speak:none;"><span class="wpb-project">',
params.project, '</span><span class="wpb-banner_name">', params.banner_name,
'</span><span class="wpb-assessment_cat">', params.assessment_cat, '</span></span>')
return tostring(result)
end
return banner