Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  



























Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage from wikitext  





2 Usage from Lua modules  














Module:Side box






Afrikaans
Anarâškielâ
Ænglisc
Аԥсшәа
العربية
Արեւմտահայերէն
Авар
Azərbaycanca
تۆرکجه
Basa Bali

 / Bân-lâm-gú

Bikol Central
Bosanski
Brezhoneg
Català
Cebuano
Chamoru
Corsu
Dansk
الدارجة
Eesti
Español
فارسی
Føroyskt
Gaeilge
Galego
گیلکی

  / Gõychi Konknni
/Hak-kâ-ngî

Hausa
Hawaiʻi
Հայերեն
Hrvatski
Ilokano
Bahasa Indonesia
Íslenska
Jawa


Ikirundi
Kotava
Kurdî
Ladin
Latviešu
Lietuvių
Madhurâ
Македонски

Māori
مصرى

مازِرونی
Bahasa Melayu
 / Mìng-dĕ̤ng-nḡ



Norsk bokmål
Norsk nynorsk
ି
Oʻzbekcha / ўзбекча

ि
Pangasinan
Pangcah
پنجابی

پښتو
Português
Qaraqalpaqsha
Русский
Sakizaya
Scots
Shqip

Simple English
سنڌي
Slovenščina
Soomaaliga
کوردی
Српски / srpski
Srpskohrvatski / српскохрватски
Suomi
Svenska
Tagalog
Taqbaylit
 


Тоҷикӣ

Türkçe
Türkmençe
اردو
Tiếng Vit
Volapük

Winaray



 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
Meta-Wiki
Wikispecies
Wikidata
Wikifunctions
Wikimania
Wikiversity
 

















Permanently protected module

From Wikipedia, the free encyclopedia
 


This module implements the {{side box}} template.

Usage from wikitext

This module cannot be used directly from wikitext. It can only be used through the {{side box}} template. Please see the template page for documentation.

Usage from Lua modules

To use this module from other Lua modules, first load the module.

local mSideBox = require('Module:Side box')

You can then generate a side box using the _main function.

mSideBox._main(args)

The args variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the {{side box}} template documentation.

local yesno = require('Module:Yesno')
local p = {}

local function makeData(args)
 local data = {}

 -- Main table classes
 data.classes = {}
 if yesno(args.metadata) ~= false then
  table.insert(data.classes, 'metadata')
 end
 if args.position and args.position:lower() == 'left' then
  table.insert(data.classes, 'side-box-left')
 else
  table.insert(data.classes, 'side-box-right')
 end
 
 if args.collapsible then
  table.insert(data.classes, 'mw-collapsible')
  if args.collapsible == "collapsed" then
   table.insert(data.classes, 'mw-collapsed')
  end
  data.collapsible = true
 end

 table.insert(data.classes, args.class)
 
 -- Image
 if args.image and args.image ~= 'none' then
  data.image = args.image
 end
 
 -- we have to check to see if a downstream use has plainlist like
 -- Template:Sister_project. also it's the default. wikitext is :(
 if args.textclass == 'plainlist' or not args.textclass then
  data.textclass = 'plainlist'
  data.plainlist_templatestyles = 'Plainlist/styles.css'
 else
  data.textclass = args.textclass
 end

 -- Copy over data that does not need adjusting
 local argsToCopy = {
  -- aria qualities
  'role',
  'labelledby',

  -- Styles
  'style',
  'textstyle',
  'templatestyles',

  -- Above row
  'above',
  'abovestyle',

  -- Body row
  'text',
  'imageright',

  -- Below row
  'below',
 }
 for i, key in ipairs(argsToCopy) do
  data[key] = args[key]
 end

 return data
end

local function renderSidebox(data)
 -- Renders the sidebox HTML.

 -- Table root
 local root = mw.html.create('div')
 root:attr('role', data.role)
  :attr('aria-labelledby', data.labelledby)
  :addClass('side-box')
 for i, class in ipairs(data.classes or {}) do
  root:addClass(class)
 end
 if data.style then
  root:cssText(data.style)
 end
 
 local frame = mw.getCurrentFrame()
 if data.plainlist_templatestyles then
  root:wikitext(frame:extensionTag{
   name = 'templatestyles', args = { src = data.plainlist_templatestyles }
  })
 end

 -- The "above" row
 if data.above then
  local above = root:newline():tag('div')
  above:addClass('side-box-abovebelow')
   :newline()
   :wikitext(data.above)
  if data.textstyle then
   above:cssText(data.textstyle)
  end
  if data.abovestyle then
   above:cssText(data.abovestyle)
  end
 end

 -- The body row
 local body = root:newline():tag('div')
  body:addClass('side-box-flex')
   :addClass(data.collapsible and 'mw-collapsible-content')
   :newline()
 if data.image then
  body:tag('div')
   :addClass('side-box-image')
   :wikitext(data.image)
 end
 local text = body:newline():tag('div')
 text:addClass('side-box-text')
  :addClass(data.textclass)
 if data.textstyle then
  text:cssText(data.textstyle)
 end
 text:wikitext(data.text)
 if data.imageright then
  body:newline():tag('div')
   :addClass('side-box-imageright')
   :wikitext(data.imageright)
 end

 -- The below row
 if data.below then
  local below = root:newline():tag('div')
  below
   :addClass('side-box-abovebelow')
   :wikitext(data.below)
  if data.textstyle then
   below:cssText(data.textstyle)
  end
 end

 root:newline()
 local templatestyles = ''
 if data.templatestyles then
  templatestyles = frame:extensionTag{
   name = 'templatestyles', args = { src = data.templatestyles }
  }
 end
 return frame:extensionTag{
  name = 'templatestyles', args = { src = 'Module:Side box/styles.css' }
 } .. templatestyles .. tostring(root)
end

function p._main(args)
 local data = makeData(args)
 return renderSidebox(data)
end

function p.main(frame)
 local origArgs = frame:getParent().args
 local args = {}
 for k, v in pairs(origArgs) do
  v = v:match('%s*(.-)%s*$')
  if v ~= '' then
   args[k] = v
  end
 end
 return p._main(args)
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Side_box&oldid=1127149393"

Categories: 
Modules subject to page protection
Templates using TemplateStyles
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 13 December 2022, at 04:33 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki