Module:Message box: Difference between revisions

Jump to navigation Jump to search
pass nocat, page, and demospace parameters to Module:Category handler, and add a choice for which arguments to allow as blank
(add mbox, various other fixes)
(pass nocat, page, and demospace parameters to Module:Category handler, and add a choice for which arguments to allow as blank)
Line 88:
 
local function getNamespaceId(ns)
if not ns then return end
if type(ns) == 'string' then
ns = lang:ucfirst(mw.ustring.lower(ns))
Line 124 ⟶ 125:
 
-- Get the title object and the namespace.
local titlepageTitle = getTitleObject(args.page) or~= mw'' and args.title.getCurrentTitle(page)
local nsidtitle = getNamespaceId(args.demospace)pageTitle or mw.title.namespacegetCurrentTitle()
local demospace = getNamespaceId(args.demospace ~= '' and args.demospace)
local nsid = demospace or title.namespace
 
-- Get the box config data from the data page.
Line 141 ⟶ 144:
error(format('invalid message box type "%s"; valid types are %s', tostring(boxType), mw.text.listToText(boxTypes)), 2)
end
-- Only allow blank arguments for the parameter names listed in data.allowBlankParams.
local newArgs = {}
for k, v in pairs(args) do
for i, param in ipairs(data.allowBlankParams or {}) do
if v ~= '' or args[k] == vparam then
newArgs[k] = v
end
end
end
args = newArgs
newArgs = nil
 
------------------------ Process config data ----------------------------
Line 222 ⟶ 237:
if data.allowMainspaceCategories then
-- Categories for the main namespace.
if args.cat then
args.cat1 = args.cat
end
local origCatNums = getArgNums(args, 'cat')
if args.category then
args.category1 = args.category
end
local origCategoryNums = getArgNums(args, 'category')
local catNums = union(origCatNums, origCategoryNums)
Line 233 ⟶ 254:
 
-- Process template namespace categories
local isTemplatePage = type(name) == 'string' and title.prefixedText == ('Template:' .. name)
local templateCats = {}
if data.templateCategory and not title.isSubpage and not yesno(args.nocat) then
if name then
tinsert(templateCats, format('[[Category:%s]]', data.templateCategory))
if isTemplatePage then
tinsert(templateCats, format('[[Category:%s]]', data.templateCategory))
end
elseif not title.isSubpage then
tinsert(templateCats, format('[[Category:%s]]', data.templateCategory))
end
end
 
-- Add an error category for the template namespace if appropriate.
if data.templateErrorCategory then
Line 387 ⟶ 415:
main = tconcat(mainCats),
template = tconcat(templateCats),
all = tconcat(allCats),
nocat = args.nocat,
demospace = demospace and args.demospace or nil,
page = pageTitle and pageTitle.prefixedText or nil
})
Line 415 ⟶ 446:
v = mw.text.trim(v)
end
if v ~= '' or args[k] == 'talk' or k == 'sect' or k == 'date' thenv
args[k] = v
end
end
return p.build(boxType, args)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu