Module:Portal toolbox: Difference between revisions

Content deleted Content added
reduce amount of duplication needed
add support for parameter "template"; clean up
Line 11:
 
local function edit(frame, pagename)
return frame:expandTemplate{ title='edit', args = { pagename } }
end
 
local function toolbox_template_row(frame, tbl, pagename)
local row = tbl:tag('tr')
row:tag('td')
:wikitext(frame:expandTemplate{ title='tl', args={ pagename } })
row:tag('td')
:wikitext(edit(frame, 'Template:' .. pagename))
end
 
Line 22 ⟶ 30:
end
 
local function toolbox_section(frame, args, tbl, rootTitle, titlesection_header, prefix, page_prefix, row_function)
if row_function == nil then
toolbox_header_row(frame, tbl, title)
row_function = toolbox_row
end
local nums = {}
for k, _ in pairs(args) do
Line 32 ⟶ 42:
end
end
end
if #nums == 0 then
return
end
table.sort(nums)
toolbox_header_row(frame, tbl, titlesection_header)
for _, num in ipairs(nums) do
local arg_name = prefix .. num
Line 46 ⟶ 60:
right = edit(frame, pagename)
end
toolbox_rowrow_function(frame, tbl, pagename, text, right)
end
end
Line 60 ⟶ 74:
toolbox_row(frame, tbl, rootTitle.fullText, nil, edit(frame, rootTitle.fullText))
toolbox_section(frame, args, tbl, rootTitle, 'Static subpages', 'static', rootTitle.fullText .. '/')
toolbox_section(frame, args, tbl, rootTitle, 'Dynamic subpages', 'dynamic', rootTitle.fullText .. '/')
toolbox_section(frame, args, tbl, rootTitle, 'OtherTemplates', 'othertemplate', '', toolbox_template_row)
toolbox_section(frame, args, tbl, 'Other', 'other', '')
return tbl
end