jenkins-bot has submitted this change and it was merged.

Change subject: Add tour to be used for first edit (other than GettingStarted).
......................................................................


Add tour to be used for first edit (other than GettingStarted).

There are variants based on whether VisualEditor is installed,
since it controls the text of the edit source links too.

Bug: 51483
GitHub: https://github.com/wikimedia/mediawiki-extensions-GuidedTour/pull/1

Co-Author: Steven Walling <steven.wall...@gmail.com>
Co-Author: Matthew Flaschen <mflasc...@wikimedia.org>
Change-Id: I38ecddd5d8afcf59b7918378b94201d59b907c65
---
M GuidedTour.i18n.php
M GuidedTour.php
M GuidedTourHooks.php
A modules/tours/firstedit.js
4 files changed, 169 insertions(+), 0 deletions(-)

Approvals:
  Spage: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/GuidedTour.i18n.php b/GuidedTour.i18n.php
index 4245937..0872427 100644
--- a/GuidedTour.i18n.php
+++ b/GuidedTour.i18n.php
@@ -49,6 +49,23 @@
        'guidedtour-tour-gettingstarted-click-save-description' => 'Click 
\'{{int:savearticle}}\' and your changes will be visible.',
        'guidedtour-tour-gettingstarted-end-title' => 'Looking for more to do?',
        'guidedtour-tour-gettingstarted-end-description' => 
