This translation is older than the original page and might be outdated. See what has changed.
本页面的其他翻译?:

跨维基(Interwiki)链接

跨维基一开始的想法是让我们拥有一个分布在整个网络的Wiki,在今天,它更多的是通过一些简单的链接语法来提供一种从一个Wiki链接到另一个Wiki的方式。

DokuWiki ,我们在要链接的 Wiki Shortcuts和页面名称之间加上个 > 字符,便可实现跨维基链接。

一些实例:

[[wp>Wiki]] 链接到维基百科,
[[Meatball>TourBusStop]] 链接到MeatBall wiki 的 TourBusStop 页面,
[[google>Wiki]] 链接到Google 搜索,
[[doku>interwiki]] 链接到当前页面((即http://www.dokuwiki.org/interwiki))。

Wiki 链接到维基百科,TourBusStop 链接到MeatBall wiki 的 TourBusStop 页面,Wiki 链接到Google 搜索,interwiki 链接到当前页面1)

this是一个特殊的跨维基Shortcuts, 它一直指向当前 DokuWiki 所在服务器上的安装目录。 你可以使用这种方法来构建相对链接。 下面的例子表示一个到本地聚合订阅的链接:feed.php

[[this>feed.php]]

了解更多:

配置跨维基 Shortcuts

跨维基的 shortcuts 定义在文件 conf/interwiki.conf 。这个文件默认包含了所有在 http://usemod.com/intermap.txt建议使用的 shortcuts 。 你也可以添加自定义的跨维基链接,首先创建这个文件(没有的话)conf/interwiki.local.conf,然后在里面添加上你的链接(这将保护你的链接不会在更新的时候被覆盖)。

直接更改 conf/interwiki.conf 文件也是可以,但不建议,因为这将导致在DokuWiki更新的时候你所做的修改会被覆盖。

你可以把以 shortcut 命名的图片放入lib/images/interwiki目录里,来让你自定义的图片替换掉默认的图标。自定义的图片大小必须是16×16 且必须是 PNG 或者 GIF 格式。在使用自定义图片代替默认图片后,要使更改生效,你应该清除下缓存中的 PNGGIF 图片和 CSS 文件。

rm -rf <path-to-dokuwiki>/data/cache/*/*.gif
rm -rf <path-to-dokuwiki>/data/cache/*/*.png
rm -rf <path-to-dokuwiki>/data/cache/*/*.css

跨维基 shortcut 必须使用小写字母且遵循页面名称的规则。

跨维基配置文件的格式如下:

<shortcut>      <url to wiki>

shortcut 是一个你将会在链接时使用的字符串,URL的部分你可以使用一些占位符来让链接更灵活。如果没有提供占位符那么 wikiname2) 将会通过URL编码后追加到URL后面。 下面是有效的占位符列表:

占位符 替换为
{URL} 经URL编码后的wikiname (追加到URL后面的那一部分)
{NAME} 未经过编码的wikiname
{SCHEME} scheme part if an URL was given as wikiname
{HOST} host part if an URL was given as wikiname
{PORT} port part if an URL was given as wikiname
{PATH} path part if an URL was given as wikiname
{QUERY} query part if an URL was given as wikiname

最后5个参数在创建指向 cachesystems 的跨维基链接时十分有用。具体参考位于 interwiki.confcoral shortcut 。

更多使用占位符的例子可以在 conf/interwiki.conf 里找到。

For example, Ubuntu's wiki uses namespaces and pagenames like this “LaptopTestingTeam/ToshibaPortegeM700” and without using {NAME} as a placeholder in your interwiki.local.conf file, you'll get a Not Found error on their wiki, because it'll interpret the forward slash as a %2F ; so what you can do is add this line to your interwiki.local.conf:

ubuntu https://wiki.ubuntu.com/{NAME}

and now create your link to it like this:

[[ubuntu>LaptopTestingTeam/ToshibaPortegeM700|Ubuntu Linux on Toshiba Portege M700 Tablet]]
2) 形如[[shortcut>wikiname]]的模式
zh/interwiki.txt · 最后更改: 2011/06/26 14:32 由 douo
 
除额外注明的地方外,本维基上的内容按下列许可协议发布: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate