跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
383
文件
1
用户
5999
编辑
Gal中文百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
在其他项目中
打开/关闭外观设置菜单
无法加载偏好设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
讨论
贡献
创建账号
登录
编辑“︁
Module
:
Portal bar
”︁
来自Gal中文百科
查看
阅读
编辑源代码
查看历史
associated-pages
模块
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
-- This module implements {{portal bar}}. require('strict') -- determine whether we're being called from a sandbox local isSandbox = mw.getCurrentFrame():getTitle():find('sandbox', 1, true) local sandbox = isSandbox and '/sandbox' or '' local portalModule = require('Module:Portal'..sandbox) local getImageName = portalModule._image local yesno = require( 'Module:Yesno' ) local p = {} local function sandboxVersion(s) return isSandbox and s.."-sand" or s end -- Builds the portal bar used by {{portal bar}}. function p._main( portals, args ) if #portals < 1 then return '' end -- Don't display a blank navbox if no portals were specified. if args.border == nil then args.border = true end args.border = yesno(args.border, true) local nav = mw.html.create( 'div' ) :addClass(sandboxVersion('portal-bar')) :addClass( 'noprint metadata noviewer' ) :attr( 'role', 'navigation' ) :attr( 'aria-label' , 'Portals' ) :addClass(sandboxVersion(args.border and 'portal-bar-bordered' or 'portal-bar-unbordered')) local container = nav:tag('ul') container:addClass(sandboxVersion('portal-bar-content')) local size = '24x21px' for _, portal in ipairs( portals ) do container :tag( 'li' ) :addClass(sandboxVersion('portal-bar-item')) :wikitext( string.format('<span class="nowrap">[[File:%s|%s]] </span>[[Portal:%s|%s主题]]', getImageName{ portal }, size, portal, portal)) end local styleFile = 'Module:Portal bar'..sandbox..'/styles.css' return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = styleFile } } .. tostring( nav ) end -- Processes external arguments and sends them to the other functions. function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in from the debug console -- or from another Lua module. local origArgs if type( frame.getParent ) == 'function' then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Process the args to make an array of portal names that can be used with ipairs. We need to use ipairs because we want to list -- all the portals in the order they were passed to the template, but we also want to be able to deal with positional arguments -- passed explicitly, for example {{portal|2=Politics}}. The behaviour of ipairs is undefined if nil values are present, so we -- need to make sure they are all removed. local portals, args = {}, {} for k, v in pairs( origArgs ) do if type( k ) == 'number' and type( v ) == 'string' then -- Make sure we have no non-string portal names. if mw.ustring.find( v, '%S' ) then -- Remove blank values. table.insert( portals, k ) end elseif type( k ) ~= 'number' then -- Separate named arguments from portals. if type( v ) == 'string' then v = mw.text.trim( v ) end args[ k ] = v end end table.sort( portals ) for i, v in ipairs( portals ) do portals[ i ] = mw.text.trim( origArgs[ v ] ) -- Swap keys with values, trimming whitespace. end return p._main( portals, args ) end return p
摘要:
请注意,所有对Gal中文百科的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Gal中文百科:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
此页面嵌入的页面:
Module:Portal bar/doc
(
编辑
)
编辑“︁
Module
:
Portal bar
”︁
来自Gal中文百科