Erweiterung:Description2

This page is a translated version of the page Extension:Description2 and the translation is 27% complete.
MediaWiki-Erweiterungen
Description2
Freigabestatus: stabil
Einbindung Daten-Extraktion, Parser-Erweiterung
Beschreibung Provides a meta description tag and adds data to parser output for other extensions to use.
Autor(en) Daniel Friesen (DantmanDiskussion)
Letzte Version 0.4.1
Kompatibilitätspolitik Der Master behält die Abwärtskompatibilität bei.
MediaWiki >= 1.38.0
Datenbankänderungen Nein
Lizenz GNU General Public License 2.0 oder neuer
Herunterladen
  • $wgDescriptionMaxChars
  • $wgDescriptionRemoveElements
  • $wgDescriptionAlgorithm
  • $wgEnableMetaDescriptionFunctions
Quarterly downloads 46 (Ranked 86th)
Übersetze die Description2-Erweiterung, wenn sie auf translatewiki.net verfügbar ist

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 Erweiterung:OpenGraphMeta does, or perhaps to use it in article lists on the wiki).

Installation

  • Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens Description2 im Ordner extensions/ ablegen.
    Entwickler und Code-Beitragende sollten stattdessen die Erweiterung von Git installieren, mit:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Description2
  • Folgenden Code am Ende deiner LocalSettings.php -Datei einfügen:
    wfLoadExtension( 'Description2' );
    $wgEnableMetaDescriptionFunctions = true;
    
  •   Erledigt – Navigiere zu Special:Version in deinem Wiki, um zu überprüfen, ob die Erweiterung erfolgreich installiert wurde.


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.

Algorithmus

Description is extracted from the HTML representation of a page:

  1. Entfernt alle ‎<table>-Elemente (und dessen Inhalte).
  2. Finde alle ‎<p>-Elemente.
  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.

Siehe auch