'[[Special:GettingStarted|Getting Started]] is updated every hour with new 
pages.',
+
+       // firstedit (wiktext version)
+       'guidedtour-tour-firstedit-edit-page-title' => 'Ready to edit?',
+
+       // Both of these refer to the wikitext edit links.  However, if 
VisualEditor is
+       // installed, we use a version that transcludes their tab/link text.
+       // The same applies to the edit-section-description ones.
+       'guidedtour-tour-firstedit-edit-page-description' => 'Click the 
\'{{int:vector-view-edit}}\' button to make your changes.',
+       'guidedtour-tour-firstedit-edit-page-visualeditor-description' => 
'Click the \'{{int:visualeditor-ca-editsource}}\' button to make your changes.',
+
+       'guidedtour-tour-firstedit-edit-section-title' => 'Edit just a section',
+       'guidedtour-tour-firstedit-edit-section-description' => 'There are 
\'{{int:editsection}}\' links for each major section in an article, so you can 
focus on just that part.',
+       'guidedtour-tour-firstedit-edit-section-visualeditor-description' => 
'There are \'{{int:visualeditor-ca-editsource-section}}\' links for each major 
section in an article, so you can focus on just that part.',
+       'guidedtour-tour-firstedit-preview-title' => 'Preview your changes 
(optional)',
+       'guidedtour-tour-firstedit-preview-description' => 'Clicking 
\'{{int:showpreview}}\' allows you to check what the page will look like with 
your changes. Just don\'t forget to save!',
+       'guidedtour-tour-firstedit-save-title' => 'You\'re almost done!',
+       'guidedtour-tour-firstedit-save-description' => 'When you\'re ready, 
clicking \'{{int:savearticle}}\' will make your changes visible for everyone.',
 );
 
 /** Message documentation (Message documentation)
@@ -93,6 +110,16 @@
        'guidedtour-tour-gettingstarted-click-save-description' => 'Description 
of step showing user where to click {{msg-mw|savearticle}}',
        'guidedtour-tour-gettingstarted-end-title' => 'Title of final step of 
Getting Started tour',
        'guidedtour-tour-gettingstarted-end-description' => 'Description of 
final step of Getting Started tour',
+       'guidedtour-tour-firstedit-edit-page-title' => 'Title of the step of 
the firstedit tour pointing to the main edit button',
+       'guidedtour-tour-firstedit-edit-page-description' => 'Description of 
the step of the firstedit tour pointing to the main edit button, if 
VisualEditor is not installed',
+       'guidedtour-tour-firstedit-edit-page-visualeditor-description' => 
'Title of the step of the firstedit tour pointing to the main edit button, if 
VisualEditor is installed',
+       'guidedtour-tour-firstedit-edit-section-title' => 'Title of the step of 
the firstedit tour pointing to the section edit button',
+       'guidedtour-tour-firstedit-edit-section-description' => 'Description of 
the step of the firstedit tour pointing to the section edit button, if 
VisualEditor is not installed',
+       'guidedtour-tour-firstedit-edit-section-visualeditor-description' => 
'Description of the step of the firstedit tour pointing to the section edit 
button, if VisualEditor is installed',
+       'guidedtour-tour-firstedit-preview-title' => 'Title of step explaining 
preview',
+       'guidedtour-tour-firstedit-preview-description' => 'Description of step 
explaining preview',
+       'guidedtour-tour-firstedit-save-title' => 'Title of step explaining 
saving an edit',
+       'guidedtour-tour-firstedit-save-description' => 'Description of step 
explaining how to save',
 );
 
 /** Arabic (العربية)
diff --git a/GuidedTour.php b/GuidedTour.php
index a877adf..8035d3f 100644
--- a/GuidedTour.php
+++ b/GuidedTour.php
@@ -38,6 +38,7 @@
 $wgHooks['ResourceLoaderTestModules'][] = 
'GuidedTourHooks::onResourceLoaderTestModules';
 $wgHooks['UnitTestsList'][] = 'GuidedTourHooks::onUnitTestsList';
 $wgHooks['RedirectSpecialArticleRedirectParams'][] = 
'GuidedTourHooks::onRedirectSpecialArticleRedirectParams';
+$wgHooks['ResourceLoaderRegisterModules'][] = 
'GuidedTourHooks::onResourceLoaderRegisterModules';
 
 // Extension credits that will show up on Special:Version
 $wgExtensionCredits['other'][] = array(
@@ -148,6 +149,10 @@
 
 // Tour designed to help new users edit.
 // Can be used with Special:GettingStarted or independently.
+
+// TODO (mattflaschen, 2013-05-24): Move this tour (or at least the messages 
that are still
+// used) to the GettingStarted extension.  Since we have 'firstedit', 
'gettingstarted'
+// doesn't need to be used as a generic "first edit" tour.
 $wgResourceModules['ext.guidedTour.tour.gettingstarted'] = array(
        'scripts' => 'gettingstarted.js',
        'localBasePath' => $dir . 'modules/tours',
diff --git a/GuidedTourHooks.php b/GuidedTourHooks.php
index c603956..4152177 100644
--- a/GuidedTourHooks.php
+++ b/GuidedTourHooks.php
@@ -193,4 +193,54 @@
 
                return true;
        }
+
+       /**
+        * We should continue using $wgResourceModules for everything, except 
when the
+        * definition depends on whether another extension is present.  This is 
to avoid
+        * relying on the include order.
+        *
+        * @param $resourceLoader ResourceLoader
+        */
+       public static function onResourceLoaderRegisterModules( 
&$resourceLoader ) {
+               $dir = __DIR__ . DIRECTORY_SEPARATOR;
+               $module = array(
+                       'scripts' => 'firstedit.js',
+                       'localBasePath' => $dir . 'modules/tours',
+                       'remoteExtPath' => 'GuidedTour/modules/tours',
+                       'dependencies' => array(
+                               'ext.guidedTour',
+                       ),
+                       'messages' => array(
+                               'savearticle',
+                               'showpreview',
+                               'guidedtour-tour-firstedit-edit-page-title',
+                               'guidedtour-tour-firstedit-edit-section-title',
+                               'guidedtour-tour-firstedit-preview-title',
+                               'guidedtour-tour-firstedit-preview-description',
+                               'guidedtour-tour-firstedit-save-title',
+                               'guidedtour-tour-firstedit-save-description',
+                       ),
+               );
+
+               // Check whether VE is installed to determine which messages to 
add.
+               if ( class_exists( 'VisualEditorHooks' ) ) {
+                       array_push(
+                               $module['messages'],
+                               'visualeditor-ca-editsource',
+                               
'guidedtour-tour-firstedit-edit-page-visualeditor-description',
+                               'visualeditor-ca-editsource-section',
+                               
'guidedtour-tour-firstedit-edit-section-visualeditor-description'
+                       );
+               } else {
+                       array_push(
+                               $module['messages'],
+                               'vector-view-edit',
+                               
'guidedtour-tour-firstedit-edit-page-description',
+                               'editsection',
+                               
'guidedtour-tour-firstedit-edit-section-description'
+                       );
+               }
+
+               $resourceLoader->register( 'ext.guidedTour.tour.firstedit', 
$module );
+       }
 }
diff --git a/modules/tours/firstedit.js b/modules/tours/firstedit.js
new file mode 100644
index 0000000..6968673
--- /dev/null
+++ b/modules/tours/firstedit.js
@@ -0,0 +1,87 @@
+// Guided Tour to help users make their first edit.
+// Designed to work on any Wikipedia article, and can work for other sites 
with minor message changes.
+
+( function ( window, document, $, mw, gt ) {
+       var hasEditSection, isVeInstalled;
+
+       function shouldShowForPage() {
+               // Excludes pages outside the main namespace and pages with 
editing restrictions
+               // Should be 'pages that are not in content namespaces'.
+               // However, the list of content namespaces isn't currently 
exposed to JS.
+               return ( mw.config.get( 'wgCanonicalNamespace' ) === '' && 
mw.config.get( 'wgIsProbablyEditable' ) );
+       }
+
+       // If we shouldn't show it, don't initialize the guiders
+       if ( !shouldShowForPage() ) {
+               return;
+       }
+
+       hasEditSection = $( '.mw-editsection' ).length > 0;
+
+       // We don't care if VE is actually available on the page.
+       // If it is installed, it controls the edit link messages, even if VE 
is not available.
+       //
+       // VE actually allows configuring this through 
$wgVisualEditorTabMessages, but we assume the defaults.
+       //
+       // We fork messages only when necessary, based on whether VE is 
installed.  The messages with 'visualeditor'
+       // in the name include the VE messages through {{int:}}
+       isVeInstalled = !!mw.libs.ve;
+       gt.defineTour( {
+               name: 'firstedit',
+               steps: [ {
+                       titlemsg: 'guidedtour-tour-firstedit-edit-page-title',
+                       descriptionmsg: isVeInstalled ?
+                               
'guidedtour-tour-firstedit-edit-page-visualeditor-description' :
+                               
'guidedtour-tour-firstedit-edit-page-description',
+                       attachTo: '#ca-edit',
+                       position: 'bottom',
+                       // TODO (mattflaschen, 2013-09-03): After GuidedTour 
API enhancements, try to replace
+                       // section-related shouldSkip and onclick code with 
proceedTo.
+                       shouldSkip: gt.isEditing,
+                       buttons: [ {
+                               namemsg: hasEditSection ? 
'guidedtour-next-button' : 'guidedtour-okay-button',
+                               onclick: function () {
+                                       if ( hasEditSection ) {
+                                               mw.libs.guiders.next();
+                                       } else {
+                                               mw.libs.guiders.hideAll();
+                                       }
+                               }
+                       } ],
+                       allowAutomaticOkay: false
+               }, {
+                       titlemsg: 
'guidedtour-tour-firstedit-edit-section-title',
+                       descriptionmsg: isVeInstalled ?
+                               
'guidedtour-tour-firstedit-edit-section-visualeditor-description' :
+                               
'guidedtour-tour-firstedit-edit-section-description',
+                       position: 'right',
+                       attachTo: '.mw-editsection',
+                       autoFocus: true,
+                       width: 300,
+                       shouldSkip: function () {
+                               return gt.isEditing() || $( '.mw-editsection' 
).length === 0;
+                       }
+               }, {
+                       titlemsg: 'guidedtour-tour-firstedit-preview-title',
+                       descriptionmsg: 
'guidedtour-tour-firstedit-preview-description',
+                       attachTo: '#wpPreview',
+                       autoFocus: true,
+                       position: 'top',
+                       closeOnClickOutside: false,
+                       shouldSkip: function() {
+                               return !gt.isEditing();
+                       }
+               },  {
+                       titlemsg: 'guidedtour-tour-firstedit-save-title',
+                       descriptionmsg: 
'guidedtour-tour-firstedit-save-description',
+                       attachTo: '#wpSave',
+                       autoFocus: true,
+                       position: 'top',
+                       closeOnClickOutside: false,
+                       shouldSkip: function() {
+                               return !gt.isReviewing();
+                       }
+               } ]
+       } );
+
+} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I38ecddd5d8afcf59b7918378b94201d59b907c65
Gerrit-PatchSet: 16
Gerrit-Project: mediawiki/extensions/GuidedTour
Gerrit-Branch: master
Gerrit-Owner: SuchABot <yuvipanda+sucha...@gmail.com>
Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Spage <sp...@wikimedia.org>
Gerrit-Reviewer: Swalling <swall...@wikimedia.org>
Gerrit-Reviewer: Yuvipanda <yuvipa...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to