DokuWiki

It's better when it's simple

用户工具

站点工具


zh:interwiki

这是本文档旧的修订版!


跨维基(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]]

了解更多:

  • 中文维基百科上的跨维基
  • Wikipedia 上的InterWiki
  • MeatBall 上的InterWiki
  • c2.com Wiki 上的InterWiki

配置跨维基 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 格式。在使用自定义图片代替默认图片后,你应该清除下缓存中的PNG、GIF图片和 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>

The shortcut is the one you will be able to use in the link later. In the URL you can use some placeholders to be more flexible in linking. If no placeholder is given the URL-encoded wikiname will be appended to the URL. These placeholders are available:

Placeholder Replaced by
{URL} URL-encoded wikiname (the part which is appended to the URL in interwiki.local.conf)
{NAME} wikiname without any encoding
{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

The last 5 parameters are useful when creating interwikilinks to cachesystems. Refer to the coral shortcut in the distributed interwiki.conf. Examples of these placeholders can found in 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]]
zh/interwiki.1309087681.txt.gz · 最后更改: 2011-06-26 13:28 由 douo

除额外注明的地方外,本维基上的内容按下列许可协议发布: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki