Editing
Module:InfoboxBuilder
Jump to navigation
Jump to search
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
local onmain = require('Module:Mainonly').on_main local editBtn = require('Module:Paramtest').editbtn local InfoboxBuilder = {} local htmlmt = getmetatable(mw.html.create()) local htmlindex = htmlmt.__index setmetatable(InfoboxBuilder, { -- Constructor for a new InfoboxBuilder object. __call = function(self, params, style) local params = params or 0 local ret = mw.html.create('div') :addClass("infobox") if style then ret:cssText(style) end if params > 1 then ret:addClass("tabber") if params > 2 then ret:addClass("dropdown") end end return ret end, __index = htmlindex, __tostring = htmlmt.__tostring }) htmlindex.title = function(self, value) return self:tag('div'):addClass("infobox-title"):wikitext(value):done() end htmlindex.header = function(self, value) return self:tag('div'):addClass("infobox-header"):wikitext(value):done() end htmlindex.group = function(self) return self:tag('div'):addClass("infobox-group") end htmlindex.image = function(self, args) local image = args.image local caption = args.caption local container = self:tag('div'):addClass('infobox-image-container') :tag('div'):addClass('infobox-image'):wikitext(image):done() if caption ~= nil then container:tag('div'):addClass('infobox-image-caption'):wikitext(caption):done() end return container:done() end htmlindex.getVersion = function(self, args) local versions = {} local i = 1 while args["name"..i] or args["version"..i] or args["perk"..i] do table.insert(versions, i) i = i + 1 end if #versions == 0 then versions = { '' } end return versions end htmlindex.releaseDate = function(self, releaseDate, update, page) if not releaseDate or not update then return editBtn(page) end local day, month, year = releaseDate:match("^(%d+)%s+(%a+)%s+(%d+)$") return string.format("[[%s %s]] [[%s]] ([[Update:%s|Update]])", day, month, year, update) end htmlindex.release = function(self, release, page) if not release then return editBtn(page) end local day, month, year = release:match("^(%d+)%s+(%a+)%s+(%d+)$") return string.format("[[%s %s]] [[%s]]", day, month, year) end htmlindex.removalDate = function(self, removalDate, removalUpdate) if not removalDate or not removalUpdate then return end local day, month, year = removalDate:match("^(%d+)%s+(%a+)%s+(%d+)$") return string.format("[[%s %s]] [[%s]] ([[Update:%s|Update]])", day, month, year, removalUpdate) end htmlindex.addMissCat = function(self, categories) if onmain() then local ret = {} for i, v in ipairs(categories) do if (v ~= '') then ret[i] = string.format('[[Category:%s]]',v) end end return table.concat(ret, "") or "" else return "" end end htmlindex.addTemplateCats = function (self, categories) local ret = '' for _, cat in ipairs(categories or {}) do ret = ret .. "[[Category:" .. cat .. "]]" end return ret end htmlindex.addCats = function (self, categories) local ret = '' if onmain() then if not categories then return ret end if type(categories) == "string" then categories = { categories } end for _, cat in ipairs(categories) do ret = ret .. "[[Category:" .. cat .. "]]" end end return ret end -- Wrap content with line breaks if it contains list-like wiki syntax function wrapContent(content) if type(content) == "string" then local firstListItem = math.min(content:find('^[*#]') or math.huge, content:find('\n[*#]') or math.huge) if firstListItem ~= math.huge then local suffix = content:find('\n[*#][^\n]+$') and '\n' or '' content = content:sub(1, firstListItem - 1) .. '\n' .. content:sub(firstListItem) .. suffix end end return content end htmlindex.row = function(self, args) local label = args.label local value = wrapContent(args.value) if value == nil or value == '' then return self end local row = self:tag('div'):addClass('infobox-row-container') if label and label ~= '' then row:tag('div'):addClass('infobox-row-label'):wikitext(label):done() return row :tag('div'):addClass('infobox-row-value') :tag('div'):addClass('infobox-row-value__inner'):wikitext(value):done() :done() :done() else row:css("display", "block") :css("width", "100%") :css("text-align", "left") return row :tag('div') :addClass('infobox-row-value') :css("float", "none") :css("width", "100%") :tag('div'):addClass('infobox-row-value__inner'):wikitext(value):css("text-align", "center"):css("width", "90%"):done() :done() :done() end end local Tabber = {} Tabber.__index = Tabber Tabber.__tostring = function(self) local ret = {} self:_build(ret) return table.concat(ret) end setmetatable(Tabber, {__index = htmlindex}) htmlindex.tabber = function(self, isDropdown) local obj = mw.html.create('div') obj.parent = self obj._isDropdown = isDropDown or false setmetatable(obj, Tabber) self:node(obj) return obj end function Tabber:_build(ret) local tabs = {} if self._isDropdown then local span = mw.html.create('span'):addClass('dropdown'):done() table.insert(ret, tostring(span)) end for i, tab in ipairs(self.nodes) do -- each node should be a tab table.insert(tabs, {name=tab.name, content=tostring(tab)}) end table.insert(ret, require('Module:Tabber').main(tabs)) end function Tabber:tab(name) local obj = self:tag('div'):addClass("infobox-tab") obj.name = name return obj end return InfoboxBuilder
Summary:
Please note that all contributions to RuneScape: Dragonwilds Wiki are considered to be released under the CC BY-NC-SA 3.0 (see
Dragonwilds:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Pages included on this page:
Template:Clear
(
edit
)
Template:DependencyList
(
edit
)
Template:Documentation
(
edit
)
Template:No documentation
(
edit
)
Template:PageType
(
edit
)
Module:Array
(
edit
)
Module:DPLlua
(
edit
)
Module:DependencyList
(
edit
)
Module:Documentation
(
edit
)
Module:InfoboxBuilder/doc
(
edit
)
Module:Infobox Armour
(
edit
)
Module:Infobox Bonus Perk
(
edit
)
Module:Infobox Build
(
edit
)
Module:Infobox Deity
(
edit
)
Module:Infobox Emote
(
edit
)
Module:Infobox Item
(
edit
)
Module:Infobox Item/sandbox
(
edit
)
Module:Infobox Jagex
(
edit
)
Module:Infobox Monster
(
edit
)
Module:Infobox Monster/sandbox
(
edit
)
Module:Infobox NPC
(
edit
)
Module:Infobox Perk
(
edit
)
Module:Infobox Quest
(
edit
)
Module:Infobox Resource Node
(
edit
)
Module:Infobox Scenery
(
edit
)
Module:Infobox Skill
(
edit
)
Module:Infobox Soundtrack
(
edit
)
Module:Infobox Spell
(
edit
)
Module:Infobox Spell/sandbox
(
edit
)
Module:Infobox Tool
(
edit
)
Module:Infobox Weapon
(
edit
)
Module:Mainonly
(
edit
)
Module:Paramtest
(
edit
)
Module:Sandbox
(
edit
)
Module:Tabber
(
edit
)
Module:Tooltip
(
edit
)
Module:User error
(
edit
)
Module:Yesno
(
edit
)
This page is a member of 2 hidden categories:
Category:Pages using DynamicPageList4 parser function
Category:Pages using DynamicPageList4
Navigation menu
Personal tools
Create account
Log in
associated-pages
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Discord
Discord
Navigation
Random page
Recent changes
New files
Mechanics
Player
Inventory
Items
Skills
Buildings
Spells
World
Ashenfall
Lore
Monsters
NPCs
Quests
Dragonkin
Community
How to edit
User help
Active discussions
Policies
More RuneScape
RuneScape Wiki
OSRS Wiki
RSC Wiki
RuneScape.com
Tools
What links here
Related changes
Page information
View buckets