jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/391142 )
Change subject: Use Html messageBox helpers ...................................................................... Use Html messageBox helpers These helper methods are now upstreamed into core (see T166915) and can be removed. Clarification: MessageBox.mustache is retained given its usage inside JavaScript inside mobile.messageBox however it is updated to run as a hogan template as now it is not needed for server side rendering. The hasHeading hack is no longer necessary there. Change-Id: I94329791958251971e0b4817f814acf7a8ee34d6 Depends-On: I2757e1f4ff2599e93a7257fc644cab69063896d2 --- M extension.json M includes/MobileUI.php M includes/diff/InlineDifferenceEngine.php M includes/specials/MobileSpecialPage.php M includes/specials/SpecialMobileContributions.php M includes/specials/SpecialMobileHistory.php M includes/specials/SpecialMobilePreferences.php A resources/mobile.messageBox/MessageBox.hogan M resources/mobile.messageBox/MessageBox.js D resources/mobile.messageBox/MessageBox.mustache 10 files changed, 11 insertions(+), 71 deletions(-) Approvals: Pmiazga: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index f2cf7bf..1056a6b 100644 --- a/extension.json +++ b/extension.json @@ -176,7 +176,7 @@ "mobile.messageBox.styles" ], "templates": { - "MessageBox.hogan": "resources/mobile.messageBox/MessageBox.mustache" + "MessageBox.hogan": "resources/mobile.messageBox/MessageBox.hogan" }, "scripts": [ "resources/mobile.messageBox/MessageBox.js" diff --git a/includes/MobileUI.php b/includes/MobileUI.php index fe7f204..fa4b239 100644 --- a/includes/MobileUI.php +++ b/includes/MobileUI.php @@ -63,57 +63,6 @@ } /** - * Return a message box. - * @param string $html of contents of box - * @param string $className corresponding to box - * @param string $heading (optional) - * @return string of html representing a box. - */ - public static function messageBox( $html, $className, $heading = '' ) { - $templateParser = new TemplateParser( __DIR__ . '/../resources/mobile.messageBox/' ); - - $templateOptions = [ - 'className' => $className, - 'msg' => $html - ]; - if ( $heading ) { - $templateOptions += [ - 'heading' => $heading, - 'hasHeading' => true, - ]; - } - return $templateParser->processTemplate( 'MessageBox', $templateOptions ); - } - - /** - * Return a warning box. - * @param string $html of contents of box - * @return string of html representing a warning box. - */ - public static function warningBox( $html ) { - return self::messageBox( $html, 'warningbox' ); - } - - /** - * Return an error box. - * @param string $html of contents of error box - * @param string $heading (optional) - * @return string of html representing an error box. - */ - public static function errorBox( $html, $heading = '' ) { - return self::messageBox( $html, 'errorbox', $heading ); - } - - /** - * Return a success box. - * @param string $html of contents of box - * @return string of html representing a success box. - */ - public static function successBox( $html ) { - return self::messageBox( $html, 'successbox' ); - } - - /** * Mark some html as being content * @param string $html * @param string $className additional class names diff --git a/includes/diff/InlineDifferenceEngine.php b/includes/diff/InlineDifferenceEngine.php index 76e9ff4..10ee84c 100644 --- a/includes/diff/InlineDifferenceEngine.php +++ b/includes/diff/InlineDifferenceEngine.php @@ -78,7 +78,7 @@ $warnings = $this->getWarningMessageText(); if ( $warnings ) { - $warnings = MobileUI::warningBox( $warnings ); + $warnings = Html::warningBox( $warnings ); } $output->addHTML( $warnings . diff --git a/includes/specials/MobileSpecialPage.php b/includes/specials/MobileSpecialPage.php index 2be1028..73ce4bd 100644 --- a/includes/specials/MobileSpecialPage.php +++ b/includes/specials/MobileSpecialPage.php @@ -82,7 +82,7 @@ $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'mobile-frontend-requires-title' ) ); $out->setProperty( 'unstyledContent', true ); - $out->addHTML( MobileUI::warningBox( $msg ) ); + $out->addHTML( Html::warningBox( $msg ) ); } /** diff --git a/includes/specials/SpecialMobileContributions.php b/includes/specials/SpecialMobileContributions.php index 769f126..ad11304 100644 --- a/includes/specials/SpecialMobileContributions.php +++ b/includes/specials/SpecialMobileContributions.php @@ -116,7 +116,7 @@ } else { // For users who exist but have not made any edits $out->addHtml( - MobileUI::warningBox( $this->msg( 'mobile-frontend-history-no-results' ) ) ); + Html::warningBox( $this->msg( 'mobile-frontend-history-no-results' ) ) ); } } diff --git a/includes/specials/SpecialMobileHistory.php b/includes/specials/SpecialMobileHistory.php index e72dc06..1f7a806 100644 --- a/includes/specials/SpecialMobileHistory.php +++ b/includes/specials/SpecialMobileHistory.php @@ -283,7 +283,7 @@ // Edge case. // I suspect this is here because revisions may exist but may have been hidden. $out->addHtml( - MobileUI::warningBox( $this->msg( 'mobile-frontend-history-no-results' ) ) ); + Html::warningBox( $this->msg( 'mobile-frontend-history-no-results' ) ) ); } } diff --git a/includes/specials/SpecialMobilePreferences.php b/includes/specials/SpecialMobilePreferences.php index b0a78ec..fd5c398 100644 --- a/includes/specials/SpecialMobilePreferences.php +++ b/includes/specials/SpecialMobilePreferences.php @@ -62,7 +62,7 @@ $this->checkReadOnly(); if ( $this->getRequest()->getCheck( 'success' ) ) { - $out->addHtml( MobileUI::successBox( $this->msg( 'savedprefs' )->escaped() ) ); + $out->addHtml( Html::successBox( $this->msg( 'savedprefs' )->escaped() ) ); } // combine our valid tabs array with all available tabs on the preferences form diff --git a/resources/mobile.messageBox/MessageBox.hogan b/resources/mobile.messageBox/MessageBox.hogan new file mode 100644 index 0000000..188a76c --- /dev/null +++ b/resources/mobile.messageBox/MessageBox.hogan @@ -0,0 +1,4 @@ +<div class="{{className}}"> + {{#heading}}<h2>{{heading}}</h2>{{/heading}} + {{{msg}}} +</div> diff --git a/resources/mobile.messageBox/MessageBox.js b/resources/mobile.messageBox/MessageBox.js index 847872c..7fbeb6c 100644 --- a/resources/mobile.messageBox/MessageBox.js +++ b/resources/mobile.messageBox/MessageBox.js @@ -19,12 +19,7 @@ * @cfg {string} defaults.className either errorbox, warningbox or successbox */ defaults: {}, - template: mw.template.get( 'mobile.messageBox', 'MessageBox.hogan' ), - preRender: function () { - // Mustache (serverside) only allows truthy block tags. - // In case a dev added a heading but not hasHeading we set its value here. - this.options.hasHeading = Boolean( this.options.heading ); - } + template: mw.template.get( 'mobile.messageBox', 'MessageBox.hogan' ) } ); M.define( 'mobile.messageBox/MessageBox', MessageBox ); diff --git a/resources/mobile.messageBox/MessageBox.mustache b/resources/mobile.messageBox/MessageBox.mustache deleted file mode 100644 index 650fbca..0000000 --- a/resources/mobile.messageBox/MessageBox.mustache +++ /dev/null @@ -1,8 +0,0 @@ -<div class="{{className}}"> - {{! - See T143847 - Mustache and Hogan work differently with regards to block rendering so we - need to use both hasHeading and heading. this template operates in both js and php - }} - {{#hasHeading}}<h2>{{heading}}</h2>{{/hasHeading}} - {{{msg}}} -</div> -- To view, visit https://gerrit.wikimedia.org/r/391142 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I94329791958251971e0b4817f814acf7a8ee34d6 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Pmiazga <pmia...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits