Manual:インターウィキ

From mediawiki.org
This page is a translated version of the page Manual:Interwiki and the translation is 54% complete.

インターウィキ リンク (ウィキ間リンク) は、内部リンクに接頭辞を付けたスタイルを使用する、ページから他のプロジェクトへのリンクです。

インターウィキ リンクを使用すると、(例えば) ウィキペディア、ウィキブックス、ウィキニュースなどのページや、さまざまな言語のウィキ プロジェクトにリンクできます。 (Manual:ウィキファミリー を参照してください。)

[[Wikipedia:Main Page]]のようなリンクはWikipedia:Main Pageのように表示され、ウィキペディアのメインページにリダイレクトされます。

他のプロジェクトへのインターウィキリンク

テーブルとクエリAPI

インターウィキ リンクは MediaWiki のデータベースの interwiki テーブルで保持されています。 You can retrieve the interwiki list from the interwikimap property of the siteinfo meta query API, in other words by making an API request like api.php?action=query&meta=siteinfo&siprop=interwikimap

既定

Several Wikimedia projects (and others) are ready for interwiki linking by default, so you can use them without editing your database.

The following are some examples of interwiki prefixes which are available by default (Wikipedia is also available, 1.10 and after):

接頭辞 転送先 URL 使用例
commons https://commons.wikimedia.org/wiki/ [[commons:MediaWiki]]
mediazilla http://bugzilla.wikimedia.org/ [[mediazilla:1209]]
metawikimedia (before version 1.23: metawikipedia) https://meta.wikimedia.org/wiki/ [[metawikimedia:Main Page]]

The full list of default interwiki prefixes is available at maintenance/interwiki.list

See m:Help:Interwiki linking for complete information on linking from/to Wikimedia projects.

In some installations, none of these are pre-installed. Try [[metawikipedia:Main Page]] in this case.

ウィキ間リンクに新しいウェブサイトを追加

  • Interwiki links are set in the interwiki table of the database.
  • To modify these, you will need to edit the database, as below.

It is recommended to use the "Interwiki" extension, which eases the process.

As Wikipedia isn't set up by default prior to version 1.10, you might want to add it (and other projects that you desire).

The examples below show how to set up w: as a link to the English Wikipedia.

The idea is to insert a line of the form:

('prefix', 'URL format string', 1, 0)

into the interwiki table.

単一行

上級利用者なら以下のようにコマンドラインを1行で書くことがあります。

  • MySQLとPostgreSQL
MediaWiki バージョン:
1.10 – 1.16
INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans) VALUES ('w', 'https://en.wikipedia.org/wiki/$1', 1, 0);

Newer MediaWiki versions require some extra fields such as iw_wikiid:

INSERT INTO interwiki (iw_prefix, iw_url, iw_api, iw_local, iw_trans, iw_wikiid) 
VALUES ('w', 'https://en.wikipedia.org/wiki/$1', 'https://en.wikipedia.org/w/api.php', 0, 1, '');

エクスポート、追加、インポートし直す

Alternatively, you can use the following multi-step process, which exports the interwiki table, adds a line, then re-imports it:

  • Export the database table interwiki
  • add to the end of the table a line of the following form (using English wikipedia as an example):
('w', 'https://en.wikipedia.org/wiki/$1', 1, 0);
In the above code, the semicolon ';' as seen, MUST be at the end of the table. At the end of any other line within that table Only has ','.
  • Import the database table interwiki

テストの方法

環境設定をテストするには:

  • Go to your site,
  • create an article, with the following content:
  • [[w:Wikipedia:Village pump|]]
  • This should display a link to the 'Village pump' page on en.Wikipedia.org (the url https://en.wikipedia.org/wiki/Wikipedia:Village_pump)

Field documentation


ウィキ管理者への助言: 複数のヘルプページは MediaWiki.org のManual 名前空間にリンクしています。 To make these links work on your local wiki, add an interwiki link with iw_prefix=manual and iw_url=http://www.mediawiki.org/wiki/Manual:$1


ウィキ管理者への助言: $wgTranscludeCacheExpiry in your LocalSettings.php should be set if changes in the transcluded wiki are done. Alternatively, you can flush the table transcache on your local wiki.


他の言語へのインターウィキリンク

他言語版にウィキ間リンクを貼る

すでに Wiki family をインストールしてあると、日本語版の記事からドイツ語版の対応する記事にリンクが貼れます(そのウィキでドイツ語版のプロジェクトが存在する場合。) メディアウィキの設定により、これらのリンクをサイドバーに表示することができ、位置はツールボックスの直下になります。

ご利用のファイルシステムでメディアウィキをインストールしたディレクトリの下位にサブフォルダ「languages」があるはずです。 そのフォルダを開き、Names.php を調べると既知の言語版とその接頭辞が一覧になっています。 一例として、ドイツ語版のプロジェクトを追加する場合には Names.php で "Deutsch" (ドイツ語)を検索すると、接頭辞の "de" を見つけます。

「正しい」接頭辞がわかっている場合は、データベースを編集し interwiki テーブルに追加します。

iw_prefix language-prefix (e.g. "de" for German), which is listed in Names.php
iw_url URL to your wiki-project (e.g. http://de.example.org/index.php/$1)
iw_local same as above "Adding More"
iw_trans same as above "Adding More"

この方法で、他言語版の記事にもリンクが貼れます。 英語版のメインページに [[de:Hauptseite]] を追加すると、ツールボックスの下部に "Deutsch" (ドイツ語)が増え、リンク先はドイツ語版ウィキペディアのウィキ(Hauptseite)になります。

留意点として、このリンクはサイドバーにのみ表示され、記事の文中には表れない点です。 テキストにリンクを埋め込む場合は、右記の例のように接頭辞の後に半角のコロン「:」が必要です。[[:de:Hauptseite]]あるいは、$wgInterwikiMagic を false に設定します。

特定のウィキからウィキ間テーブルをエクスポートする

以下の JavaScript コードは API クエリを実行し、既存のウィキからインターウィキ・マップを取得し、SQL INSERT ステートメントを表示して新しいウィキのインターウィキ・テーブルに書き込みます。たとえばブラウザの開発者ツールを介してコードを挿入するか、Special:MyPage/skinname.js 内にコードを配置してプレビューし、実行します。

function ExtractInterwikiMapTable() {
	$.getJSON(mw.config.get('wgScriptPath') + '/api.php?action=query&meta=siteinfo&siprop=interwikimap&format=json', function(data) {
		var iw_prefix, iw_url, iw_local, iw_api, re_escape = /(')/g, result = '';
		for (var i = 0, iwm = data.query.interwikimap; i < iwm.length; i++) {
			iw_prefix = "'" + iwm[i].prefix.replace(re_escape, '\\$1') + "'";
			iw_url = "'" + iwm[i].url.replace(re_escape, '\\$1') + "'";
			iw_local = (typeof iwm[i].local == 'string') ? '1' : '0';
			iw_api = "'" + (iwm[i].iw_api || '').replace(re_escape, '\\$1') + "'";
			result += 'INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans, iw_api) VALUES ('+iw_prefix+', '+iw_url+', '+iw_local+', 0, '+iw_api+');\n'
		}
		$('<textarea style="width:800px;height:400px;"/>').val(result).appendTo(document.body);
	});
}

$(ExtractInterwikiMapTable);

関連項目