Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/99777


Change subject: WIP: Story 1405: Update messages
......................................................................

WIP: Story 1405: Update messages

Overhaul all our messages
TODO: Add qqq codes, finalise messages

In process fix following bugs:
Bug: 54795
Bug: 56437

Change-Id: I827ac7894db534fc3bf3732516117f01f41fda8e
---
M MobileFrontend.i18n.php
M includes/skins/UserAccountCreateMobileTemplate.php
M includes/skins/UserLoginAndCreateTemplate.php
M includes/skins/UserLoginMobileTemplate.php
A javascripts/common/user/user.js
M javascripts/modules/editor/editor.js
M less/specials/userlogin.less
7 files changed, 113 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/77/99777/1

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index d1839fe..e0e3e24 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -175,7 +175,9 @@
 
        // image donation
        'mobile-frontend-donate-image-nouploads' => 'No uploads.',
-       'mobile-frontend-donate-image-login' => 'You must be logged in to see 
your uploads.',
+       'mobile-frontend-donate-image-login' => 'Media on {{SITENAME}} is 
donated by people like you.',
+       'mobile-frontend-donate-image-login-action' => 'Login to share your 
media.',
+       'mobile-frontend-donate-image-signup-action' => 'Sign up to share your 
media with the world.',
        'mobile-frontend-photo-upload-disabled' => 'No image is needed on this 
page.',
        'mobile-frontend-photo-upload-anon' => 'You need to be logged in to add 
an image to this page.',
        'mobile-frontend-photo-upload-protected' => 'You do not have permission 
to add an image to this page.',
@@ -200,10 +202,25 @@
        'mobile-frontend-watchlist-removed' => 'Removed $1 from your watchlist',
        'mobile-frontend-watchlist-view' => 'View your watchlist',
        'mobile-frontend-watchlist-more' => 'more',
-       'mobile-frontend-watchlist-cta' => 'Please login or sign up to watch 
this page.',
+       'mobile-frontend-watchlist-cta' => 'Keep track of this page and all 
changes to it.',
        'mobile-frontend-watchlist-cta-button-login' => 'Login',
        'mobile-frontend-watchlist-cta-button-signup' => 'Sign up',
-       'mobile-frontend-watch-login' => 'You must be logged in to watch 
pages.',
+
+       // login headers from left nav
+       'mobile-frontend-watchlist-login' => 'A watchlist helps you bookmark 
pages and keep track of changes to them.',
+       'mobile-frontend-watchlist-login-action' => 'Login to see it.',
+       'mobile-frontend-watchlist-signup' => 'A watchlist helps you bookmark 
pages and keep track of changes to them.',
+       'mobile-frontend-watchlist-signup-action' => 'Sign up to start one 
now.',
+       'mobile-frontend-generic-login' => '{{SITENAME}} is made by people like 
you.',
+       'mobile-frontend-generic-login-action' => 'Login to contribute.',
+       'mobile-frontend-generic-signup-action' => 'Sign up to contribute.',
+
+       // login article actions
+       'mobile-frontend-watch-login' => 'Add $1 to your watchlist.',
+       'mobile-frontend-watch-login-action' => 'A watchlist helps you bookmark 
pages and keep track of changes to them.',
+       'mobile-frontend-edit-login' => 'Help improve the $1 page.',
+       'mobile-frontend-edit-login-action' => 'Login to edit.',
+       'mobile-frontend-edit-signup-action' => 'Sign up to edit.',
 
        'mobile-frontend-watchlist-a-z' => 'List',
        'mobile-frontend-watchlist-feed' => 'Modified',
@@ -273,7 +290,6 @@
        'mobile-frontend-photo-cancel' => 'Cancel',
        'mobile-frontend-photo-upload-user-count' => 
'{{PLURAL:$1|<span>1</span> upload|<span>$1</span> uploads}}',
        'mobile-frontend-photo-upload-user-count-over-limit' => '500+ uploads',
-       'mobile-frontend-photo-upload-login' => 'You must be logged in to add 
an image.',
        'mobile-frontend-image-heading-describe' => "'''Describe''' image",
        'mobile-frontend-image-uploading' => "'''Uploading''' image...",
        'mobile-frontend-image-cancel-confirm' => "Cancel upload?",
@@ -281,9 +297,10 @@
        // edit
        'mobile-frontend-editor-undo-unsupported' => 'Undo is not currently 
supported on mobile devices.',
        'mobile-frontend-editor-newpage-prompt' => 'This page doesn\'t exist. 
Why not be bold and create it?',
-       'mobile-frontend-editor-disabled' => 'You are not allowed to edit this 
page.',
+       'mobile-frontend-editor-disabled' => 'This page is protected to prevent 
vandalism.',
+       'mobile-frontend-editor-blocked' => 'Your account is blocked from 
editing.',
        'mobile-frontend-editor-unavailable' => 'Mobile editing is not 
