پودمان:Redirect template: تفاوت میان نسخهها
fa>Jeeputer جز (تنظیمات محافظت «پودمان:Redirect template» را تغییر داد: بیش از ۲۱۲ هزار تراگنجانش ([ویرایش=تنها مدیران] (بیپایان) [انتقال=تنها مدیران] (بیپایان))) |
Nazarzadeh (بحث | مشارکتها) جز (۱ نسخه واردشده) |
نسخهٔ کنونی تا ۱۵ آوریل ۲۰۲۴، ساعت ۱۱:۵۰
توضیحات این پودمان میتواند در پودمان:Redirect template/توضیحات قرار گیرد.
require('strict') local p = {} -- key is beginning of arg name. value is table with namespace number and link -- alternatively, a function taking the namespace number and returning a validity -- can be used local namespaceCategories = { all = { function() return true end }, ['همه'] = { function() return true end }, main = { 0, '[[ویکیپدیا:مقاله چیست؟|اصلی]]' }, ['اصلی'] = { 0, '[[ویکیپدیا:مقاله چیست؟|اصلی]]' }, help = { 12, '[[ویکیپدیا:فضای نام راهنما|راهنما]]' }, ['راهنما'] = { 12, '[[ویکیپدیا:فضای نام راهنما|راهنما]]' }, portal = { 100, '[[ویکیپدیا:درگاه|درگاه]]' }, ['درگاه'] = { 100, '[[ویکیپدیا:درگاه|درگاه]]' }, talk = { function(n) return n > 0 and n%2 == 1 end, '[[راهنما:صفحه بحث|بحث]]' }, ['بحث'] = { function(n) return n > 0 and n%2 == 1 end, '[[راهنما:صفحه بحث|بحث]]' }, template = { 10, '[[ویکیپدیا:فضای نام الگو|الگو]]' }, ['الگو'] = { 10, '[[ویکیپدیا:فضای نام الگو|الگو]]' }, wikipedia = { 4, '[[ویکیپدیا:فضای نام ویکیپدیا|پروژه ویکیپدیا]]' }, ['ویکیپدیا'] = { 4, '[[ویکیپدیا:فضای نام ویکیپدیا|پروژه ویکیپدیا]]' }, category = { 14, '[[ویکیپدیا:ردهبندی|رده]]' }, ['رده'] = { 14, '[[ویکیپدیا:ردهبندی|رده]]' }, user = { 2, '[[ویکیپدیا:صفحههای کاربری|کاربر]]' }, ['کاربر'] = { 2, '[[ویکیپدیا:صفحههای کاربری|کاربر]]' }, } -- remove whitespaces from beginning and end of args local function valueFunc(key, val) if type(val) == 'string' then val = mw.ustring.match(val, '^%s*(.-)%s*$') if val == '' then return nil end end return val end local function getPrettyName(args) for k in pairs(namespaceCategories) do if args[k .. ' category'] or args['رده ' .. k] then return mw.ustring.format("'''[[:رده:%s|%s]]''': ", args[k .. ' category'] or args['رده ' .. k], args.name) end end return mw.ustring.format("'''%s''': ", args.name) end function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = 'الگو:الگوی تغییرمسیر', valueFunc = valueFunc}) local namespace = mw.title.getCurrentTitle().namespace --- Local arguments if args['از'] then args.from = args['از'] end if args['اطلاعات'] then args.info = args['اطلاعات'] end if args['به'] then args.to = args['به'] end if args['ترتیب'] then args.sortkey = args['ترتیب'] end if args['تعبیه'] then args.embed = args['تعبیه'] end if args['رده دیگر'] then args['other category'] = args['رده دیگر'] end if args['شناسه'] then args.id = args['شناسه'] end if args['قابل چاپ'] then args.printworthy = args['قابل چاپ'] end if args['نام'] then args.name = args['نام'] end --- XXX: this is a HORRIBLE HACK. kill it with fire as soon as https://bugzilla.wikimedia.org/show_bug.cgi?id=12974 is fixed local beCompatibleWithBug12974 = args.info and (mw.ustring.find(args.info, '^[:;#*]', 1) == 1 or mw.ustring.find(args.info, '{|', 1, true) == 1) and '\n' or ' ' local content = mw.ustring.format('\n<div class="rcat %s">\n*%sاین یک تغییرمسیر است%s%s.%s%s\n</div>', args.id and ('rcat-' .. mw.ustring.gsub(args.id, ' ', '_')) or '', args.name and getPrettyName(args) or '', args.from and (' از ' .. args.from) or '', args.to and (' به ' .. args.to) or '', args.info and beCompatibleWithBug12974 or '', args.info or '' ) for k,v in pairs(namespaceCategories) do if args[k .. ' category'] or args['رده ' .. k] then if type(v[1]) == 'function' and v[1](namespace) or v[1] == namespace then if args.sortkey then content = content .. mw.ustring.format('[[رده:%s|%s]]', args[k .. ' category'] or args['رده ' .. k], args.sortkey) else content = content .. mw.ustring.format('[[رده:%s]]', args[k .. ' category'] or args['رده ' .. k]) end elseif args['other category'] then if args.sortkey then content = content .. mw.ustring.format('[[رده:%s|%s]]', args['other category'], args.sortkey) else content = content .. mw.ustring.format('[[رده:%s]]', args['other category']) end else content = content .. frame:expandTemplate{title = 'الگوی تغییرمسیر نادرست', args = {v[2]}} end end end if namespace == 0 then local yesno = require('Module:Yesno') if yesno(args.printworthy) == true then return content .. '[[رده:تغییرمسیرهای قابل چاپ]]' elseif yesno(args.printworthy) == false then return content .. '[[رده:تغییرمسیرهای فاقد ارزش چاپ]]' end end return content end return p