打开/关闭搜索
搜索
打开/关闭菜单
14
6636
42
1.1万
OGAS数据中枢
导航
首页
最近更改
随机页面
特殊页面
上传文件
少女前线
简介
战术人形
装备图鉴
BGM
任务
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
注册
登录
查看“︁模块:Lua banner”︁的源代码
来自OGAS数据中枢
更多操作
←
模块:Lua banner
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
管理员
您可以查看和复制此页面的源代码。
local yesno = require('Module:Yesno') local mList = require('Module:List') local mTableTools = require('Module:TableTools') local mMessageBox = require('Module: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(frame, args) end function p._main(frame, args) local modules = mTableTools.compressSparseArray(args) -- 预处理:将参数统一格式为 Module:xxx for i = 1, #modules do modules[i] = 'Module:' .. mw.title.new(modules[i]).text end local box = p.renderBox(modules) local trackingCategories = p.renderTrackingCategories(args, modules) return box .. trackingCategories end -- if action=edit function p.main2(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 local modules = mTableTools.compressSparseArray(args) return p.renderBox(modules) end --end function p.renderBox(modules) local boxArgs = {} if #modules < 1 then boxArgs.text = '<strong class="error">錯誤:没有指定-{zh-hans:模块; zh-hant:模組;}-</strong>' else local moduleLinks = {} for i, module in ipairs(modules) do moduleLinks[i] = string.format('%s', module) moduleLinks[i] = '[[:' .. moduleLinks[i] .. ']]' end local moduleList = mList.makeList('bulleted', moduleLinks) boxArgs.text = '此' .. (mw.title.getCurrentTitle():inNamespaces(828,829) and '-{zh-hans:模块; zh-hant:模組;}-' or '模板') .. '使用[[Help:Lua|Lua語言]]:\n' .. moduleList end boxArgs.type = 'notice' boxArgs.small = true boxArgs.image = '[[File:Lua-logo.svg|30px|alt=|link=]]' return mMessageBox.main('mbox', boxArgs) end function p.renderTrackingCategories(args, modules, titleObj) if yesno(args.nocat) then return '' end -- 子页面标题在黑名单内则不添加分类 -- 例如{{Lua}}被嵌入到 Template:xxx/doc 时,只在 Template:xxx 添加分类,而不在 doc 添加分类 titleObj = titleObj or mw.title.getCurrentTitle() local subpageBlacklist = { doc = true, sandbox = true, sandbox2 = true, testcases = true } if subpageBlacklist[titleObj.subpageText] then return '' end local cats = {} -- 错误分类 if #modules < 1 then cats[#cats + 1] = '有错误的Lua模板' end local category = args.category -- 添加特殊分类 if not category then local categories = { ['Module:String'] = '使用String模块的模板', ['Module:Nav'] = '使用Nav模块的模板', --['Module:Math'] = '使用Math模块的模板', --['Module:BaseConvert'] = '使用BaseConvert模块的模板', --['Module:Citation'] = '使用Citation模块的模板' } categories['Module:Citation/CS1'] = categories['Module:Citation'] category = modules[1] and categories[modules[1]] category = category or 'x' end cats[#cats + 1] = category for i, cat in ipairs(cats) do cats[i] = string.gsub(string.format('[[Category:%s]]', cat), '%[%[Category:x%]%]', '') end -- 为防止[[Category:Lua模板]]泛滥,当只使用一个模块且添加了特殊分类后,不再添加[[Category:Lua模板]] -- 这尤其是为了防止上千个使用[[Module:Nav]]的模板涌入[[Category:Lua模板]](如果真的有人准备大量添加{{Lua|Nav}}) if #modules == 1 and category ~= 'x' then return table.concat(cats) else return table.concat(cats) .. '[[Category:Lua模板]]' end end return p
该页面嵌入的页面:
模块:Lua banner/doc
(
查看源代码
)
返回
模块:Lua banner
。
查看“︁模块:Lua banner”︁的源代码
来自OGAS数据中枢