打开/关闭搜索
搜索
打开/关闭菜单
12.2K
18.1K
94
80.3K
导航
首页
最近更改
特殊页面
上传文件
随机页面
随机页面
随机歌曲
随机P主
编辑相关
帮助
讨论版
公共沙盒
待修改页面
批量上传文件
友情链接
VCPedia
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
登录后可编辑和发表评论。
user-interface-preferences
个人工具
创建账号
登录
欢迎加入
本站官方QQ群
!
查看“︁Module:Sig2User”︁的源代码
来自Vocawiki
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
Module:Sig2User
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
-- Module:Sig2User -- Made with ♥ by User:Leranjun -- This module takes a signature and returns the username found in the signature. -- For efficiency reasons, the module first looks for the "common" namespace aliases -- before obtaining all aliases from the mw.site.namespaces table. local p = {} local getArgs = require("Module:Arguments").getArgs local function isempty(s) return not s or s == "" end local function throw(e, suppress) return suppress and ("Error: " .. e) or error(e) end local function toComp(v) local r = mw.ustring.gsub( mw.ustring.gsub(v, "%s", "[ _]"), "(%%?)(.)", function(percent, letter) if percent ~= "" or not letter:match("%a") then -- do not use ustring! -- if the '%' matched, or `letter` is not a letter, return "as is" return percent .. letter else -- else, return a case-insensitive character class of the matched letter return mw.ustring.format("[%s%s]", mw.ustring.lower(letter), mw.ustring.upper(letter)) end end ) return r end local function findFromTable(s, prefixes, lang) local r = nil for _, v in pairs(prefixes) do pattern = "%[%[:?" .. toComp(v) .. "([^|/]+)|?.-/?.-%]%]" r = mw.ustring.match(s, pattern) if r then return lang:ucfirst(r) end end end local function patternExtend() local r = {} local NS_USER = mw.site.namespaces[2]["aliases"] local NS_USER_TALK = mw.site.namespaces[3]["aliases"] local NS_SPECIAL = mw.site.namespaces[-1]["aliases"] for _, v in pairs(NS_USER) do table.insert(r, v .. ":") end for _, v in pairs(NS_USER_TALK) do table.insert(r, v .. ":") end for _, v in pairs(NS_SPECIAL) do table.insert(r, v .. ":Contributions/") table.insert(r, v .. ":用[户戶][贡貢][献獻]/") end return r end function p._main(args) local s = args[1] local suppress = args["suppress"] if isempty(s) then return throw("Empty string", suppress) end -- Common namespace aliases local COMMON_PREFIX = { "User:", "U:", "User talk:", "Special:Contributions/", "Special:用[户戶][贡貢][献獻]/" } local lang = mw.language.getContentLanguage() local r = findFromTable(s, COMMON_PREFIX, lang) if r then return r end -- All namespace aliases r = findFromTable(s, patternExtend(), lang) if r then return r end -- Nothing found :( return throw("Invalid signature", suppress) end function p.main(frame) return p._main(getArgs(frame)) end return p
该页面嵌入的页面:
Module:Sig2User/doc
(
查看源代码
)
返回
Module:Sig2User
。
查看“︁Module:Sig2User”︁的源代码
来自Vocawiki