Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Izno
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} function p.file() --frame local image = 'File:US 730.svg' local title = mw.title.new(image) local width = title.file.width local height = title.file.height return string.format('%s width: %d, height: %d', image, width, height) end function p.basic_iteration(frame) local pv = require('Module:If preview') local t = { 'a', 'b', 'c', 'd', } local t2 = { a = 'a', b = 'b', c = 'c', d = 'd' } local preview = '' for _, v in ipairs(t) do -- guarantees ordering preview = preview .. pv._warning({ v }) end for _, v in pairs(t2) do -- doesn't guarantee ordering preview = preview .. pv._warning({ v }) end return preview end local function has_navbar() return true end function p.addListStyles() local frame = mw.getCurrentFrame() -- TODO?: Should maybe take a table of classes for e.g. hnum, hwrap as above -- I'm going to do the stupid thing first though -- Also not sure hnum and hwrap are going to live in the same TemplateStyles -- as hlist local function _addListStyles(htmlclass, templatestyles) local class_args = { -- rough order of probability of use 'bodyclass', 'listclass', 'aboveclass', 'belowclass', 'titleclass', 'navboxclass', 'groupclass', 'titlegroupclass', 'imageclass' } local patterns = { '^' .. htmlclass .. '$', '%s' .. htmlclass .. '$', '^' .. htmlclass .. '%s', '%s' .. htmlclass .. '%s' } local found = false for _, arg in ipairs(class_args) do for _, pattern in ipairs(patterns) do if mw.ustring.find(frame.args[arg] or '', pattern) then found = true break end end if found then break end end if found then return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles } } else return '' end end local hlist_styles = '' if not has_navbar() then hlist_styles = _addListStyles('hlist', 'Flatlist/styles.css') end local plainlist_styles = _addListStyles('plainlist', 'Plainlist/styles.css') return hlist_styles .. plainlist_styles end local msg = mw.message.newRawMessage function p.message(frame) local messages = {} table.insert(messages, 'This is an inserted message') local msg1 = msg('This is a $1 message.', 'raw') local msg2 = msg('This is a $1 message of $2 quality.', '[[raw]]', '{{icon|fa}}') local msg3 = msg('This is a $1 message of $2 quality.', '[[raw]]', '{{icon|fa}}'):plain() if frame.args[1] then table.insert(messages, frame.args[1]) end return -- tostring(messages) .. '\n\n' .. -- this prints string 'table' table.concat(messages) .. tostring(msg1) .. '\n\n' .. tostring(msg2) .. '\n\n' .. tostring(msg3) end function p.output() local obj = mw.html.create() obj:wikitext(p.addListStyles()) return obj end function p.tostringnil() return tostring(nil) end function p.remove_disallowed_css(s) local disallowed_css = { 'border', -- border 'border%-.+', -- border subproperties 'background', -- background 'background%-.+', -- background subproperties 'box%-shadow', -- box-shadow 'padding', -- padding 'padding%-.+', -- padding subproperties } local split_rules = mw.text.split(s, ';') local super_split = {} for k, v in ipairs(split_rules) do split_rules[k] = mw.text.trim(v) super_split[k] = mw.text.split(v, ':') end for k, t in ipairs(super_split) do for _, v in ipairs(disallowed_css) do if mw.text.trim(t[1]):lower():match(v) then table.remove(split_rules, k) break -- because we are done with the kth table end end end return table.concat(split_rules, ';') end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Izno/doc
(
edit
)