jenkins-bot has submitted this change and it was merged.
Change subject: Allow API results to wrap long lines
......................................................................
Allow API results to wrap long lines
- Bug 260 provides potentally relevant discussion
(also eventually settled in white-space:pre-wrap)
- Wrapping isn't applied in help pages, since they rely
on the monospaced font for layout purposes.
- Rename $isError to the more exact $isHelp
- Update documentation for ApiFormatBase::initPrinter()
- Bonus: header w/ info about output formats won't show
for action=help anymore (irrelevant)
Change-Id: Id9cdf102e17b4c3eaf4b10f3e3f5e97233911b97
---
M includes/api/ApiFormatBase.php
M includes/api/ApiMain.php
2 files changed, 15 insertions(+), 10 deletions(-)
Approvals:
btongminh: Looks good to me, but someone else must approve
Yurik: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php
index 8ad9b8c..d990052 100644
--- a/includes/api/ApiFormatBase.php
+++ b/includes/api/ApiFormatBase.php
@@ -123,11 +123,13 @@
/**
* Initialize the printer function and prepare the output headers, etc.
- * This method must be the first outputing method during execution.
- * A help screen's header is printed for the HTML-based output
- * @param $isError bool Whether an error message is printed
+ * This method must be the first outputting method during execution.
+ * A human-targeted notice about available formats is printed for the
HTML-based output,
+ * except for help screens (caused by either an error in the API
parameters,
+ * the calling of action=help, or requesting the root script api.php).
+ * @param $isHelpScreen bool Whether a help screen is going to be shown
*/
- function initPrinter( $isError ) {
+ function initPrinter( $isHelpScreen ) {
if ( $this->mDisabled ) {
return;
}
@@ -164,7 +166,7 @@
<?php
- if ( !$isError ) {
+ if ( !$isHelpScreen ) {
?>
<br />
<small>
@@ -175,15 +177,18 @@
See the <a href='https://www.mediawiki.org/wiki/API'>complete
documentation</a>, or
<a href='<?php echo( $script ); ?>'>API help</a> for more information.
</small>
+<pre style='white-space: pre-wrap;'>
<?php
- }
+ } else { // don't wrap the contents of the <pre> for
help screens
+ // because these are actually formatted to
rely on
+ // the monospaced font for layout purposes
?>
<pre>
<?php
-
+ }
}
}
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 57ccc7a..5193ab5 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -936,10 +936,10 @@
* tell the printer not to escape ampersands so that our links
do
* not break.
*/
- $printer->setUnescapeAmps( ( $this->mAction == 'help' ||
$isError )
- && $printer->getFormat() == 'XML' &&
$printer->getIsHtml() );
+ $isHelp = $isError || $this->mAction == 'help';
+ $printer->setUnescapeAmps( $isHelp && $printer->getFormat() ==
'XML' && $printer->getIsHtml() );
- $printer->initPrinter( $isError );
+ $printer->initPrinter( $isHelp );
$printer->execute();
$printer->closePrinter();
--
To view, visit https://gerrit.wikimedia.org/r/37188
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id9cdf102e17b4c3eaf4b10f3e3f5e97233911b97
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Waldir <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Harshkothari410 <[email protected]>
Gerrit-Reviewer: Lwelling <[email protected]>
Gerrit-Reviewer: Waldir <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: btongminh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits