mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
synced 2024-11-27 09:30:09 +00:00
Adjust expectations for API consumers when using the TextExtracts API
Bug: T170617 Change-Id: I53e08db40e5319019c842869f992bac32b1dac97
This commit is contained in:
parent
dd728f81e2
commit
d69b35f4bc
|
@ -14,5 +14,7 @@
|
|||
"apihelp-query+extracts-example-1": "Get a 175-character extract",
|
||||
"apiwarn-textextracts-limit": "<var>exlimit</var> was too large for a whole article extracts request, lowered to $1.",
|
||||
"apiwarn-textextracts-unsupportedmodel": "$1 has content model $2, which is not supported; returning an empty extract.",
|
||||
"apiwarn-textextracts-title-in-file-namespace": "Extract for a title in File namespace was requested, none returned."
|
||||
"apiwarn-textextracts-title-in-file-namespace": "Extract for a title in File namespace was requested, none returned.",
|
||||
"apiwarn-textextracts-sentences-and-html": "The <var>$1sentences</var> parameter may have unexpected results when used in HTML mode.",
|
||||
"apiwarn-textextracts-malformed-html": "HTML may be malformed and/or unbalanced and may omit inline images. Use at your own risk. Known problems are listed at https://www.mediawiki.org/wiki/Extension:TextExtracts#Caveats."
|
||||
}
|
||||
|
|
|
@ -16,5 +16,7 @@
|
|||
"apihelp-query+extracts-example-1": "{{doc-apihelp-example|query+extracts}}",
|
||||
"apiwarn-textextracts-limit": "{{doc-apierror}}\n\nParameters:\n* $1 - Limit that will be used",
|
||||
"apiwarn-textextracts-unsupportedmodel": "{{doc-apierror}}\n\nParameters:\n* $1 - Page title\n* $2 - Content model",
|
||||
"apiwarn-textextracts-title-in-file-namespace": "{{doc-apierror}}\n\nWarning message displayed when an extract for a title in File namespace is requested."
|
||||
"apiwarn-textextracts-title-in-file-namespace": "{{doc-apierror}}\n\nWarning message displayed when an extract for a title in File namespace is requested.",
|
||||
"apiwarn-textextracts-sentences-and-html": "{{doc-apierror}}\n\nWarning message displayed documenting a known issue with sentence parameter used.",
|
||||
"apiwarn-textextracts-malformed-html": "{{doc-apierror}}\n\nWarning message displayed documented known issues with the TextExtracts API."
|
||||
}
|
||||
|
|
|
@ -42,6 +42,11 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
*/
|
||||
const CACHE_VERSION = 2;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PREFIX = 'ex';
|
||||
|
||||
/**
|
||||
* @var ParserOptions
|
||||
*/
|
||||
|
@ -66,7 +71,7 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
* @return ApiQueryExtracts
|
||||
*/
|
||||
public function __construct( $query, $moduleName, Config $conf ) {
|
||||
parent::__construct( $query, $moduleName, 'ex' );
|
||||
parent::__construct( $query, $moduleName, self::PREFIX );
|
||||
$this->config = $conf;
|
||||
}
|
||||
|
||||
|
@ -109,10 +114,16 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
$text = '';
|
||||
$titleInFileNamespace = true;
|
||||
} else {
|
||||
$params = $this->params;
|
||||
$text = $this->getExtract( $t );
|
||||
$text = $this->truncate( $text );
|
||||
if ( $this->params['plaintext'] ) {
|
||||
if ( $params['plaintext'] ) {
|
||||
$text = $this->doSections( $text );
|
||||
} else {
|
||||
if ( $params['sentences'] ) {
|
||||
$this->addWarning( $this->msg( 'apiwarn-textextracts-sentences-and-html', self::PREFIX ) );
|
||||
}
|
||||
$this->addWarning( 'apiwarn-textextracts-malformed-html' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue