Module:Sandbox/BearBin/VNG
< Module:Sandbox | BearBin
跳到导航
跳到搜索
本模板用于生成使用{{supu}}显示的Template:萌百视觉小说研究会,用户数据存放于Module:Sandbox/BearBin/VNG/data。
源代码改自Module:UserGroup。
{{#invoke:nav|box
|name = 萌百视觉小说研究会
|title = {{coloredlink|#FFFFFF|Template:萌百视觉小说研究会|萌娘百科视觉小说研究会}}
|titlestyle = background:#B399FF;color:#FFFFFF
|groupstyle = background:#B399FF;color:#FFFFFF
|state = {{#ifeq:{{{1}}}|collapsed|mw-collapsed|mw-uncollapsed}}
|group1 = 萌百维护人员
|list1={{#invoke:Sandbox/BearBin/VNG|maintainer}}
|group2 = 优编与荣维
|list2={{#invoke:Sandbox/BearBin/VNG|autoreviewers}}
|group3 = 自动确认用户
|list3={{#invoke:Sandbox/BearBin/VNG|autoconfirmed}}
}}
|
--[[来自Module:UserGroup的低水平复制(悲 ]] local luaq = require("Module:Luaq") -- 加载查询模块。 local module = {} local data = mw.text.jsonDecode(mw.title.new("Module:Sandbox/BearBin/VNG/data"):getContent()) local order = { "maintainer", -- 萌百维护人员 "autoreviewers", -- 优编和荣维 "autoconfirmed" -- 自动确认用户 } function table.indexof(t, item) for i, v in ipairs(t) do if v == item then return i end end return 0 end local getGroups = function(filter) return luaq.iasQuery(mw.text.split(filter, "%s+")) :select(function(_, name) return alias[name] or name end) :distinct() :orderBy(function(aname) return table.indexof(order, aname) end) :where(function(_, aname) return data[aname] ~= nil end) :select(function(_, aname) return data[aname] end) :query() end local UserGroupInfo = function(group, frame) local parent = frame:getParent() if parent and parent:getTitle() == "Template:UserGroup" then frame = parent end local list = {} for key, val in ipairs(group) do if mw.text.trim(val) ~= "" then table.insert(list, frame:expandTemplate{ title = "supu", args = { val } }) end end return table.concat(list, " • ") end for gname, g in pairs(data) do module[gname] = function(frame) return UserGroupInfo(g, frame) end end return module