Module:Portal toolbox: Difference between revisions

Content deleted Content added
m simplify
add "clear: right;" to the main CSS
 
(2 intermediate revisions by the same user not shown)
Line 3:
p = {}
 
local function toolbox_header_rowadd_header_row(frame, tbl, text)
local row = tbl:tag('tr')
row:tag('th')
Line 14:
end
 
local function toolbox_template_rowadd_template_row(frame, tbl, pagename)
local row = tbl:tag('tr')
row:tag('td')
Line 22:
end
 
local function toolbox_rowadd_wikilink_row(frame, tbl, pagename, text, right)
local row = tbl:tag('tr')
row:tag('td')
Line 30:
end
 
local function toolbox_sectionadd_section(frame, args, tbl, section_headeradd_section_header, prefixarg_prefix, page_prefix, row_function)
if row_function == nil then
row_function = toolbox_rowadd_wikilink_row
end
local nums = {}
for k, _ in pairs(args) do
if type(k) == 'string' then
local num = k:match('^' .. prefixarg_prefix .. '(%d+)$')
if num then
table.insert(nums, tonumber(num))
Line 47:
end
table.sort(nums)
toolbox_header_rowadd_header_row(frame, tbl, section_headeradd_section_header)
for _, num in ipairs(nums) do
local arg_name = prefixarg_prefix .. num
local aarg = args[arg_name]
local pagename = page_prefix .. aarg
local text = args[arg_name .. 'text']
local right = args[arg_name .. 'right']
row_function(frame, tbl, pagename, text or arg, right)
if text == nil then
text = a
end
row_function(frame, tbl, pagename, text, right)
end
end
Line 64 ⟶ 61:
local args = getArgs(frame)
local tbl = mw.html.create('table')
:cssText('clear: right; float:right; border:1px navy solid;')
tbl:tag('caption')
:wikitext('Portal toolbox')
toolbox_header_rowadd_header_row(frame, tbl, 'Main portal page')
local rootTitle = mw.title.getCurrentTitle().rootPageTitle.subjectPageTitle
toolbox_rowadd_wikilink_row(frame, tbl, rootTitle.fullText, nil, edit(frame, rootTitle.fullText))
toolbox_sectionadd_section(frame, args, tbl, 'Static subpages', 'static', rootTitle.fullText .. '/')
toolbox_sectionadd_section(frame, args, tbl, 'Dynamic subpages', 'dynamic', rootTitle.fullText .. '/')
toolbox_sectionadd_section(frame, args, tbl, 'Templates', 'template', '', toolbox_template_rowadd_template_row)
toolbox_sectionadd_section(frame, args, tbl, 'Other', 'other', '')
return tbl
end