Module:Babel
Appearance
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This Lua module is used on approximately 44,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Usage
Implements Template:Babel, allowing users to group together any number of userboxes in a single, customizable table
{{#invoke:Babel|main}}
local p = {}
local getArgs
function p.main(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame, {wrappers = 'Template:Babel'})
local table_tag = mw.html.create('table')
:addClass('userboxes')
local table_styling = {
{'float', args.align or 'right', ''},
{'margin-left', args.left or '1', 'em'},
{'margin-bottom', args.bottom or '0', 'em'},
{'width', args.width or '248', 'px'},
{'clear', args.align or 'right', ''},
{'color', args.textcolor or '#000000', ''}
}
for _,v in ipairs(table_styling) do
table_tag:css(v[1],v[2]..v[3])
end
local bordercolor = args.bordercolor or '#99B3FF'
local solid = args.solid or '1'
table_tag:css('border',bordercolor..' solid '..solid..'px')
if args.shadow and string.lower(args.shadow) == 'yes' then
table_tag:css('box-shadow','0 2px 4px rgb(0,0,0,0.2)')
:css('-mox-box-shadow','0 2px 4px rgb(0,0,0,0.2)')
:css('-webkit-box-shadow','0 2px 4px rgb(0,0,0,0.2)')
end
local extracss = args.extracss or ''
table_tag:cssText(extracss)
local color = args.color or 'inherit'
local row1 = mw.html.create('tr')
local row2 = mw.html.create('tr')
local row3 = mw.html.create('tr')
local header = args.header or '[[Wikipedia:Babel]]'
local footer = args.footer or '[[:Category:Wikipedians by language|Search user languages]]'
local footer_td = mw.html.create('td')
:css('background-color',color)
:css('text-align','center')
:attr('colspan','10')
:wikitext(footer)
local header_th = mw.html.create('th')
:css('background-color',color)
:css('text-align','center')
:attr('colspan','10')
:wikitext(header)
row1:node(header_th)
row3:node(footer_td)
local body_cells = mw.html.create('td')
:css('vertical-align', 'middle !important')
local userboxes
if args[1] and args[1]:find('%S') then
userboxes = frame:expandTemplate{title='User '..args[1]}
else
userboxes = "''You haven't set up any languages. Please see [[Template:Babel/doc]] for help.''"
end
args[1] = ''
local unclosed_td = false
for i, v in ipairs( args ) do
local boxtext
if v:find('%S') and v ~= '!' then
boxtext = frame:expandTemplate{title='User '..v}
userboxes = userboxes..boxtext
elseif v and v == '!' then
userboxes = userboxes..'</td>\n<td>'
unclosed_td = true
end
end
if args.special-boxes then
userboxes = userboxes..frame:preprocess(args.special-boxes)
end
if unclosed_td then
userboxes = userboxes..'</td>'
end
body_cells:wikitext(userboxes)
row2:node(body_cells)
table_tag:node(row1)
:node(row2)
:node(row3)
return tostring(table_tag)
end
return p