Editing
Module:Uses TNT
Jump to navigation
Jump to search
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!
-------------------------------------------------------------------------------- -- This module implements the {{Uses TNT}} template. -- -- @module usesTNT -- @alias p -- @author [[User:ExE Boss]] -- @require [[Module:Uses TNT/config]] -- @require [[Module:Arguments]] -- @require [[Module:Func]] -- @require [[Module:List]] -- @require [[Module:Message box]] -- @require [[Module:TNT]] -- @require [[Module:TNTTools]] -- @require [[Module:TableTools]] -- @require [[Module:Yesno]] -------------------------------------------------------------------------------- require("strict"); local checkType = require("libraryUtil").checkType; local getArgs = require("Module:Arguments").getArgs; local yesno = require("Module:Yesno"); local lists = require("Module:List"); local tableTools = require("Module:TableTools"); local messageBox = require("Module:Message box"); local TNTTabFull = require("Module:TNTTools").TNTTabFull; local format = require("Module:Func") .bind(require("Module:TNT").format, "I18n/Uses TNT.tab"); local p = {}; local function getConfig() return mw.loadData("Module:Uses TNT/config"); end function p.main(frame) local args = getArgs(frame, { wrappers = { "Template:Uses TNT", }, }); return p._main(args); end function p._main(args, cfg) checkType("_main", 1, args, "table"); checkType("_main", 2, cfg, "table", true); cfg = cfg or getConfig(); local tabFiles = tableTools.compressSparseArray(args); local box = p.renderBox(tabFiles, cfg, args); local trackingCategories = p.renderTrackingCategories(args, tabFiles, nil, cfg); return box .. trackingCategories; end function p.renderBox(tabFiles, cfg, args) checkType("renderBox", 1, tabFiles, "table"); checkType("renderBox", 2, cfg, "table", true); checkType("renderBox", 3, args, "table", true); cfg = cfg or getConfig(); local nsType = mw.title.getCurrentTitle():inNamespaces(828, 829) and 'module' or 'template'; local boxArgs = {}; if #tabFiles < 1 then if cfg["allow_wishes"] or yesno(args and args.wish) then boxArgs.text = format("wishtext-" .. nsType); else boxArgs.text = string.format('<strong class="error">%s</strong>', format("error-emptylist")); end else local tabFileLinks = {}; for i, tabFile in ipairs(tabFiles) do local tabFileFull = TNTTabFull(tabFile); tabFileLinks[i] = string.format("[[:c:Data:%s|%s]]", tabFileFull, tabFileFull); end local tabFilesList = lists.makeList("bulleted", tabFileLinks); boxArgs.text = format("header-" .. nsType) .. "\n" .. tabFilesList; end boxArgs.type = "notice"; boxArgs.small = true; boxArgs.image = cfg["logo_link"] and string.format("[[%s|%s]]", cfg["logo_link"], format("logo-alt")) or format("logo-alt"); return messageBox.main("mbox", boxArgs); end function p.renderTrackingCategories(args, tabFiles, titleObj, cfg) checkType("renderTrackingCategories", 1, args, "table"); checkType("renderTrackingCategories", 2, tabFiles, "table"); checkType("renderTrackingCategories", 3, titleObj, "table", true); checkType("renderTrackingCategories", 4, cfg, "table", true); if yesno(args.nocat) then return ''; end cfg = cfg or getConfig(); local cats = {}; -- Error category if #tabFiles < 1 and not (cfg["allow_wishes"] or yesno(args.wish)) and cfg["error_category"] then cats[#cats + 1] = cfg["error_category"]; end -- [[Module:TNT]] category titleObj = titleObj or mw.title.getCurrentTitle(); if ( (titleObj.namespace == 10 or titleObj.namespace == 828) and not cfg["subpage_blacklist"][titleObj.subpageText] ) then local category = args.category; if not category then if (cfg["allow_wishes"] or yesno(args.wish)) and #tabFiles < 1 then category = cfg["wish_category"]; else category = cfg["default_category"]; end end if category then cats[#cats + 1] = category; end end for i, cat in ipairs(cats) do cats[i] = string.format("[[Category:%s]]", cat); end return table.concat(cats); end return p;
Summary:
Please note that all contributions to FRC Archive Wiki 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
Frcwiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Uses TNT/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Upload file
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information