查看“FAQ:MediaWiki”的源代码
←
FAQ:MediaWiki
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
[[category:MediaWiki]] <span style="font-weight:bold; font-size:150%;"> [https://www.mediawiki.org/wiki/Manual:FAQ/zh 官网FAQ] </span> == 无法生成avg缩略图 == '''如果要使用第三方的converter,参见[https://www.mediawiki.org/wiki/Manual:Installing_third-party_tools#Image_thumbnailing Image thumbnailing页面]''' * '''描述:''' 上传'''<code>.svg</code>'''文件过后,页面中提示“生成缩略图出错:无法创建临时缩略图文件”,在“特殊页面:文件列表”中查看文件时: '''<code>Warning: symlink() has been disabled for security reasons in /www/wwwroot/wiki.eijux.com/includes/media/SvgHandler.php on line 280</code>'''。 *'''处理:''' 默认安装的PHP一些函数是没有默认开启的。 我们需要的函数是'''<code>symlink()</code>''',则用在PHP的禁用函数中删除该函数即可。 ---- * '''描述:''' 生成缩略图处提示:'''<code>sh: convert: command not found</code>''',PHP错误信息为'''<code>Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311</code>'''。 * '''处理:''' 先考虑是PHP配置的问题, <pre> PHP错误'''require(): open_basedir restriction in effect”''',即访问脚本不在'''<code>open_basedir</code>'''的限定目录里面,'''<code>open_basedir</code>'''的作用是将php所能打开的文件限制在指定的目录或文件。<br/> </pre> 修改PHP配置文件<code>PHP.ini</code>的<code>open_basedir</code>之后错误依旧,而后一直都盯着<code>open_basedir</code>打转。兜兜转转许久才注意到<code>sh: convert: command not found</code>的提示,想到可能没有配置Svg Converter,从而进一步发现MediaWiki没有默认安装Converter。最后在[https://www.mediawiki.org/wiki/Manual:Image_administration/zh#SVG | 官网手册SVG节]了解到支持信息,相关的Converter("ImageMagick", "ImagickExt", "sodipodi", "inkscape", "batik", "rsvg", and "imgserv")均需单独安装。相较之下,选用了[https://www.mediawiki.org/wiki/Extension:NativeSvgHandler/zh | NativeSvgHandler]扩展(将SVG文件直接发送至客户端以进行客户端渲染)。步骤如下:<br/> # '''下载文件,并将其放置在extensions/文件夹中的NativeSvgHandler目录内。(注意修改所有者及读写权限)''' # '''将下列代码放置在您的LocalSettings.php的底部:'''<code>wfLoadExtension( 'NativeSvgHandler' );</code>'''''' # '''导航至Special:Version,以验证扩展已成功安装。''' 再于网页刷新,svg缩略图显示正常。 * 如果要使用第三方的converter,参见[https://www.mediawiki.org/wiki/Manual:Installing_third-party_tools#Image_thumbnailing<nowiki> Image thumbnailing页面]</nowiki> == 左侧导航栏设置 == MediaWiki的左侧导航栏,在搜索栏中搜索“<code>[http://wiki.eijux.com/index.php?title=MediaWiki:Sidebar mediawiki:Sidebar]</code>”,<br/> 修改左侧导航栏如下: <pre> * navigation ** mainpage|mainpage-description ** recentchanges-url|recentchanges ** randompage-url|randompage ** helppage|help-mediawiki * 标题 ** 链接 |名称 ** 链接 |名称 ** 链接 |名称 </pre> * Note: *# “*”后为标题,可以是MediaWiki命名空间的页面(如navigation,即“[[MediaWiki:Navigation]]”)、文本内容,不能为http链接或MediaWiki格式链接。(其后没有“**”内容则该标题不显示) *# “**”后为导航链接,可以是MediaWiki命名空间的页面(如mainpage,即“[[MediaWiki:Mainpage]]”)、http链接,不能为MediaWiki格式链接。 *# 默认侧边栏只有两级(标题、链接|名称),若要实现多级链接、树形链接,需要需要修改MediaWiki的相关代码,或用Extension实现。 === 关于导航栏的SEARCH、TOOLBOX、LANGUAGES === 我想要在左侧导航栏通过类似于模板的方式,来自定义导航页并添加到[http://wiki.eijux.com/index.php?title=MediaWiki:Sidebar mediawiki:Sidebar]中,类似于其中的'''TOOLBOX'''('''SEARCH'''、'''LANGUAGES''')导航栏,<code>* TOOLBOX</code>,就可以变成: <pre> 工具 链入页面 相关更改 上传文件 特殊页面 页面信息 </pre> 起初,我以为是需要在MediaWiki命名空间下安装Sidebar的规则编写文件就可以,但尝试一番以失败告终。<br/> 然后,我考虑是不是这些内容和skin有关,并在<code>skins\Vector\includes\VectorTemplate.php</code>中看到了线索: <syntaxhighlight lang="php" line start="1" highlight="19,26"> private function buildSidebar() : array { $skin = $this->getSkin(); $portals = $skin->buildSidebar(); $props = []; $languages = null; // Render portals foreach ( $portals as $name => $content ) { if ( $content === false ) { continue; } // Numeric strings gets an integer when set as key, cast back - T73639 $name = (string)$name; switch ( $name ) { case 'SEARCH': break; case 'TOOLBOX': $portal = $this->getMenuData( 'tb', $content, self::MENU_TYPE_PORTAL ); // Run deprecated hook. // Use SidebarBeforeOutput instead. ob_start(); Hooks::run( 'VectorAfterToolbox', [], '1.35' ); $props[] = $portal + [ 'html-hook-vector-after-toolbox' => ob_get_clean(), ]; break; case 'LANGUAGES': $portal = $this->getMenuData( 'lang', $content, self::MENU_TYPE_PORTAL ); // The language portal will be added provided either // languages exist or there is a value in html-after-portal // for example to show the add language wikidata link (T252800) if ( count( $content ) || $portal['html-after-portal'] ) { $languages = $portal; } break; default: // Historically some portals have been defined using HTML rather than arrays. // Let's move away from that to a uniform definition. if ( !is_array( $content ) ) { $html = $content; $content = []; wfDeprecated( "`content` field in portal $name must be array." . "Previously it could be a string but this is no longer supported.", '1.35.0' ); } else { $html = false; } $portal = $this->getMenuData( $name, $content, self::MENU_TYPE_PORTAL ); if ( $html ) { $portal['html-items'] .= $html; } $props[] = $portal; break; } } $firstPortal = $props[0] ?? null; if ( $firstPortal ) { $firstPortal[ 'class' ] .= ' portal-first'; } return [ 'has-logo' => $this->isLegacy, 'html-logo-attributes' => Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [ 'class' => 'mw-wiki-logo', 'href' => Skin::makeMainPageUrl(), ] ), 'array-portals-rest' => array_slice( $props, 1 ), 'data-portals-first' => $firstPortal, 'data-portals-languages' => $languages, ]; } </syntaxhighlight> 不懂PHP粗略看了下,自定义导航名称的话当前函数内并没有<code>Hooks::run( 'VectorAfterToolbox', [], '1.35' );</code>类似的代码会执行,不知道函数返回之后的流程,就此搁置,以后再看吧。<br/> 【2020/09/09 00:40:57】 == “open_basedir restriction in effect” == * '''错误:''' '''<code>Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311</code>'''。<br/> 分析:出现此类问题一般为open_basedir的问题,即访问的文件不在'''<code>open_basedir</code>'''的限定目录里面'''(<code>open_basedir</code>的作用是将php所能打开的文件限制在指定的目录或文件,防止跨目录、跨站的访问)'''。 * '''处理:''' === <s>修改php配置</s> === <div style="background-color:#D3D3D3;"> <s> 查阅PHP配置文件'''<code>php.ini</code>'''搜索'''<code>open_basedir</code>''',添加配置如下: <pre style="background-color:#D3D3D3;"> ; open_basedir, if set, limits all file operations to the defined directory ; and below. This directive makes most sense if used in a per-directory ; or per-virtualhost web server configuration file. ; Note: disables the realpath cache ; http://php.net/open-basedir ; open_basedir = open_basedir = /www/wwwroot/wiki.eijux.com/:/tmp/ </pre> </s> </div> 结果还是搞不定!<br/> === BTPanel防跨站攻击 === 上网搜索一番才发现,'''BTPanel中站点设置的“网站目录”中有“防跨站攻击(open_basedir)”的选项,取消勾选之后,重启PHP''',就不再有这错误了。<br/> (该选项的配置文件为:“'''/www/server/panel/vhost/openlitespeed/detail/wiki.eijux.com.conf'''”),取消勾选即注释了代码: <pre> phpIniOverride { #php_admin_value open_basedir "/tmp/:/www/wwwroot/wiki.eijux.com/" } </pre> * '''注意:''' 注意用'''<code>open_basedir </code>'''指定的限制'''是路径前缀,而非目录名'''。所以如果要将访问限制在仅为指定的目录,应用斜线结束路径名。<br/> 如:若'''"open_basedir = /dir/user"''', 那么目录 '''"/dir/user"''' 和 '''"/dir/user1"'''都是可以访问的。 <div style="background-color:#ffffcc; color:#e76700; font-weight:bold;"> 设置'''<code>open_basedir</code>'''对此有效。之前解析'''<code>.svg</code>'''、使用'''<code>syntaxhighlight</code>'''遇到此问题时,还有确实依赖的库、服务的问题需要解决,此备忘。 </div> == 目录控制 == 当文章中含有3个以上标题时,mediawiki将自动在第一个标题之前生成目录(这是默认的设置)。<br/> * 如果需要隐去目录,可以在文章中加入“<code><nowiki>__NOTOC__</nowiki></code>”标记; * 如果需要强制显示目录而不管标题数量,可以加入“<code><nowiki>__TOC__</nowiki></code>”标记; * 这两个wiki标记不限制出现位置,但一般出现在文章第一个标题之前。 == 关于文章标题 == '''不要使用“.php”之类的后缀作为文章标题!'''<br/> '''不要使用“.php”之类的后缀作为文章标题!'''<br/> '''不要使用“.php”之类的后缀作为文章标题!'''<br/> 如果,一不小心使用了特殊后缀作为标题,并已经提交了,但是又不能显示页面(nginx404好像)。如何删除?<br/> 在其他文章的删除页面,将url中的文章标题替换为要删除的标题,就能跳转到该文章的删除页面。<br/> (移动页面是特殊页面,其url末尾是文章标题,即最后也是“.php”,也不能正常显示) == 如何在输入框自定义标签 == * 参见:“'''[https://www.mediawiki.org/wiki/Extension:Gadgets#List_of_gadget_scripts Extension:Gadgets]'''” 【2021/05/16 01:01:52 已安装扩展“CharInsert”,系统安装时已有“Gadgets”】 == '''折叠显示''' == 参考: https://zh.wikipedia.org/wiki/Help:%E6%91%BA%E7%96%8A%E9%A1%AF%E7%A4%BA#%E6%96%B0%E6%91%BA%E7%96%8A%E6%95%88%E6%9E%9C 在当前使用的 MediaWiki 版本中: 1、上述页面中使用“NavFrame”、“collapsible”、“collapsed”等标签不再有效; 2、上述页面中使用“mw-collapsible”、“mw-collapsed”、“mw-collapsible-content”、“mw-customtoggle-<自定义名字>”等标签可用。(“新折叠效果”一节) 折叠效果可以用在:<nowiki>'''<div>、<table>、<ul>、<ol>'''</nowiki>等标签(或这些标签的嵌套使用)中,通过“'''class'''”属性来指定。 标签说明: # “'''mw-collapsible'''”:表示元素可折叠; # “'''mw-collapsed'''”:表示元素默认折叠; # “'''mw-collapsible-content'''”:用于指定折叠部分; #*(须选择前两个元素中任意一个配合使用) #: 示例: #: <syntaxhighlight lang="bash" highlight=""> <div class="darken mw-collapsible mw-collapsed"> 这里的文字不会被折叠 <div class="mw-collapsible-content">折叠文字 Four score and seven years ago our forefathers brought forth on this continent</div> </div> </syntaxhighlight> # “'''mw-customtoggle-<自定义名字>'''”:用于设置自定义折叠按钮; #*(须选择前两个元素中任意一个配合使用) #: 示例: #: <syntaxhighlight lang="bash" highlight=""> <span class="darken mw-customtoggle-huiji">折叠按钮A</span> <div class="darken mw-collapsible mw-collapsed" id="mw-customcollapsible-huiji">折叠的内容</div> <span class="darken mw-customtoggle-huiji">折叠按钮B</span> </syntaxhighlight> === 效果 === {| class="wikitable mw-collapsible mw-collapsed" style="width:100%;" |- ! style="width:10%;" | ! style="width:45%;" | 代码 ! style="width:45%;" | 效果 |- | rowspan="8" | mw-collapsible mw-collapsed | “'''data-collapsetext'''”、“'''data-expandtext'''”用于设置折叠展开的文字: <syntaxhighlight lang="bash" highlight=""> <div class="mw-collapsible" data-collapsetext="点此隐藏" data-expandtext="点此开启"> Lorem ipsum </div> </syntaxhighlight> | <div class="mw-collapsible" data-collapsetext="点此隐藏" data-expandtext="点此开启"> Lorem ipsum </div> |- | '''默认折叠''': <syntaxhighlight lang="bash" highlight=""> <div class="mw-collapsible mw-collapsed"> Lorem ipsum </div> </syntaxhighlight> | <div class="mw-collapsible mw-collapsed"> Lorem ipsum </div> |- | '''折叠嵌套''': <syntaxhighlight lang="bash" highlight=""> <div class="mw-collapsible mw-collapsed"> 第一个折叠 <div class="mw-collapsible" style="background:#eee"> 第一个子折叠 </div> <div class="mw-collapsible" style="background:#eee"> 第二个子折叠 </div> </div> </syntaxhighlight> | <div class="mw-collapsible mw-collapsed"> 第一个折叠 <div class="mw-collapsible" style="background:#eee"> 第一个子折叠 </div> <div class="mw-collapsible" style="background:#eee"> 第二个子折叠 </div> </div> |- | Mediawiki 表格:'''标题行不会被折叠''' <syntaxhighlight lang="bash" highlight=""> {| class="wikitable sortable mw-collapsible" ! 你好 ! 世界 |- | 內容 | 会在 |- | 这里 | 出现 |} </syntaxhighlight> | {| class="wikitable sortable mw-collapsible" ! 你好 ! 世界 |- | 內容 | 会在 |- | 这里 | 出现 |} |- | 也可用于 '''syntaxhighlight''' 标签: <syntaxhighlight lang="bash" highlight=""> <syntaxhighlight lang="xml" highlight="" class=" mw-collapsible mw-collapsed"> <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> ... </ syntaxhighlight> </syntaxhighlight> | <syntaxhighlight lang="xml" highlight="" class=" mw-collapsible mw-collapsed"> <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> ... </syntaxhighlight> |- | html 的 <nowiki><table></nowiki> 标签的折叠:(用法更灵活复杂,但代码不如 Mediawiki 表格易读) <syntaxhighlight lang="bash" highlight=""> <table class="wikitable"> <tr> <th>X</th> <th>Y</th> <th>Z</th> </tr> <tr> <td>下面的內容是预设隐藏的</td> <td>35</td> <td>91</td> </tr> <tr> <td class="mw-collapsible mw-collapsed">我是mw-collapsible的內容</td> <td>42</td> <td>63</td> </tr> </table> </syntaxhighlight> | <table class="wikitable"> <tr> <th>X</th> <th>Y</th> <th>Z</th> </tr> <tr> <td>下面的內容是预设隐藏的</td> <td>35</td> <td>91</td> </tr> <tr> <td class="mw-collapsible mw-collapsed">我是mw-collapsible的內容</td> <td>42</td> <td>63</td> </tr> </table> |- | <nowiki><ul></nowiki> 标签折叠效果: <syntaxhighlight lang="bash" highlight=""> <ul class="mw-collapsible"> <li>Lorem <li>Ipsum <li>Dolor </ul> </syntaxhighlight> | <ul class="mw-collapsible"> <li>Lorem <li>Ipsum <li>Dolor </ul> |- | <nowiki><ol></nowiki> 标签折叠效果: <syntaxhighlight lang="bash" highlight=""> <ol class="mw-collapsible"> <li>One <li>Two is more than one <li>..a total of three items! </ol> </syntaxhighlight> | <ol class="mw-collapsible"> <li>One <li>Two is more than one <li>..a total of three items! </ol> |- | rowspan="2" | mw-collapsible-content | <syntaxhighlight lang="bash" highlight=""> <div class="darken mw-collapsible mw-collapsed"> 这里的文字不会被折叠 <div class="mw-collapsible-content">折叠文字 Four score and seven years ago our forefathers brought forth on this continent</div> </div> </syntaxhighlight> | <div class="darken mw-collapsible mw-collapsed"> 这里的文字不会被折叠 <div class="mw-collapsible-content">折叠文字 Four score and seven years ago our forefathers brought forth on this continent</div> </div> |- | <syntaxhighlight lang="bash" highlight=""> <div class="darken mw-collapsible mw-collapsed"> 这里的文字不会被折叠 <div class="mw-collapsible-content"> 被折叠的文字,和列表: <ul> <li>A <li>B <li>C <li>D </ul> </div> </div> </syntaxhighlight> | <div class="darken mw-collapsible mw-collapsed"> 这里的文字不会被折叠 <div class="mw-collapsible-content"> 被折叠的文字,和列表: <ul> <li>A <li>B <li>C <li>D </ul> </div> </div> |- | rowspan="3" | mw-customtoggle-<自定义名字> * 每个页面仅能使用一次??? | <syntaxhighlight lang="bash" highlight=""> <span class="darken mw-customtoggle-huiji">折叠按钮A</span> <div class="darken mw-collapsible mw-collapsed" id="mw-customcollapsible-huiji">折叠的内容</div> <span class="darken mw-customtoggle-huiji">折叠按钮B</span> </syntaxhighlight> | <span class="darken mw-customtoggle-huiji">折叠按钮A</span> <div class="darken mw-collapsible mw-collapsed" id="mw-customcollapsible-huiji">折叠的内容</div> <span class="darken mw-customtoggle-huiji">折叠按钮B</span> |- | <syntaxhighlight lang="bash" highlight=""> <div class="mw-customtoggle-myTable">点此折叠表格</div> {| class="wikitable sortable mw-collapsible" id="mw-customcollapsible-myTable" ! Hello ! World |- | Content | Goes |- | In | Here |} </syntaxhighlight> | <div class="mw-customtoggle-myTable">点此折叠表格</div> {| class="wikitable sortable mw-collapsible" id="mw-customcollapsible-myTable" ! Hello ! World |- | Content | Goes |- | In | Here |} |- | <syntaxhighlight lang="bash" highlight=""> <div class="mw-customtoggle-myList">折叠列表</div> <ul class="mw-collapsible" id="mw-customcollapsible-myList"> <li>A <li>B <li>C <li>D </ul> </syntaxhighlight> | <div class="mw-customtoggle-myList">折叠列表</div> <ul class="mw-collapsible" id="mw-customcollapsible-myList"> <li>A <li>B <li>C <li>D </ul> |} === 示例 === 代码: : <syntaxhighlight lang="bash" highlight=""> : '''示例:'''<span class="darken mw-customtoggle-settings.xml.example"><font color="SandyBrown">(展开/隐藏)</font></span> <div class="darken mw-collapsible mw-collapsed" id="mw-customcollapsible-settings.xml.example"> : <syntaxhighlight lang="xml" highlight=""> <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd"> ... </settings> </ syntaxhighlight> </div> </syntaxhighlight> 效果:<br/> :{| : '''示例:'''<span class="darken mw-customtoggle-settings.xml.example"><font color="SandyBrown">(展开/隐藏)</font></span> <div class="darken mw-collapsible mw-collapsed" id="mw-customcollapsible-settings.xml.example"> : <syntaxhighlight lang="xml" highlight=""> <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd"> ... </settings> </syntaxhighlight> </div> |}
返回至“
FAQ:MediaWiki
”。
导航菜单
个人工具
登录
命名空间
页面
讨论
大陆简体
已展开
已折叠
查看
阅读
查看源代码
查看历史
更多
已展开
已折叠
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
笔记
服务器
数据库
后端
前端
工具
《To do list》
日常
阅读
电影
摄影
其他
Software
Windows
WIKIOE
所有分类
所有页面
侧边栏
站点日志
工具
链入页面
相关更改
特殊页面
页面信息