currently available on your browser. Please try a different browser.',
-       'mobile-frontend-editor-cta' => 'You must be logged in to edit pages on 
mobile.',
+       'mobile-frontend-editor-cta' => 'Help improve this page!',
        'mobile-frontend-editor-edit' => 'Edit',
        'mobile-frontend-editor-continue' => 'Continue',
        'mobile-frontend-editor-save' => 'Save',
diff --git a/includes/skins/UserAccountCreateMobileTemplate.php 
b/includes/skins/UserAccountCreateMobileTemplate.php
index 1eedca4..e6d18f2 100644
--- a/includes/skins/UserAccountCreateMobileTemplate.php
+++ b/includes/skins/UserAccountCreateMobileTemplate.php
@@ -3,6 +3,16 @@
  * Provides a custom account creation form for mobile devices
  */
 class UserAccountCreateMobileTemplate extends UserLoginAndCreateTemplate {
+       protected $actionMessages = array(
+               'watch' => 'mobile-frontend-watchlist-login',
+               'edit' => 'mobile-frontend-edit-signup-action',
+               'signup-edit' => 'mobile-frontend-edit-signup-action',
+               '' => 'mobile-frontend-generic-signup-action',
+       );
+       protected $pageMessages = array(
+               'Uploads' => 'mobile-frontend-donate-image-signup-action',
+               'Watchlist' => 'mobile-frontend-watchlist-signup-action',
+       );
 
        /**
         * @TODO refactor this into parent template
@@ -18,14 +28,6 @@
                $msgBox = ''; // placeholder for displaying any login-related 
system messages (eg errors)
                // handle captcha
                $captcha = $this->handleCaptcha( $this->data['header'] );
-               $headMsg = $this->getHeadMsg();
-
-               $accountCreation = Html::openElement( 'div', array( 'id' => 
'mw-mf-accountcreate', 'class' => 'content' ) );
-
-               // @TODO refactor this into base class
-               if ( $headMsg ) {
-                       $msgBox .= Html::Element( 'div', array( 'class' => 
'headmsg' ), $headMsg );
-               }
 
                if ( $message ) {
                        $heading = '';
@@ -90,9 +92,10 @@
                        Html::input( 'watch', $watchArticle, 'hidden' ) .
                        $stickHTTPS .
                        Html::closeElement( 'form' );
-               $accountCreation .= $msgBox . $form;
-               $accountCreation .= Html::closeElement( 'div' );
-               echo $accountCreation;
+               echo Html::openElement( 'div', array( 'id' => 
'mw-mf-accountcreate', 'class' => 'content' ) );
+               echo $this->renderGuiderMessage();
+               echo $form;
+               echo Html::closeElement( 'div' );
        }
 
        /**
diff --git a/includes/skins/UserLoginAndCreateTemplate.php 
b/includes/skins/UserLoginAndCreateTemplate.php
index eacbbd5..2a4e316 100644
--- a/includes/skins/UserLoginAndCreateTemplate.php
+++ b/includes/skins/UserLoginAndCreateTemplate.php
@@ -8,6 +8,20 @@
  * special mobile-specific magic.
  */
 abstract class UserLoginAndCreateTemplate extends QuickTemplate {
+       protected $pageMessageHeaders = array(
+               'Uploads' => 'mobile-frontend-donate-image-login',
+               'Watchlist' => 'mobile-frontend-watchlist-login',
+       );
+       protected $pageMessages = array();
+
+       protected $actionMessageHeaders = array(
+               'watch' => 'mobile-frontend-watch-login',
+               'edit' => 'mobile-frontend-edit-login',
+               'signup-edit' => 'mobile-frontend-edit-login',
+               '' => 'mobile-frontend-generic-login',
+       );
+
+       protected $actionMessages = array();
 
        /**
         * Overload the parent constructor
@@ -70,24 +84,58 @@
                return false;
        }
 
-       protected function getHeadMsg() {
+       /**
+        * Gets the message that should guide a user who is creating an account 
or logging in to an account.
+        * @return Array: first element is header of message and second is the 
content.
+        */
+       protected function getGuiderMessage() {
                $req = $this->getRequestContext()->getRequest();
                if ( $req->getVal( 'returnto' ) && ( $title = 
Title::newFromText( $req->getVal( 'returnto' ) ) ) ) {
                        list( $returnto, /* $subpage */ ) = 
SpecialPageFactory::resolveAlias( $title->getDBkey() );
+                       $title = $title->getText();
                } else {
                        $returnto = '';
+                       $title = '';
                }
-               $returntoQuery = $req->getVal( 'returntoquery' );
-               if ( $returnto == 'Uploads' ) {
-                       $key = 'mobile-frontend-donate-image-login';
-               } elseif ( $returnto == 'Watchlist' || strstr( $returntoQuery, 
'article_action=watch' ) ) {
-                       $key = 'mobile-frontend-watch-login';
-               } elseif ( strstr( $returntoQuery, 
'article_action=photo-upload' ) ) {
-                       $key = 'mobile-frontend-photo-upload-login';
+               $returnToQuery = $req->getVal( 'returntoquery' );
+               preg_match( '/article_action=([^&]*)/', $returnToQuery, $match 
);
+               if ( isset( $match[1] ) ) {
+                       $action = $match[1];
                } else {
-                       return '';
+                       $action = '';
                }
-               return wfMessage( $key )->plain();
+
+               $heading = '';
+               $content = '';
+
+               if ( isset( $this->pageMessageHeaders[$returnto] ) ) {
+                       $heading = wfMessage( 
$this->pageMessageHeaders[$returnto] )->parse();
+                       if ( isset( $this->pageMessages[$returnto] ) ) {
+                               $content = wfMessage( 
$this->pageMessages[$returnto] )->parse();
+                       }
+               } else if ( isset( $this->actionMessageHeaders[$action] ) ) {
+                       $heading = wfMessage( 
$this->actionMessageHeaders[$action], $title )->parse();
+                       if ( isset( $this->actionMessages[$action] ) ) {
+                               $content = wfMessage( 
$this->actionMessages[$action], $title )->parse();
+                       }
+               }
+               return array( $heading, $content );
+       }
+
+       /**
+        * Renders a prompt above the login or upload screen
+        *
+        */
+       protected function renderGuiderMessage() {
+               $msgs = $this->getGuiderMessage();
+               if ( $msgs[0] ) {
+                       echo Html::openElement( 'div', array( 'class' => 
'headmsg' ) );
+                       echo Html::element( 'strong', array(), $msgs[0] );
+                       if ( $msgs[1] ) {
+                               echo Html::element( 'div', array(), $msgs[1] );
+                       }
+                       echo Html::closeElement( 'div' );
+               }
        }
 
        protected function getLogoHtml() {
diff --git a/includes/skins/UserLoginMobileTemplate.php 
b/includes/skins/UserLoginMobileTemplate.php
index 81376c6..43c7e86 100644
--- a/includes/skins/UserLoginMobileTemplate.php
+++ b/includes/skins/UserLoginMobileTemplate.php
@@ -3,6 +3,15 @@
  * Provides a custom login form for mobile devices
  */
 class UserLoginMobileTemplate extends UserLoginAndCreateTemplate {
+       protected $actionMessages = array(
+               'watch' => 'mobile-frontend-watch-login-action',
+               'edit' => 'mobile-frontend-edit-login-action',
+               '' => 'mobile-frontend-generic-login-action',
+       );
+       protected $pageMessages = array(
+               'Uploads' => 'mobile-frontend-donate-image-login-action',
+               'Watchlist' => 'mobile-frontend-watchlist-login-action',
+       );
 
        /**
         * @TODO refactor this into parent template
@@ -16,7 +25,6 @@
                $message = $this->data['message'];
                $messageType = $this->data['messagetype'];
                $msgBox = ''; // placeholder for displaying any login-related 
system messages (eg errors)
-               $headMsg = $this->getHeadMsg();
 
                // @TODO make sure this also includes returnto and 
returntoquery from the request
                $query = array(
@@ -41,10 +49,6 @@
                        array( 'class'=> 'mw-mf-create-account' ), $query );
 
                $login = Html::openElement( 'div', array( 'id' => 
'mw-mf-login', 'class' => 'content' ) );
-
-               if ( $headMsg ) {
-                       $msgBox .= Html::Element( 'div', array( 'class' => 
'headmsg' ), $headMsg );
-               }
 
                if ( $message ) {
                        $heading = '';
@@ -95,9 +99,11 @@
                        $stickHTTPS .
                        Html::closeElement( 'form' ) .
                        Html::closeElement( 'div' );
-               $login .= $msgBox . $form;
-               $login .= Html::closeElement( 'div' );
                echo $login;
+               echo $this->renderGuiderMessage();
+               echo $msgBox;
+               echo $form;
+               echo Html::closeElement( 'div' );
        }
 
 }
diff --git a/javascripts/common/user/user.js b/javascripts/common/user/user.js
new file mode 100644
index 0000000..816c58b
--- /dev/null
+++ b/javascripts/common/user/user.js
@@ -0,0 +1,3 @@
+mw.user.isNewEditor = function() {
+       
+};
diff --git a/javascripts/modules/editor/editor.js 
b/javascripts/modules/editor/editor.js
index dbae783..a895936 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -11,7 +11,8 @@
                CtaDrawer = M.require( 'CtaDrawer' ),
                drawer = new CtaDrawer( {
                        queryParams: {
-                               campaign: 'mobile_editPageActionCta'
+                               campaign: 'mobile_editPageActionCta',
+                               returntoquery: 'article_action=edit'
                        },
                        signupQueryParams: { returntoquery: 
'article_action=signup-edit' },
                        content: mw.msg( 'mobile-frontend-editor-cta' )
diff --git a/less/specials/userlogin.less b/less/specials/userlogin.less
index 786a8f8..9ef6724 100644
--- a/less/specials/userlogin.less
+++ b/less/specials/userlogin.less
@@ -22,7 +22,6 @@
                background-color: #eee;
                border: 1px solid #ccc;
                color: #252525;
-               font-weight: bold;
                padding: 0.5em 1em;
                margin: 1em 0;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/99777
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I827ac7894db534fc3bf3732516117f01f41fda8e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to