打开/关闭搜索
搜索
打开/关闭菜单
1K
5.2K
4
8.2K
星砂岛百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
本站正在进行早期测试,目前仍存在许多内容的缺失。
查看“︁模块:Common”︁的源代码
来自星砂岛百科
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:Common
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:已验证邮箱用户
您没有权限编辑
模块
命名空间内的页面。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local p = {} local cache = {} local lua_cache = mw.ext and mw.ext.LuaCache or nil local FILEPATH_CACHE_TTL = 3600 function p.trim(value) if value == nil then return '' end return mw.text.trim(tostring(value)) end function p.getArg(frame, key, default) local value = frame.args[key] if value == nil and frame:getParent() then value = frame:getParent().args[key] end value = p.trim(value) if value == '' then return default or '' end return value end function p.toText(value, sep) if value == nil then return '' end if type(value) == 'boolean' then return value and '是' or '否' end if type(value) == 'table' then local parts = {} for _, item in ipairs(value) do parts[#parts + 1] = tostring(item) end return table.concat(parts, sep or '、') end return tostring(value) end function p.normalizeKey(value) return mw.ustring.lower(p.trim(value)) end function p.loadJsonData(titleText) local pageName = p.trim(titleText) if pageName == '' then return nil end local cacheKey = 'json:' .. pageName if cache[cacheKey] ~= nil then return cache[cacheKey] or nil end local ok, data = pcall(mw.loadJsonData, pageName) if not ok or type(data) ~= 'table' then cache[cacheKey] = false return nil end cache[cacheKey] = data return data end p.readJsonPage = p.loadJsonData function p.getCurrentTitleText() return mw.title.getCurrentTitle().text end function p.filePageExists(fileName) local name = p.trim(fileName) if name == '' then return false end local cacheKey = 'file-exists:' .. name if cache[cacheKey] ~= nil then return cache[cacheKey] end local frame = mw.getCurrentFrame() local path = '' if frame then path = p.trim(frame:preprocess('{{filepath:' .. name .. '}}')) end local exists = path ~= '' cache[cacheKey] = exists return exists end function p.getFilePath(frame, fileName) local name = p.trim(fileName) if name == '' then return '' end local cacheKey = 'filepath:' .. name local lua_cached = p.luaCacheGet(cacheKey) if lua_cached ~= nil then return lua_cached end if cache[cacheKey] ~= nil then return cache[cacheKey] end local title = mw.title.new('File:' .. name) local path = '' if title and title.exists then path = name end cache[cacheKey] = path p.luaCacheSet(cacheKey, path, FILEPATH_CACHE_TTL) return path end function p.buildLuaCacheKey(namespace, version, key) local ns = p.trim(namespace) if ns == '' then ns = 'cache' end local ver = tostring(version or '1') local suffix = p.trim(key) if suffix == '' then return ns .. ':' .. ver end return ns .. ':' .. ver .. ':' .. suffix end function p.luaCacheGet(key) local k = p.trim(key) if k == '' then return nil end if not lua_cache or type(lua_cache.get) ~= 'function' then return nil end return lua_cache.get(k) end function p.luaCacheSet(key, value, ttl) local k = p.trim(key) if k == '' then return value end if not lua_cache or type(lua_cache.set) ~= 'function' then return value end if ttl ~= nil then lua_cache.set(k, value, ttl) else lua_cache.set(k, value) end return value end return p
该页面嵌入的页面:
模块:Common/doc
(
查看源代码
)
返回
模块:Common
。
查看“︁模块:Common”︁的源代码
来自星砂岛百科