Jump to content

Руководство:Интервики

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

Ссылки интервики – это ссылки на страницы других проектов, использующие преднастроенный внутренний стиль ссылок.

Интервики-ссылки делают возможным ссылаться на страницы (к примеру) Википедии, Викикниг, Викиновостей и т.д., или на википроекты на других языках. (См. Руководство:Семьи вики/ru .)

Ссылка вида [[Wikipedia:Main Page]] будет представлена как: Wikipedia:Main Page и будет перенаправлять на заглавную страницу Википедии.

Интервики-ссылки на другие проекты

Интервики-ссылки можно просматривать и редактировать с Special:Interwiki начиная с MW 1.44, когда расширение Interwiki было объединено в ядро.

API таблиц и запросов Интервики ссылки расположены в таблице interwiki базы данных MediaWiki. Вы можете получить список интервики из свойства interwikimap мета-запроса API siteinfo , другими словами, сделав примерно такой запрос API:

По умолчанию

Некоторые Викимедиа проекты (и другие) готовы к интервики-ссылкам по умолчанию, так что вы можете использовать их без необходимости редактирования базы данных.

Следующие несколько примеров интервики префиксов, которые возможны по умолчанию (Wikipedia is also available, 1.10 and after):

префикс адрес назначения пример использования
commons https://commons.wikimedia.org/wiki/ [[commons:MediaWiki]]
mediazilla http://bugzilla.wikimedia.org/ [[mediazilla:1209]]
metawikimedia (до версии 1.23: metawikipedia) https://meta.wikimedia.org/wiki/ [[metawikimedia:Main Page]]

Полный список предустановленных префиксов интервики доступен на maintenance/interwiki.list.

See Interwiki linking on Wikimedia wikis for complete information on linking from/to Wikimedia projects.

В некоторых установках ни одна из них не установлена.

Adding a new website for interwiki linking

  • Interwiki links are set in the interwiki table of the database.
  • These can be modified at Special:Interwiki by users that have the interwiki right. You might need to add the line $wgGroupPermissions['sysop']['interwiki'] = true; to your wiki's configuration for this to work. In MediaWiki 1.44 and later, this feature is built into MediaWiki core. Older versions can use the Interwiki extension.
  • Make sure the new prefix you are defining isn't already used by MediaWiki as an interlanguage link , otherwise it will be interpreted as such. translatewiki:Special:MessageGroupStats/mediawiki provides a list of interlanguage links currently defined. For example, dtp: would be interpreted as a page in Central Dusun language rather than a link to a desktop publishing site as you might have envisioned.

To test

To test configuration:

  • Go to your site,
  • create an article, with the following content:
  • [[wikipedia: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

См. также: Manual:Interwiki table

Совет для администраторов вики: Several help pages link to MediaWiki.org's Manual namespace. 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.

Interwiki links to other languages

If you have installed a Wiki family , you can link from an article in English to an article in German (if you have a German project, too). You can set up MediaWiki to show those links in the sidebar, just below the toolbox.

In your filesystem, there is a subfolder of your MediaWiki installation, called "languages". Go there and have a look at Names.php as it contains a list of known languages and their prefixes. E.g. you want to add your German project, search Names.php for "Deutsch" and note the prefix "de".

If you know the "right" prefix, edit your database by adding a new line to table 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 see Manual:Interwiki table
iw_trans see Manual:Interwiki table

Now, you can link an article to the same in other languages. Adding [[de:Hauptseite]] on your English Main_Page will create a link "Deutsch" below the toolbox, which leads to the Main_Page of the German wiki (Hauptseite).

Note, that this link is shown in Sidebar's section, only, and not inside of the article. If you want to create a link inside of the text, you have to add a colon before the prefix: [[:de:Hauptseite]] or set $wgInterwikiMagic to false.


Exporting the interwiki table from a wiki

The following JavaScript code performs the API query to retrieve the interwiki map of an existing wiki, then displays the SQL INSERT statements to fill the interwiki table on a new wiki. You run it for example by injecting the code through your browser's developer tools, or by placing it inside Special:MyPage/skinname.js and previewing.

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);
[[imdbtitle:0389790|Bee Movie]]Bee Movie
[http://www.imdb.com/title/tt0389790 Bee Movie]Bee Movie

Linksearch works for the latter only.

Since interwikis are parsed in the same way as internal links, they have the same character limitations. For example, it is not possible to include a space (%20) in the interwiki target page, as the parser turns them into underscores (_). It is also not possible to use a plus sign (+) as the parser encodes them (making them %2B). Due to this, interwikis to other websites (including other wikis which use software besides MediaWiki) are not guaranteed to function. Interwikis to MediaWiki installations will always function correctly as they share the same title structure.

Wikitext using interwiki links isn't always easily transferable between different wikis because they don't consistently use the same interwiki prefixes, or they might not have them at all. Additionally, interwiki links can sometimes mislead users since they don't know when they're being sent to another site.

You can choose between "extiw" and "external text" CSS classes for links, depending on whether you want them to look the same or different. Using just the interwiki link is easier to type, but copying the URL from the webpage is handy. Templates like w:Template:imdb title can be set up to use either an interwiki link with a parameter like "tt0389790" or "0389790", or an external link with a parameter like one of those or the full URL, making it easier to include IMDb references.

Alternatives

As an alternative to interwiki linking, a template can be created to wrap a plaintext page title into a URL-encoded external link to a known wiki, which can then be called with syntax equivalent to interwiki links. This preserves the appearance and functionality of external links while providing similar convenience as interwiki linking.

The alternative template can also be customized to resemble a normal interwiki, which may be useful in cases where a normal interwiki does not function, e.g. linking to a wiki that does not use MediaWiki.

<!-- Template:IW --> [https://example.com/wiki/{{urlencode:{{{1}}}|WIKI}} {{{2|{{{1}}}}}}]

Then, instead of [[iw:External Page Title]], call the template:

{{IW|External Page Title}}External Page Title
{{IW|External Page Title|Alternate text}}Alternate text

Interwiki links can be configured to point to the same wiki they are being rendered from. For example, mw:Manual:Interwiki/ru points to this page. These links are treated identically to internal links and do show up on Special:WhatLinksHere, appear bold if they are a selflink like the above, appear red if the page doesn't exist, etc.

См. также