Changes

Jump to navigation Jump to search
244 bytes added ,  13:26, 11 July 2020
use live config instead of sandbox one
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local TNT = require('Module:TNT')
local p = {}
 
local function format(msg)
return TNT.format('I18n/Lua banner', msg)
end
 
local function getConfig()
return mw.loadData('Module:Lua banner/config')
end
function p.main(frame)
end
function p._main(args, cfg)
local modules = mTableTools.compressSparseArray(args)
local box = p.renderBox(modules, cfg) local trackingCategories = p.renderTrackingCategories(args, modules, nil, cfg)
return box .. trackingCategories
end
function p.renderBox(modules, cfg)
local boxArgs = {}
if #modules < 1 then
cfg = cfg or getConfig() if cfg['allow_wishes'] then boxArgs.text = format('wishtext') else boxArgs.text = string.format('<strong class="error">Error: no modules specified%s</strong>', format('error_emptylist')) end
else
local moduleLinks = {}
end
local moduleList = mList.makeList('bulleted', moduleLinks)
boxArgs.text = format('header') .. 'Uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = string.format( '[[File:Lua-logo-nolabel.svg|30px|alt=Lua logo%s|link=Wikipedia:Lua%s]]', format('logo_alt'), format('logo_link') )
return mMessageBox.main('mbox', boxArgs)
end
function p.renderTrackingCategories(args, modules, titleObj, cfg)
if yesno(args.nocat) then
return ''
end
cfg = cfg or getConfig()
local cats = {}
-- Error category
if #modules < 1 and not cfg['allow_wishes'] and cfg['error_category'] then cats[#cats + 1] = cfg['Lua templates with errorserror_category']
end
-- Lua templates category
titleObj = titleObj or mw.title.getCurrentTitle()
local subpageBlacklist = {
doc = true,
sandbox = true,
sandbox2 = true,
testcases = true
}
if titleObj.namespace == 10
and not subpageBlacklistcfg['subpage_blacklist'][titleObj.subpageText]
then
local category = args.category
if not category then
local categories pagename = {modules[1] and mw.title.new(modules[1]) category = pagename and cfg['Module:Stringmodule_categories'] = 'Lua String-based templates', ['Module:Math'pagename.text] = 'Templates based on the Math Lua module', if not category then if cfg['Module:BaseConvertallow_wishes'] and #modules < 1 then category = 'Templates based on the BaseConvert Lua module', cfg['Module:Citationwish_category'] = 'Lua-based citation templates' } else categories['Module:Citation/CS1'] category = categoriescfg['Module:Citationdefault_category'] end end end if category = modules[1] and categories[modulesthen cats[#cats + 1]] category = category or 'Lua-based templates'
end
cats[#cats + 1] = category
end
Anonymous user

Navigation menu