Расширение:TextExtracts
![]() | For obtaining summaries in production environments, the Page Content Service is recommended and used by Wikimedia products. |
![]() Статус релиза: стабильно |
|
---|---|
Реализация | API |
Описание | Provides API with plain-text or limited HTML extracts of page content |
Автор(ы) | Max Semenik (MaxSemобсуждение) |
Политика совместимости | Snapshots releases along with MediaWiki. Master is not backward compatible. |
MediaWiki | >= 1.41 |
Изменения в БД | Нет |
Лицензия | GNU General Public License 2.0 или позднее |
Скачать | |
|
|
Ежеквартальные загрузки | 161 (Ranked 55th) |
Использование общедоступными вики | 2,046 (Ranked 189th) |
Переведите расширение TextExtracts, если оно доступно на translatewiki.net | |
Проблемы | Открытые задачи · Сообщить об ошибке |
The TextExtracts extension provides an API which allows retrieval of plain-text or limited HTML (HTML with content for some CSS classes removed) extracts of page content.
Установка
- Скачайте и распакуйте файл(ы) в папку с названием
TextExtracts
в вашей папкеextensions/
.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts - Добавьте следующий код в конце вашего файла LocalSettings.php :
wfLoadExtension( 'TextExtracts' );
Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.
Для использующих MediaWiki 1.26 или более ранние версии:
В приведенных выше инструкциях описывается новый способ установки этого расширения с использованием wfLoadExtension()
.
Если вам нужно установить это расширение на более ранние версии (MediaWiki 1.26 и более ранние), вместо wfLoadExtension( 'TextExtracts' );
, вам необходимо использовать:
require_once "$IP/extensions/TextExtracts/TextExtracts.php";
Настройки конфигурации
$wgExtractsRemoveClasses
is an array of <tag>, <tag>.class, .<class>, #<id> which will be excluded from extraction.
- For example,
$wgExtractsRemoveClasses[] = 'dl';
removes indented text, often used for non-templated hatnotes that are not desired in summaries.
- For example,
- extension.json defines the defaults, of which the class "noexcerpt" is one - this may be added to any template to exclude it.
$wgExtractsExtendOpenSearchXml
defines whether TextExtracts should provide its extracts to the Opensearch API module. The default isfalse
.
API
extracts | |
---|---|
Returns plain-text or limited HTML extracts of the given pages Этот модуль не может быть использован в качестве генератора. | |
Префикс | ex |
Необходимые права | нет |
Только POST? | Нет |
Генерируемая справка | Текущее |
![]() | Документация ниже автоматически сгенерирована предварительной версией MediaWiki, используемой на этом сайте (MediaWiki.org); она доступна на служебной странице Special: |
prop=extracts (ex)
- This module requires read rights.
- Source: TextExtracts
- License: GPL-2.0-or-later
Returns plain-text or limited HTML extracts of the given pages.
- exchars
How many characters to return. Actual text returned might be slightly longer.
- Type: integer
- The value must be between 1 and 1,200.
- exsentences
How many sentences to return.
- Type: integer
- The value must be between 1 and 10.
- exlimit
How many extracts to return. (Multiple extracts can only be returned if exintro is set to true.)
- Type: integer or max
- The value must be between 1 and 20.
- Default: 20
- exintro
Return only content before the first section.
- Type: boolean (details)
- explaintext
Return extracts as plain text instead of limited HTML.
- Type: boolean (details)
- exsectionformat
How to format sections in plaintext mode:
- plain
- No formatting.
- wiki
- Wikitext-style formatting (== like this ==).
- raw
- This module's internal representation (section titles prefixed with <ASCII 1><ASCII 2><section level><ASCII 2><ASCII 1>).
- One of the following values: plain, raw, wiki
- Default: wiki
- excontinue
When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.
- Type: integer
- Get a 175-character extract
- api.php?action=query&prop=extracts&exchars=175&titles=Therion [open in sandbox]
Another example
Результат |
---|
{
"query": {
"pages": {
"9228": {
"pageid": 9228,
"ns": 0,
"title": "Earth",
"extract": "Earth, also called the world and, less frequently, Gaia, (or Terra in some works of science fiction)..."
}
}
}
}
|
Предостережения
There are various things to be aware of when using the API or software that uses the API e.g. Расширение:Всплывающие окна .
- We do not recommend the usage of `exsentences`.
It does not work for HTML extracts and there are many edge cases for which it doesn't exist. For example "Arm. gen. Ing. John Smith was a soldier." will be treated as 4 sentences. We do not plan to fix this.
- Inline images are stripped from the response (even in HTML mode). This means if you are using the Math extension and using formulae in your lead section they may not appear in the summary output.
- In HTML mode we cannot guarantee well formed HTML. Resulting HTML may be invalid or malformed.
- In plaintext mode:
- citations may not be stripped (see phab:T197266)
- if a paragraph ends with an HTML tag e.g. ref tag, new lines may be dropped (see phab:T201946)
- new lines may be dropped after lists phab:T208132
- Articles must begin with the lead paragraph for an extract to be generated. The use of any template, and/or unclosed or empty HTML element may result in no preview for the article. E.g. "<div></div>hello" will give an empty extract.
ЧЗВ
How can I remove content from a page preview/extract?
TextExtracts will strip any element that is marked with the class .noexcerpt
.
This is provided by the $wgExtractsRemoveClasses
configuration variable (which also defines some other excluded elements).
См. также
![]() | Это расширение используется в одном или нескольких проектах Викимедиа. Вероятно, это означает, что расширение стабильно и работает достаточно хорошо, чтобы использоваться такими сайтами с высоким трафиком. Найдите название этого расширения в файлах конфигурации Викимедиа CommonSettings.php и InitialiseSettings.php, чтобы узнать, где оно установлено. Полный список расширений, установленных на конкретной вики, можно увидеть на странице Special:Version wiki. |
![]() | Это расширение включено в следующие вики-фермы/хостинги и/или пакеты: Это не исчерпывающий список. Некоторые вики-фермы/хостинги и/или пакеты могут содержать это расширение, даже если они не перечислены здесь. Всегда сверяйтесь со своими вики-фермами/хостингами или комплектами/бандлами для подтверждения. |
- Extensions bundled with MediaWiki 1.34/ru
- Stable extensions/ru
- API extensions/ru
- GPL licensed extensions/ru
- Extensions in Wikimedia version control/ru
- ApiOpenSearchSuggest extensions/ru
- All extensions/ru
- Extensions still supporting pre-registration versions
- Extensions used on Wikimedia/ru
- Extensions included in BlueSpice/ru
- Extensions included in Canasta/ru
- Extensions available as Debian packages/ru
- Extensions included in Fandom/ru
- Extensions included in Miraheze/ru
- Extensions included in MyWikis/ru
- Extensions included in ProWiki/ru
- Extensions included in wiki.gg/ru
- Extensions included in WikiForge/ru
- Extensions included in WikiTide/ru