جز
۱ نسخه واردشده
بدون خلاصۀ ویرایش |
جز (۱ نسخه واردشده) |
||
| خط ۴: | خط ۴: | ||
local mTableTools = require('Module:TableTools') | local mTableTools = require('Module:TableTools') | ||
local mMessageBox = require('Module:Message box') | local mMessageBox = require('Module:Message box') | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
| خط ۲۸: | خط ۱۹: | ||
end | end | ||
function p._main(args | function p._main(args) | ||
local tStyles = mTableTools.compressSparseArray(args) | local tStyles = mTableTools.compressSparseArray(args) | ||
local box = p.renderBox(tStyles) | local box = p.renderBox(tStyles) | ||
| خط ۳۸: | خط ۲۹: | ||
local boxArgs = {} | local boxArgs = {} | ||
if #tStyles < 1 then | if #tStyles < 1 then | ||
boxArgs.text = | boxArgs.text = '<strong class="error">خطا: هیچ الگوسبکی مشخص نشده</strong>' | ||
else | else | ||
local tStylesLinks = {} | local tStylesLinks = {} | ||
for i, ts in ipairs(tStyles) do | for i, ts in ipairs(tStyles) do | ||
local sandboxLink = nil | local sandboxLink = nil | ||
local tsTitle = mw.title.new(ts) | local tsTitle = mw.title.new(ts) | ||
if tsTitle | if tsTitle then | ||
local tsSandboxTitle = mw.title.new(string.format( | local tsSandboxTitle = mw.title.new(string.format('%s:%s/تمرین/%s', tsTitle.nsText, tsTitle.baseText, tsTitle.subpageText)) | ||
if tsSandboxTitle and tsSandboxTitle.exists then | if tsSandboxTitle and tsSandboxTitle.exists then | ||
sandboxLink = format(' | sandboxLink = string.format(' ([[:%s|تمرین]])', tsSandboxTitle.prefixedText) | ||
end | end | ||
end | end | ||
tStylesLinks[i] = sandboxLink or | tStylesLinks[i] = string.format('[[:%s]]%s', ts, sandboxLink or '') | ||
end | end | ||
local tStylesList = mList.makeList('bulleted', tStylesLinks) | local tStylesList = mList.makeList('bulleted', tStylesLinks) | ||
boxArgs.text = | boxArgs.text = 'این ' .. | ||
mw.title.getCurrentTitle():inNamespaces(828,829) and ' | (mw.title.getCurrentTitle():inNamespaces(828,829) and 'پودمان' or 'الگو') .. | ||
'\n' .. tStylesList | ' از [[امامتپدیا:الگوسبک|الگوسبک]] استفاده میکند:\n' .. tStylesList | ||
end | end | ||
boxArgs.type = 'notice' | boxArgs.type = 'notice' | ||
boxArgs.small = true | boxArgs.small = true | ||
boxArgs.image = | boxArgs.image = '[[File:Farm-Fresh css add.svg|32px|alt=CSS]]' | ||
return mMessageBox.main('mbox', boxArgs) | return mMessageBox.main('mbox', boxArgs) | ||
end | end | ||
| خط ۷۰: | خط ۵۸: | ||
return '' | return '' | ||
end | end | ||
local cats = {} | local cats = {} | ||
-- Error category | -- Error category | ||
if #tStyles < 1 | if #tStyles < 1 then | ||
cats[#cats + 1] = | cats[#cats + 1] = 'الگوهای از الگوسبک استفاده میکند دارای خطا' | ||
end | end | ||
-- TemplateStyles category | -- TemplateStyles category | ||
titleObj = titleObj or mw.title.getCurrentTitle() | titleObj = titleObj or mw.title.getCurrentTitle() | ||
local subpageBlacklist = { | |||
doc = true, | |||
sandbox = true, | |||
sandbox2 = true, | |||
testcases = true | |||
} | |||
if (titleObj.namespace == 10 or titleObj.namespace == 828) | if (titleObj.namespace == 10 or titleObj.namespace == 828) | ||
and not | and not subpageBlacklist[titleObj.subpageText] | ||
then | then | ||
local category = args.category | local category = args.category | ||
if category then | if not category then | ||
category = category or 'الگوهایی که از الگوسبک استفاده میکنند' | |||
end | end | ||
if not yesno(args.noprotcat | cats[#cats + 1] = category | ||
if not yesno(args.noprotcat) then | |||
local currentProt = titleObj.protectionLevels["edit"] and titleObj.protectionLevels["edit"][1] or nil | local currentProt = titleObj.protectionLevels["edit"] and titleObj.protectionLevels["edit"][1] or nil | ||
local addedLevelCat = false | local addedLevelCat = false | ||
| خط ۹۶: | خط ۸۹: | ||
local tsTitleObj = mw.title.new(ts) | local tsTitleObj = mw.title.new(ts) | ||
local tsProt = tsTitleObj.protectionLevels["edit"] and tsTitleObj.protectionLevels["edit"][1] or nil | local tsProt = tsTitleObj.protectionLevels["edit"] and tsTitleObj.protectionLevels["edit"][1] or nil | ||
if | if tsProt ~= currentProt and not addedLevelCat then | ||
cats[#cats + 1] = "الگوهایی که از الگوسبک با سطح حفاظت متفاوت استفاده میکنند" | |||
cats[#cats + 1] = | |||
end | end | ||
if | if tsProt and not addedPadlockCat then | ||
local content = tsTitleObj:getContent() | local content = tsTitleObj:getContent() | ||
if not content:find( | if not content:find("{{pp-") then | ||
cats[#cats + 1] = | cats[#cats + 1] = "الگوهایی که از الگوسبک بدون آیکون قفل استفاده میکنند" | ||
addedPadlockCat = true | addedPadlockCat = true | ||
end | end | ||
| خط ۱۱۱: | خط ۱۰۳: | ||
end | end | ||
for i, cat in ipairs(cats) do | for i, cat in ipairs(cats) do | ||
cats[i] = string.format('[[ | cats[i] = string.format('[[رده:%s]]', cat) | ||
end | end | ||
return table.concat(cats) | return table.concat(cats) | ||