Jump to content

Extension:Description2

From mediawiki.org
This page is a translated version of the page Extension:Description2 and the translation is 18% complete.
MediaWiki 拡張機能マニュアル
Description2
リリースの状態: 安定
実装 データ抽出, パーサー拡張機能
説明 Provides a meta description tag and adds data to parser output for other extensions to use.
作者 Daniel Friesen (Dantmanトーク)
最新バージョン 0.4.1
互換性の方針 master は後方互換性を維持しています。
MediaWiki >= 1.38.0
データベースの変更 いいえ
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgDescriptionMaxChars
  • $wgDescriptionRemoveElements
  • $wgDescriptionAlgorithm
  • $wgEnableMetaDescriptionFunctions
四半期ごとのダウンロード数 43 (Ranked 91st)
translatewiki.net で翻訳を利用できる場合は、Description2 拡張機能の翻訳にご協力ください

The Description2 extension adds a description meta tag for articles automatically based on the content. This functionality appears to have been removed from MediaWiki at some point. There are some situations where description extraction (by entities less sophisticated than Google, like Facebook) will extract the wrong description information from the wiki and use something like the sitenotice as the description for a page instead of its content. This extension also adds the description to the parser output in a way that other extensions can make use of (to say provide description in a different format like Extension:OpenGraphMeta does, or perhaps to use it in article lists on the wiki).

インストール

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


Extra options

If you set $wgEnableMetaDescriptionFunctions = true; in your LocalSettings.php a {{#description2:}} parser function can be used to control the description outputted for the page and override it with a custom one. You can use these parser extensions like so:

{{#description2:This is a description}}

You can use the description2 parser function instead to provide a description tag you can control with a template's variables.

アルゴリズム

Description is extracted from the HTML representation of a page:

  1. Remove all ‎<table> elements (and its contents).
  2. Find all ‎<p> elements.
  3. Iterate over those paragraphs, stripping out all HTML tags (see strip_tags()) and trimming whitespace around it.
  4. The first non-empty paragraph (after all previous transformation) is picked as the description.

Things to consider:

  • When using templates at the top of the articles, if you use ‎<div> instead of tables for the template, be sure it doesn't render paragraphs, which otherwise will be used as the description. This may happen if you have several ‎<div> inside the template with newlines.

関連項目