پودمان:Lua banner: تفاوت میان نسخهها
fa>Huji روزآمدسازی بر اساس ویکیپدیای انگلیسی |
Nazarzadeh (بحث | مشارکتها) جز ۱ نسخه واردشده |
||
(۶ نسخهٔ میانی ویرایش شده توسط ۴ کاربر نشان داده نشد) | |||
خط ۱: | خط ۱: | ||
-- This module implements the {{lua}} template. | -- This module implements the {{lua}} template. | ||
-- سطرهای ۳۷ تا ۴۰ این پودمان برای تغییر نام فضای نام از «Module» به «پودمان» تغییر کردهاند. در زمان بهروزرسانی دقت کنید | |||
local yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
خط ۳۴: | خط ۳۵: | ||
local moduleLinks = {} | local moduleLinks = {} | ||
for i, module in ipairs(modules) do | for i, module in ipairs(modules) do | ||
-- replace "Module" namespace prefix with "پودمان" | |||
if mw.ustring.find(module, '[Mm]odule', 1, false) then | |||
module = mw.ustring.gsub(module, '[Mm]odule', 'پودمان', 1) | |||
end | |||
moduleLinks[i] = string.format('[[:%s]]', module) | moduleLinks[i] = string.format('[[:%s]]', module) | ||
local maybeSandbox = mw.title.new(module .. '/تمرین') | |||
if maybeSandbox.exists then | |||
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|تمرین]])', maybeSandbox.fullText) | |||
end | |||
end | end | ||
local moduleList = mList.makeList('bulleted', moduleLinks) | local moduleList = mList.makeList('bulleted', moduleLinks) | ||
خط ۵۷: | خط ۶۷: | ||
return '' | return '' | ||
end | end | ||
local cats = {} | local cats = {} | ||
-- Error category | -- Error category | ||
if #modules < 1 then | if #modules < 1 then | ||
cats[#cats + 1] = 'الگو:لوآ همراه خطا' | cats[#cats + 1] = 'الگو:لوآ همراه خطا' | ||
end | end | ||
-- Lua templates category | -- Lua templates category | ||
titleObj = titleObj or mw.title.getCurrentTitle() | titleObj = titleObj or mw.title.getCurrentTitle() | ||
خط ۷۱: | خط ۸۱: | ||
sandbox = true, | sandbox = true, | ||
sandbox2 = true, | sandbox2 = true, | ||
testcases = true | testcases = true, | ||
['توضیحات'] = true, | |||
['تمرین'] = true, | |||
['آزمایشی'] = true, | |||
} | } | ||
local subPageName = subpageBlacklist[titleObj.subpageText] | |||
if not subPageName then | |||
then | local protCatName | ||
local category = args.category | if titleObj.namespace == 10 then | ||
local category = args.category | |||
if not category then | |||
local categories = { | |||
['Module:String'] = 'الگو:مبتنی بر لوآ رشته', | |||
['Module:Math'] = 'الگو:مبتنی بر لوآ ریاضی', | |||
['Module:Citation'] = 'الگو: | ['Module:BaseConvert'] = 'الگو:مبتنی بر لوآ تبدیل مبنا', | ||
['Module:Citation'] = 'الگو:ارجاعدهی مبتنی بر لوآ' | |||
} | |||
categories['Module:Citation/CS1'] = categories['Module:Citation'] | |||
category = modules[1] and categories[modules[1]] | |||
category = category or 'الگو:مبتنی بر لوآ' | |||
end | |||
cats[#cats + 1] = category | |||
protCatName = "الگو:مبتنی بر لوآ با سطح محافظت پایینتر" | |||
elseif titleObj.namespace == 828 then | |||
protCatName = "پودمانهای وابسته به پودمانهای دیگر با سطح محافظت پایینتر" | |||
end | |||
if not args.noprotcat and protCatName then | |||
local protLevels = { | |||
autoconfirmed = 1, | |||
extendedconfirmed = 2, | |||
templateeditor = 3, | |||
sysop = 4 | |||
} | } | ||
local currentProt | |||
if titleObj.id ~= 0 then | |||
-- id is 0 (page does not exist) if am previewing before creating a template. | |||
currentProt = titleObj.protectionLevels["edit"][1] | |||
end | |||
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end | |||
for i, module in ipairs(modules) do | |||
if module ~= "WP:libraryUtil" then | |||
local moduleProt = mw.title.new(module).protectionLevels["edit"][1] | |||
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end | |||
if moduleProt < currentProt then | |||
cats[#cats + 1] = protCatName | |||
break | |||
end | |||
end | |||
end | |||
end | end | ||
end | end | ||
for i, cat in ipairs(cats) do | for i, cat in ipairs(cats) do | ||
cats[i] = string.format('[[رده:%s]]', cat) | cats[i] = string.format('[[رده:%s]]', cat) |