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

Change subject: Make stats table target languages as links to translations 
using cx
......................................................................


Make stats table target languages as links to translations using cx

Links point to Special:RecentChanges?tagfilter=contenttranslation in
target wikis

Introduces 'action' URL pattern in wgContentTranslationSiteTemplates

Change-Id: I5314c5c6b1480047c5e7489ba5d59465459dd9a2
---
M ContentTranslation.php
M Resources.php
M modules/base/ext.cx.sitemapper.js
M modules/stats/ext.cx.stats.js
M modules/stats/styles/ext.cx.stats.less
5 files changed, 35 insertions(+), 4 deletions(-)

Approvals:
  Santhosh: Looks good to me, but someone else must approve
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ContentTranslation.php b/ContentTranslation.php
index 5dd97ee..bc4c9c7 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -111,6 +111,7 @@
  */
 $GLOBALS['wgContentTranslationSiteTemplates'] = array(
        'view' => '//$1.wikipedia.org/wiki/$2',
+       'action' => '//$1.wikipedia.org/w/index.php?title=$2',
        'api' => '//$1.wikipedia.org/w/api.php',
        'cx' => 'http://localhost:8080',
 );
diff --git a/Resources.php b/Resources.php
index 5a95cf4..730f129 100644
--- a/Resources.php
+++ b/Resources.php
@@ -620,6 +620,9 @@
        'styles' => array(
                'stats/styles/ext.cx.stats.less',
        ),
+       'dependencies' => array(
+               'ext.cx.sitemapper',
+       ),
        'messages' => array(
                'cx-stats-table-source-target',
                'cx-stats-table-source-total',
diff --git a/modules/base/ext.cx.sitemapper.js 
b/modules/base/ext.cx.sitemapper.js
index 4deabf1..6c5ea42 100644
--- a/modules/base/ext.cx.sitemapper.js
+++ b/modules/base/ext.cx.sitemapper.js
@@ -39,10 +39,19 @@
         *
         * @param {string} language Language code
         * @param {string} title Page title
+        * @param {Object} [params] Query parameters
         * @return {string}
         */
-       mw.cx.SiteMapper.prototype.getPageUrl = function ( language, title ) {
-               return this.config.view.replace( '$1', language ).replace( 
'$2', title );
+       mw.cx.SiteMapper.prototype.getPageUrl = function ( language, title, 
params ) {
+               var base = this.config.view,
+                       extra = '';
+
+               if ( params && !$.isEmptyObject( params ) ) {
+                       base = this.config.action || this.config.view;
+                       extra = ( base.indexOf( '?' ) !== -1 ? '&' : '?' ) + 
$.param( params );
+               }
+
+               return base.replace( '$1', language ).replace( '$2', title ) + 
extra;
        };
 
        /**
diff --git a/modules/stats/ext.cx.stats.js b/modules/stats/ext.cx.stats.js
index e65c2f2..b91ad0e 100644
--- a/modules/stats/ext.cx.stats.js
+++ b/modules/stats/ext.cx.stats.js
@@ -51,7 +51,16 @@
                                        continue;
                                }
                                if ( i === 0 ) {
-                                       table[ 0 ][ j ] = languages[ j - 1 ];
+                                       table[ 0 ][ j ] = $( '<a>' )
+                                               .attr( {
+                                                       target: '_blank',
+                                                       href: 
mw.cx.siteMapper.getPageUrl(
+                                                               languages[ j - 
1 ],
+                                                               
'Special:RecentChanges',
+                                                               { tagfilter: 
'contenttranslation' }
+                                                       )
+                                               } )
+                                               .text( languages[ j - 1 ] );
                                        continue;
                                }
                                if ( j === 0 ) {
@@ -102,7 +111,11 @@
                        $row = $( '<tr>' );
                        for ( j = 0; j < table.length; j++ ) {
                                value = table[ i ][ j ];
-                               $td = $( '<td>' ).text( value === 0 ? '' : 
mw.language.convertNumber( value ) );
+                               if ( value instanceof jQuery ) {
+                                       $td = $( '<td>' ).append( value );
+                               } else {
+                                       $td = $( '<td>' ).text( value === 0 ? 
'' : mw.language.convertNumber( value ) );
+                               }
                                if ( i > 0 && j > 0 && i < table.length - 1 && 
j <
                                        table.length - 1 && value > 0 ) {
                                        $td.addClass( 'cx-stat-color-' + 
parseInt( value / division ) );
@@ -134,6 +147,8 @@
        }
 
        $( function () {
+               mw.cx.siteMapper = new mw.cx.SiteMapper( mw.config.get( 
'wgContentTranslationSiteTemplates' ) );
+
                getCXStats().then( function ( data ) {
                        var $container = $( '#bodyContent' );
                        $container.append(
diff --git a/modules/stats/styles/ext.cx.stats.less 
b/modules/stats/styles/ext.cx.stats.less
index e8e8237..b304b52 100644
--- a/modules/stats/styles/ext.cx.stats.less
+++ b/modules/stats/styles/ext.cx.stats.less
@@ -13,6 +13,9 @@
        thead {
                font-weight: 700;
                background-color: #eee;
+               a {
+                       color: #252525;
+               }
        }
        .cx-stat-color-0 {
                background-color: #E8F5E9;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5314c5c6b1480047c5e7489ba5d59465459dd9a2
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to