打开/关闭搜索
搜索
打开/关闭菜单
549
7
12
2051
OGAS数据中枢
导航
首页
最近更改
随机页面
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁Module:Infobox3Base”︁的源代码
来自OGAS数据中枢
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
Module:Infobox3Base
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
管理员
您可以查看和复制此页面的源代码。
local table = table local string = string local ipairs = ipairs local mw = mw local p = {} local config = {} -- 等于 frame.args,在此处声明是为了全局使用和便于理解 local infoboxHtml = {} -- 生成标题栏 local function genTitle() local snippet = mw.html.create('div') :addClass('infobox-title') :cssText(config['title-style']) :wikitext(config['title']) table.insert(infoboxHtml, tostring(snippet)) end -- 生成图片栏 local function genImage() local snippet = mw.html.create('div') :addClass('infobox-image-container') :cssText(config['image-style']) :wikitext('[[File:' .. config['img-src'] .. '|' .. config['img-size'] .. '|class=infobox-image]]') :tag('br'):done() :wikitext(config['img-desc']) table.insert(infoboxHtml, tostring(snippet)) end -- 生成 Tabs 栏 local function genTabs() local snippet = mw.html.create('div') :cssText('text-align: center;') :wikitext(config['tabs']) table.insert(infoboxHtml, tostring(snippet)) end -- 生成子标题栏 local function genSubtitle(subtitle) local snippet = mw.html.create('div') :cssText(config['subtitle-style']) :wikitext(subtitle) table.insert(infoboxHtml, tostring(snippet)) end -- 生成双内容栏 local function genDoubleColumn(leftContent, rightContent) local snippet = mw.html.create('div') :cssText(config['double-style']) :tag('div') :cssText(config['double-l-style']) :tag('span') :wikitext(leftContent) :allDone() :tag('div') :cssText(config['double-r-style']) :newline() :wikitext(rightContent) :done() table.insert(infoboxHtml, tostring(snippet)) end -- 生成单内容栏 local function genSingleColumn(content) local snippet = mw.html.create('div') :cssText(config['single-style']) :newline() :wikitext(content) :newline() table.insert(infoboxHtml, tostring(snippet)) end -- 生成底部栏 local function genBottom() local snippet = mw.html.create('div') :cssText(config['b-style']) :newline() :wikitext(config['bottom']) table.insert(infoboxHtml, tostring(snippet)) end function p.main(frame) local parentFrame = frame:getParent() config = frame.args -- 处理标题栏、图片栏等顶部组件 -- 这些组件都是一次性的,不必借用匿名参数 if config['title'] ~= '' then genTitle() end if config['img-src'] ~= '' then genImage() end if config['tabs'] ~= '' then genTabs() end -- 批量处理中部组件 -- 绕过 Scribunto 的设计哲学,借用匿名参数保持顺序,并约定用首个 `::` 分割键值 for i, arg in ipairs(parentFrame.args) do local key, val = string.match(arg, '^%s*(.-)%s*::%s*(.-)%s*$') if key ~= nil and val ~= '' then local prefix = string.sub(key, 1, 1) if prefix == '-' then genSubtitle(val) elseif prefix == '_' then genSingleColumn(val) elseif prefix == '+' then genDoubleColumn(string.sub(key, 2), val) else genDoubleColumn(key, val) end -- 子标题栏和单内容栏不需要 key,故也允许用户直接传入 `-val` 和 `_val` else local tok, val = string.match(arg, '^([%-_])%s*(.-)%s*$') if tok ~= nil and val:sub(-2) ~= "::" and val ~= "" then if tok== '-' then genSubtitle(val) elseif tok == '_' then genSingleColumn(val) end end end end -- 处理底部栏等底部组件 if config['bottom'] ~= '' or config['b-style'] ~= '' then genBottom() end -- 套上最外层 div 并返回 return mw.html.create('div') :addClass('moe-infobox infobox3 ' .. config['class']) :cssText(config['style']) :node(table.concat(infoboxHtml)) end return p
该页面嵌入的页面:
Module:Infobox3Base/doc
(
查看源代码
)
返回
Module:Infobox3Base
。
查看“︁Module:Infobox3Base”︁的源代码
来自OGAS数据中枢