Module:CanonOrLive

-- --- --                             Module:CanonOrLive -- -- This module renders the icons in the top-right corner of articles, as well -- as the Canon and Legends tabs for pages with a Canon/Live Events counterpart. -- It also formats the page title with. It is a rewrite of -- Template:CanonOrLive. --- local DEBUG_MODE = false -- if true, errors are not caught --- -- Icon data --- -- -- This table stores data for all the icons displayed in the top-right. It can -- have the following fields: -- * image - the icon image name, minus any "File:" prefix (required). -- * tooltip - the icon tooltip (optional). -- * link - the page to link from the icon (optional). -- * category - a category to go with the icon, minus any "Category:" prefix --    (optional). -- * protectionAction - for protection icons, an action such as "edit" or "move" --     to check (optional). -- * protectionLevel - for protection icons, the protection level to check, --     such as "sysop". If the page doesn't have the right protection level --     it is put in a tracking category and the icon is not displayed --     (optional). -- Note: this is just a convenient place to store the data. The subtables are -- accessed from the code manually, so adding new subtables won't automatically -- add new icons, and removing subtables may break things. -- --- -- Helper functions --- -- Find whether the specified page exists. We use pcall to catch errors if we -- are over the expensive parser function count limit, or a number of other -- juicy errors. This function increases the expensive parser function count -- for every new page called. local function exists(page) local success, title = pcall(mw.title.new, page) return success and title and title.exists or false end -- This is the function accessed from wikitext. It must be accessed through -- a template. The template should transclude only the text -- "", and then when that template is used, any arguments -- passed to it are magically sent through to the module. function p.main(frame) local args = {} for k, v in pairs(frame:getParent.args) do		v = v:match('^%s*(.-)%s*$') -- trim whitespace if v ~= '' then args[k] = v		end end return p._main(args) end return p -- --