Jump to content

Extension:InterwikiExtracts

From mediawiki.org
This page is a translated version of the page Extension:InterwikiExtracts and the translation is 40% complete.
MediaWiki 拡張機能マニュアル
InterwikiExtracts
リリースの状態: 安定
実装 パーサー関数
説明 Allows to reuse content from other wikis
作者 Sophivorusトーク
最新バージョン 4.5
MediaWiki >= 1.34.0
データベースの変更 いいえ
ライセンス GNU 一般公衆利用許諾書 3.0 以降
ダウンロード
[1]
四半期ごとのダウンロード数 1 (Ranked 139th)
translatewiki.net で翻訳を利用できる場合は、InterwikiExtracts 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

InterwikiExtracts (formerly WikipediaExtracts) is an extension to reuse content from other wikis. It introduces the {{#InterwikiExtract}} parser function that gets content from any wiki defined in your interwiki table. See #Add new wikis for adding new wikis to the interwiki table.

The content can be returned in three formats: HTML, wikitext or plain text. See the #Usage section for details about each format.

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のInterwikiExtractsという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/InterwikiExtracts
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'InterwikiExtracts' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

使用法

Add new wikis

To use content from a wiki, it should be loaded in the interwiki table. MediaWiki comes with a bunch of wikis already loaded, including the English Wikipedia and many other Wikimedia projects, so these wikis work out of the box.

To easily add new wikis to the interwiki table, install Extension:Interwiki, visit Special:Interwiki and follow the interface. Be sure to include the URL of the API of the wiki you want to add, or it won't work.

In older versions of the Interwiki extension, it isn't possible to set the URL of the API from the special page, so you must set it directly from the database by running a SQL command like the following: UPDATE interwiki SET iw_api = "https://es.wikipedia.org/w/api.php" WHERE iw_prefix = "eswiki";

If you don't have access to Special:Interwiki, or if you don't want to meddle with the interwiki table, you can also specify the api endpoint directly using the "api" parameter, like so:

{{#InterwikiExtract: Title of the article
| api = https://www.somewiki.org/w/api.php
}}

HTML extracts

By default, the extension gets content from Wikipedia in HTML format. So to get the HTML of any Wikipedia article, just write:

{{#InterwikiExtract:Title of the article}}

If you omit the title, then the title of the current page will be used. If you enter the title of a redirect page, the redirect will be followed and the content of the target article will be returned. If the redirect is to a section of the target article it will extract the full article and not just the section.

You can control several aspects of the content you get by passing parameters to the parser function, using the familiar template syntax. For example:

{{#InterwikiExtract: Title of the article
| section = 0
}}

Wikitext extracts

You can get content in wikitext format with the following syntax:

{{#InterwikiExtract: Title of the article
| format = wiki
}}

The content will be parsed after getting it, which means that any links to pages in your wiki that don't exist yet will show red, including templates!

The wikitext format is unlikely to be useful with content from Wikipedia, but it may be more useful with content from smaller wikis, with less internal links and templates.

Plain text extracts

To get content in plain text format, the target wiki needs to have the TextExtracts extension enabled. All Wikimedia wikis have it enabled, but other wikis may not!

To get content in plain text format, use the following syntax:

{{#InterwikiExtract: Title of the article
| format = text
}}

The available parameters are:

  • section – Title of the section to get (excluding subsections).
  • paragraphs – Number of paragraphs to get
  • intro – Whether or not to get content only before the first section. Any value means true.
  • sentences – Number of sentences to get from the intro. Cannot be used together with the "chars" parameter.
  • chars – Number of characters you get. Cannot be used together with the "sentences" parameter.
  • plaintext – Whether or not to get content as plain text rather than limited HTML. Any value means true.
  • sectionformat – Either "plain", "wiki" or "raw". Default is "wiki".

Except for 'section' and 'paragraphs', all parameters are based on the API of the Extension:TextExtracts. Check its documentation for more details.

Wrapper templates

Usually you'll want to wrap the parser function in a template, to simplify the syntax and set sensible defaults. For example, if you want to use the extension to get the introductions of Wikipedia articles, you could create a template called Template:WikipediaLead with the following content:

{{#InterwikiExtract: {{{1|{{PAGENAME}}}}}
| wiki = wikipedia
| format = text
| intro = true
}}

Calling this template without any parameters will get the lead section of the Wikipedia article with the same title as the current page. If you want the lead of a different article, you can specify the article through the first parameter, like so:

{{WikipediaLead|Title of the article}}

Similarly, if you want to use this extension to get short definitions from Wikipedia, you could create a template called Template:WikipediaDefinition with the following content:

{{#InterwikiExtract: {{{1|{{PAGENAME}}}}}
| wiki = wikipedia
| format = text
| sentences = 1
}}

Calling this template without any parameters will get you the first sentence of the Wikipedia article with the same title as the current page. If you want the first sentence of a different article, you can specify the article through the first parameter.

Crediting the authors

When using this extension, you should always credit the authors of the content you're reusing. You can easily do so by including a link in your wrapper template. For example:

{{#InterwikiExtract: {{{1|{{PAGENAME}}}}}
| wiki = wikipedia
| format = text
| intro = true
}}
[{{fullurl:wikipedia:{{{1|{{PAGENAME}}}}}}} From Wikipedia]

関連項目