پرش به محتوا

پودمان:Shortcut: تفاوت میان نسخه‌ها

۶۰۲ بایت حذف‌شده ،  ‏۱۲ ژوئیهٔ ۲۰۲۳
جز
خنثی‌سازی نسخهٔ 164529 از Heydari (بحث)
جزبدون خلاصۀ ویرایش
برچسب: برگردانده‌شده
جز (خنثی‌سازی نسخهٔ 164529 از Heydari (بحث))
برچسب: خنثی‌سازی
خط ۱۵: خط ۱۵:


local function makeCategoryLink(cat)
local function makeCategoryLink(cat)
return mw.ustring.format('[[%s:%s]]', mw.site.namespaces[14].name, cat)
return string.format('[[%s:%s]]', mw.site.namespaces[14].name, cat)
end
end


خط ۲۴: خط ۲۴:
frame = frame or mw.getCurrentFrame()
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = (options.template or options['الگو']) and (yesno(options.template) or yesno(options['الگو']))
local templateMode = options.template and yesno(options.template)
local redirectMode = (options.redirect or options['تغییرمسیر']) and (yesno(options.redirect) or yesno(options['تغییرمسیر']))
local redirectMode = options.redirect and yesno(options.redirect)
local isCategorized = (not options.category) or (not options['رده']) or (yesno(options.category) ~= false) or (yesno(options['رده']) ~= false)
local isCategorized = not options.category or yesno(options.category) ~= false


-- Validate shortcuts
-- Validate shortcuts
خط ۴۸: خط ۴۸:
templatePath = shortcut
templatePath = shortcut
end
end
prefix = options['pre' .. i] or options.pre or options['پیشوند'] or ''
prefix = options['pre' .. i] or options.pre or ''
end
end
if (options.target or options['مقصد']) and (yesno(options.target) or yesno(options['مقصد'])) then
if options.target and yesno(options.target) then
listItems[i] = templateMode
listItems[i] = templateMode
and mw.ustring.format("{{%s[[%s|%s]]}}", prefix, templatePath, shortcut)
and string.format("{{%s[[%s|%s]]}}", prefix, templatePath, shortcut)
or mw.ustring.format("[[%s]]", shortcut)
or string.format("[[%s]]", shortcut)
else
else
listItems[i] = frame:expandTemplate{
listItems[i] = frame:expandTemplate{
title = 'تغییرمسیر ممنوع',
title = 'No redirect',
args = templateMode and {templatePath, shortcut} or {shortcut, shortcut}
args = templateMode and {templatePath, shortcut} or {shortcut, shortcut}
}
}
if templateMode then
if templateMode then
listItems[i] = mw.ustring.format("{{%s%s}}", prefix, listItems[i])
listItems[i] = string.format("{{%s%s}}", prefix, listItems[i])
end
end
end
end
end
end
table.insert(listItems, (options.msg or options['پیام']))
table.insert(listItems, options.msg)


-- Return an error if we have nothing to display
-- Return an error if we have nothing to display
if #listItems < 1 then
if #listItems < 1 then
local msg = cfg['no-content-error']
local msg = cfg['no-content-error']
msg = mw.ustring.format('<strong class="error">%s</strong>', msg)
msg = string.format('<strong class="error">%s</strong>', msg)
if isCategorized and cfg['no-content-error-category'] then
if isCategorized and cfg['no-content-error-category'] then
msg = msg .. makeCategoryLink(cfg['no-content-error-category'])
msg = msg .. makeCategoryLink(cfg['no-content-error-category'])
خط ۷۷: خط ۷۷:


local root = mw.html.create()
local root = mw.html.create()
root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = 'میانبر/styles.css'} })
root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = 'Shortcut/styles.css'} })
-- Anchors
-- Anchors
local anchorDiv = root
local anchorDiv = root
خط ۱۰۵: خط ۱۰۵:
:addClass('module-shortcutboxplain plainlist noprint')
:addClass('module-shortcutboxplain plainlist noprint')
:attr('role', 'note')
:attr('role', 'note')
if (options.float and (options.float:lower() == 'right' or options.float == 'راست')) or (options['شناور'] and (options['شناور']:lower() == 'right' or options['شناور'] == 'راست')) then
if options.float and options.float:lower() == 'left' then
shortcutList:addClass('module-shortcutboxright')
shortcutList:addClass('module-shortcutboxleft')
end
end
if (options.clear and options.clear ~= '') or (options['پاک‌کن'] and options['پاک‌کن'] ~= '') then
if options.clear and options.clear ~= '' then
shortcutList:css('clear', (options.clear or options['پاک‌کن']))
shortcutList:css('clear', options.clear)
end
end
if shortcutHeading then
if shortcutHeading then