Mattflaschen has uploaded a new change for review.

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


Change subject: Determine page name without red-link-title.  Use href and title
......................................................................

Determine page name without red-link-title.  Use href and title

Change-Id: I18290a19da3bffd6718f1ed3ce132bfc79656fea
---
M GettingStarted.php
M resources/ext.gettingstarted.common.accountCreation.js
2 files changed, 17 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted 
refs/changes/31/64631/1

diff --git a/GettingStarted.php b/GettingStarted.php
index 5406067..cdd42ad 100644
--- a/GettingStarted.php
+++ b/GettingStarted.php
@@ -214,11 +214,12 @@
 
 // This runs on account creation for both test and control
 $wgResourceModules[ 'ext.gettingstarted.common.accountCreation' ] = array(
-       'messages' => array(
-               'red-link-title',
-       ),
        'scripts' => 'ext.gettingstarted.common.accountCreation.js',
-       'dependencies' => 'ext.gettingstarted.logging',
+       'dependencies' => array(
+               'mediawiki.Title',
+               'mediawiki.util',
+               'ext.gettingstarted.logging',
+       ),
        'position' => 'top',
 ) + $gettingStartedModuleInfo;
 
diff --git a/resources/ext.gettingstarted.common.accountCreation.js 
b/resources/ext.gettingstarted.common.accountCreation.js
index 8e96eab..3c8a64c 100644
--- a/resources/ext.gettingstarted.common.accountCreation.js
+++ b/resources/ext.gettingstarted.common.accountCreation.js
@@ -28,27 +28,23 @@
        }
 
        /**
-        * Gets a page name from the value of a title attribute
+        * Gets a page name from a jQuery-wrapped link, in prefixed text format.
         *
-        * @param {string} titleText title text
+        * @param {jQuery} $link wrapped link
         *
         * @return {string} page name
         */
-       function getPageFromTitleAttribute( titleText ) {
-               // Access the map directly, since we're processing it unusually.
-               var redLinkFormat = mw.messages.get( 'red-link-title' ),
-               redLinkRegexText,
-               redLinkRegex,
-               redLinkMatch;
+       function getPageFromLink( $link ) {
+               var titleText, href, titleFromQuery, titleObj;
 
-               redLinkRegexText = $.escapeRE( redLinkFormat );
-               // Replace escaped $1 with capturing group for one or more 
characters
-               redLinkRegexText = redLinkRegexText.replace( '\\$1', '(.+)' );
-               redLinkRegex = new RegExp( '^' + redLinkRegexText + '$' );
+               titleText = $link.attr( 'title' );
+               href = $link.attr( 'href' );
 
-               redLinkMatch = titleText.match( redLinkRegex );
-               if ( redLinkMatch !== null ) {
-                       return redLinkMatch[1];
+               titleFromQuery = mw.util.getParamValue( 'title', href );
+               // Red links will use first branch.
+               if ( titleFromQuery !== null ) {
+                       titleObj = new mw.Title( titleFromQuery );
+                       return titleObj.getPrefixedText();
                } else {
                        return titleText;
                }
@@ -69,7 +65,7 @@
 
                // If the user clicks the returnTo link, log it and maybe start 
a funnel.
                $returnToA.on( 'click', function ( e ) {
-                       var article = getPageFromTitleAttribute( 
$returnToA.attr( 'title' ) ),
+                       var article = getPageFromLink( $returnToA ),
                                task = 'returnto';
 
                        if ( isAppropriateTaskArticle( article ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I18290a19da3bffd6718f1ed3ce132bfc79656fea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GettingStarted
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>

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

Reply via email to