Extension:Description2/ru
![]() Статус релиза: стабильно |
|
---|---|
Реализация | Извлечение данных, Расширение парсера |
Описание | Provides a meta description tag and adds data to parser output for other extensions to use. |
Автор(ы) | Daniel Friesen (Dantmanобсуждение) |
Последняя версия | 0.4.1 |
Политика совместимости | Master maintains backward compatibility. |
MediaWiki | >= 1.31.0 |
Изменения в БД | Нет |
Лицензия | GNU General Public License 2.0 или позднее |
Скачать | |
|
|
Quarterly downloads | 66 (Ranked 110th) |
Public wikis using | 327 (Ranked 354th) |
Переведите расширение Description2, если оно доступно на translatewiki.net | |
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).
Установка
- Скачайте и распакуйте файл(ы) в папку с названием
Description2
в вашей папкеextensions/
. - Добавьте следующий код внизу вашего
LocalSettings.php
:wfLoadExtension( 'Description2' ); $wgEnableMetaDescriptionFunctions = true;
- Готово – Перейдите на страницу 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:
- Remove all
<table>
elements (and its contents). - Find all
<p>
elements. - Iterate over those paragraphs, stripping out all HTML tags and trimming whitespace around it.
- 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.
См. также
- Extension:OpenGraphMeta – uses Description2's description information when installed.
- Extension:MetaDescriptionTag
- Extension:Semantic Meta Tags
Это расширение включено в следующие пакеты и/или вики-фермы: This is not an authoritative list. Some wiki farms/hosts may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |