Module:Sidebar: Difference between revisions

Ganaram inukshuk (talk | contribs)
m rename args
Ganaram inukshuk (talk | contribs)
m add name, pulled from args
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- This module follows [[User:Ganaram inukshuk/Provisional style guide for Lua]]
-- This module follows [[User:Ganaram inukshuk/Provisional style guide for Lua]]
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
local navbar  = require("Module:Navbar")._navbar
local tiu    = require("Module:Template input utils")
local tiu    = require("Module:Template input utils")


Line 10: Line 11:
-- Not to be confused with the sidebox either.
-- Not to be confused with the sidebox either.


-- TODO: add float option?
-- TODO: use templatestyles


-- "Main" function
-- "Main" function
function p._sidebar(args)
function p._sidebar(args)
local title  = args["Title" ]
local title  = args["Title"] or "Sidebar Title"
local header = args["Header Row"]
local header = args["Header Row"]
local rows  = args["Rows" ]
local rows  = args["Rows"]
local footer = args["Footer Row"]
local footer = args["Footer Row"]
local float  = args["float" ] or "right"
local float  = args["float"] or "right"
local name  = args["name"]
-- Helper function; title
-- Helper function; title
Line 41: Line 43:
table.insert(lines, "|-")
table.insert(lines, "|-")
table.insert(lines, string.format('| style="font-size: 80%%;" | %s', row_content))
table.insert(lines, string.format('| style="font-size: 80%%;" | %s', row_content))
return table.concat(lines, "\n")
end
-- Helper function; navbar row
function navbar_row()
local lines = {}
table.insert(lines, '|-')
table.insert(lines, '| style="text-align: center;" | ' .. navbar(name, "mini", ""))
return table.concat(lines, "\n")
return table.concat(lines, "\n")
end
end
Line 61: Line 72:
-- Footer
-- Footer
if footer then table.insert(lines, header_footer_row(footer)) end
if footer then table.insert(lines, header_footer_row(footer)) end
if name then table.insert(lines, navbar_row()) end
-- End of table
-- End of table