مودول:Lua banner
السيفة
يمكن إنشاء صفحة توثيق الوحدة في مودول:Lua banner/شرح
-- This module implements the {{lua}} template.
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)
if args.nocat and args.nocat ~= '' then
end
if trackingCategories and trackingCategories ~= "" then
trackingCategories = mw.getCurrentFrame():preprocess('{{#تبديل:{{SUBPAGENAME}}|تيران د الرملة|تيران|doc|لابو|نسخة|تجربة|شرح=|#default='.. trackingCategories .. "}}")
end
return box .. (trackingCategories or '')
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 = 'هاد لموضيل كيخدّم [[ ويكيپيديا:لووا|لووا]]:\n' .. moduleList
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[فيشي:Lua-logo-nolabel.svg|30px|alt=Lua logo|link= ويكيپيديا:لووا]]'
return mMessageBox.main('mbox', boxArgs)
end
function p.renderTrackingCategories(args, modules, titleObj)
if yesno(args.nocat) then
return ''
end
local cats = {}
-- Error category
if #modules < 1 then
cats[#cats + 1] = 'Lua templates with errors'
end
local categories = {
['Module:String'] = 'موضيلات مبازيين على مودول String',
['Module:Math'] = 'موضيلات مبازيين على مودول Math Lua',
['Module:BaseConvert'] = 'موضيلات مبازيين على مودول BaseConvert Lua',
['Module:Citation'] = 'موضيلات د لمراجع مبازيين على مودول د لووا',
['Module:Citation/CS1'] = 'موضيلات د لمراجع مبازيين على مودول د لووا',
['مودول:تحويلات بلدان'] = 'موضيلات مبازيين على تحويلات بلدان',
['على:Flagg'] = 'موضيلات مبازيين على مودول:Flagg',
['Module:Flagg'] = 'موضيلات مبازيين على مودول:Flagg'
}
-- Lua templates category
titleObj = titleObj or mw.title.getCurrentTitle()
local subpageBlacklist = {
['doc'] = true,
['شرح'] = true,
['تيران'] = true,
['تيران د الرملة'] = true,
['تيران2'] = true,
['حالات'] = true,
['لابو'] = true
}
if titleObj.namespace == 10
and not subpageBlacklist[titleObj.subpageText]
then
for i, Module in ipairs(modules) do
mw.log( Module )
local cate = categories[ Module ]
if not cate and mw.ustring.find( Module , "مودول:ب.ص.م", 1, true ) then
cate = "موضيلات د مودول:ب.ص.م"
end
if not cate and mw.ustring.find( Module , "Flagg", 1, true ) then
cate = 'موضيلات مبازيين على مودول:Flagg'
end
if cate and cate ~= "" then
cats[#cats + 1] = cate
end
end
end
if #cats < 1 then
cats[#cats + 1] = 'موضيلات خدامين ب مودولات د لوا'
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[تصنيف:%s]]', cat)
end
return table.concat(cats)
end
return p