м (Імпортовано 1 версія) |
|||
(Не показані 4 проміжні версії цього користувача) | |||
Рядок 30: | Рядок 30: | ||
local boxArgs = {} | local boxArgs = {} | ||
if #modules < 1 then | if #modules < 1 then | ||
− | boxArgs.text = '<strong class="error">Помилка: не | + | boxArgs.text = '<strong class="error">Помилка: не вказано модулі</strong>' |
else | else | ||
local moduleLinks = {} | local moduleLinks = {} | ||
Рядок 37: | Рядок 37: | ||
end | end | ||
local moduleList = mList.makeList('bulleted', moduleLinks) | local moduleList = mList.makeList('bulleted', moduleLinks) | ||
− | boxArgs.text = ' | + | boxArgs.text = 'Використовується [[Lua]]:\n' .. moduleList |
end | end | ||
boxArgs.type = 'notice' | boxArgs.type = 'notice' | ||
Рядок 63: | Рядок 63: | ||
sandbox = true, | sandbox = true, | ||
sandbox2 = true, | sandbox2 = true, | ||
− | testcases = true | + | testcases = true, |
+ | ['документація'] = true, | ||
+ | ['Документація'] = true, | ||
+ | ['пісочниця'] = true, | ||
+ | ['тести'] = true, | ||
+ | ['чернетка'] = true | ||
} | } | ||
if titleObj.namespace == 10 | if titleObj.namespace == 10 | ||
Рядок 72: | Рядок 77: | ||
local categories = { | local categories = { | ||
['Модуль:String'] = 'Шаблони, засновані на модулі String', | ['Модуль:String'] = 'Шаблони, засновані на модулі String', | ||
+ | ['Module:String'] = 'Шаблони, засновані на модулі String', | ||
['Модуль:Math'] = 'Шаблони, засновані на модулі Math', | ['Модуль:Math'] = 'Шаблони, засновані на модулі Math', | ||
+ | ['Module:Math'] = 'Шаблони, засновані на модулі Math', | ||
['Модуль:BaseConvert'] = 'Шаблони, засновані на модулі BaseConvert', | ['Модуль:BaseConvert'] = 'Шаблони, засновані на модулі BaseConvert', | ||
− | ['Модуль:Citation'] = 'Шаблони, засновані на модулі Citation' | + | ['Module:BaseConvert'] = 'Шаблони, засновані на модулі BaseConvert', |
+ | ['Модуль:Citation'] = 'Шаблони, засновані на модулі Citation', | ||
+ | ['Module:Citation'] = 'Шаблони, засновані на модулі Citation', | ||
+ | ['Модуль:Wikidata'] = 'Шаблони, які використовують Вікідані', | ||
+ | ['Module:Wikidata'] = 'Шаблони, які використовують Вікідані' | ||
} | } | ||
categories['Модуль:Citation/CS1'] = categories['Модуль:Citation'] | categories['Модуль:Citation/CS1'] = categories['Модуль:Citation'] |
This module implements the {{lua}} template.
This module cannot be used directly from wikitext. It can only be used through the {{lua}} template. Please see the template page for documentation.
To use this module from other Lua modules, first load the module.
local mLuaBanner = require('Module:Lua banner')
You can then generate a side box using the _main function.
mLuaBanner._main(args)
The args variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the {{lua}} template documentation.
-- Цей модуль забезпечує роботу шаблону {{lua}}.
local yesno = require('Модуль:Yesno')
local mList = require('Модуль:List')
local mTableTools = require('Модуль:TableTools')
local mMessageBox = require('Модуль:Message box')
local p = {}
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
function p._main(args)
local modules = mTableTools.compressSparseArray(args)
local box = p.renderBox(modules)
local trackingCategories = p.renderTrackingCategories(args, modules)
return box .. trackingCategories
end
function p.renderBox(modules)
local boxArgs = {}
if #modules < 1 then
boxArgs.text = '<strong class="error">Помилка: не вказано модулі</strong>'
else
local moduleLinks = {}
for i, module in ipairs(modules) do
moduleLinks[i] = string.format('[[:%s]]', module)
end
local moduleList = mList.makeList('bulleted', moduleLinks)
boxArgs.text = 'Використовується [[Lua]]:\n' .. moduleList
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[Файл:Lua-logo-nolabel.svg|30px|alt=Лого Lua|link=Вікіпедія:Lua]]'
return mMessageBox.main('mbox', boxArgs)
end
function p.renderTrackingCategories(args, modules, titleObj)
if yesno(args.nocat) then
return ''
end
local cats = {}
-- Категорія для помилок
if #modules < 1 then
cats[#cats + 1] = 'Шаблони Lua з помилками'
end
-- категорія Lua-шаблонів
titleObj = titleObj or mw.title.getCurrentTitle()
local subpageBlacklist = {
doc = true,
sandbox = true,
sandbox2 = true,
testcases = true,
['документація'] = true,
['Документація'] = true,
['пісочниця'] = true,
['тести'] = true,
['чернетка'] = true
}
if titleObj.namespace == 10
and not subpageBlacklist[titleObj.subpageText]
then
local category = args.category
if not category then
local categories = {
['Модуль:String'] = 'Шаблони, засновані на модулі String',
['Module:String'] = 'Шаблони, засновані на модулі String',
['Модуль:Math'] = 'Шаблони, засновані на модулі Math',
['Module:Math'] = 'Шаблони, засновані на модулі Math',
['Модуль:BaseConvert'] = 'Шаблони, засновані на модулі BaseConvert',
['Module:BaseConvert'] = 'Шаблони, засновані на модулі BaseConvert',
['Модуль:Citation'] = 'Шаблони, засновані на модулі Citation',
['Module:Citation'] = 'Шаблони, засновані на модулі Citation',
['Модуль:Wikidata'] = 'Шаблони, які використовують Вікідані',
['Module:Wikidata'] = 'Шаблони, які використовують Вікідані'
}
categories['Модуль:Citation/CS1'] = categories['Модуль:Citation']
category = modules[1] and categories[modules[1]]
category = category or 'Шаблони, які використовують модулі Lua'
end
cats[#cats + 1] = category
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Категорія:%s]]', cat)
end
return table.concat(cats)
end
return p