Extension:TextExtracts
|
TextExtracts Release status: stable |
||
|---|---|---|
| Implementation | API | |
| Description | Provides API with plain-text or limited HTML extracts of page content | |
| Author(s) | Max Semenik (MaxSemtalk) | |
| MediaWiki | 1.22+ | |
| PHP | 5.3+ | |
| Database changes | No | |
| License | GNU General Public License 2.0 or later | |
| Download | ||
|
||
|
||
|
Translate the TextExtracts extension if it is available at translatewiki.net |
||
| Check usage and version matrix; code metrics | ||
| Open tasks · Report a bug |
The TextExtracts extension provides an API with allows to retrieve plain-text or limited HTML extracts of page content.
Download[edit | edit source]
The extension can be retrieved directly from Git [?]:
- Browse code
- Some extensions have tags for stable releases.
- Browse tags
- Select the tag
- Click "snapshot"
- Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).
- Browse branches
- Select a branch name
- Click "Continue"
Extract the snapshot and place it in the extensions/TextExtracts/ directory of your MediaWiki installation.
If you are familiar with git and have shell access to your server, you can also obtain the extension as follows:
cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/TextExtracts.git
Installation[edit | edit source]
- Download and place the file(s) in a directory called
TextExtractsin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/TextExtracts/TextExtracts.php";
Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration settings[edit | edit source]
$wgExtractsRemoveClassesis an array of <tag>, <tag>.class, .<class>, and #<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. - TextExtracts.php defines the defaults, of which the class "noexcerpt" is one - this may be added to any template to exclude it.
- For example,
$wgExtractsExtendOpenSearchXmldefines whether TextExtracts should provide its extracts to theopensearchAPI module. The default is "false".
API[edit | edit source]
| extracts | |
|---|---|
| Prefix | ex |
| Required rights | none |
| Post only? | No |
| Generated help | Current |
| The following documentation is the output of Special:ApiHelp/query+extracts, generated from query+extracts's source code. |
prop=extracts (ex)
- This module requires read rights.
- Source: TextExtracts
- License: See link
Returns plain-text or limited HTML extracts of the given pages.
- exchars
-
How many characters to return. Actual text returned might be slightly longer.
- The value must be no less than 1.
- Type: integer
- exsentences
-
How many sentences to return.
- The value must be between 1 and 10.
- Type: integer
- exlimit
-
How many extracts to return.
- No more than 20 (20 for bots) allowed.
- Type: integer or max
- Default: 1
- 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, wiki, raw
- Default: wiki
- excontinue
-
When more results are available, use this to continue.
- Type: integer
- exvariant
-
Convert content into this language variant.
- Get a 175-character extract
- api.php?action=query&prop=extracts&exchars=175&titles=Therion
Another example
| Result |
|---|
{
"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)..."
}
}
}
}
|
| This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |

