Module:SandboxItem
From Net 7 Portal Wiki
More actions
Documentation for this module may be created at Module:SandboxItem/doc
local getArgs
local yesno = require('Module:Yesno')
local error = require('Module:Vrix').error
require('strict')
--------------------------------------------------------------------------------
-- Helper functions change
--------------------------------------------------------------------------------
local function _args(frame)
return nil
end
local function _file_link(image_title, link_contents)
return "[[File:" .. image_title .. ".png|link=" .. link_contents .. "|thumb|none|[[" .. link_contents .. "]]]]\n"
end
local function _file_link_caption(image_title, link_contents, caption)
return "[[File:" .. image_title .. ".png|link=" .. link_contents .. "|thumb|none|[[" .. link_contents .. "|" .. caption .. "]]]]\n"
end
local function _dual_file_link(image_title, link_contents, image2_title, link2_contents)
return "<table><tr><td>[[File:" .. image_title .. ".png|link=" .. link_contents .. "|thumb|none|[[" .. link_contents .. "]]]]</td><td width=250></td><td>[[File:" .. image2_title .. ".png|link=" .. link2_contents .. "|right]]</td></tr></table>\n"
end
local function _firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
local function _titleCaseHelper(first, rest)
return first:upper()..rest:lower()
end
local function _titleCase(str)
-- Add extra characters to the pattern if you need to. _ and ' are
-- found in the middle of identifiers and English words.
-- We must also put %w_' into [%w_'] to make it handle normal stuff
-- and extra stuff the same.
-- This also turns hex numbers into, eg. 0Xa7d4
return (str:gsub("(%a)([%w_']*)", _titleCaseHelper))
end
--------------------------------------------------------------------------------
-- Item class definition
--------------------------------------------------------------------------------
local Item = {}
Item.__index = Item
function Item.new(args)
local obj = {}
-- The category image and link block, if any (most are still hard-coded
-- directly on item pages across the wiki, so the only ones that show up here
-- are by category where all pages of that category have migrated to this
-- module.
obj.header = ""
-- This is the brief summary of the item, e.g. "Level X Item"
obj.brief = ""
-- This is the group of categories we will add to the page for this item.
obj.category = ""
obj.level = 777
obj.category = "[[Category:fish]]"
obj.brief = "Fishhy fish"
return setmetatable(obj, Item)
end
function Item:export()
return "Test string of testing"
end
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
local p, mt = {}, {}
function p._exportClasses()
-- For testing.
return {
Item = Item
}
end
function p.main(k, args)
local item = Item.new(args)
return item:export()
end
function mt.__index(t, k)
return function (frame)
return t.main(k, _args(frame))
end
end
return setmetatable(p, mt)