Nikerabbit has uploaded a new change for review.

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


Change subject: Make the project tiles go to project page if one exists
......................................................................

Make the project tiles go to project page if one exists

Targets are currently hardcoded to Translating:Project label,
which works for many but not all projects in translatewiki.net

Change-Id: I6a85bef2773b91ca0cbc4ff27f196ced40ba4bae
---
M resources/css/ext.translate.mainpage.css
M resources/js/ext.translate.mainpage.js
M specials/SpecialTwnMainPage.php
3 files changed, 25 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TwnMainPage 
refs/changes/81/83081/1

diff --git a/resources/css/ext.translate.mainpage.css 
b/resources/css/ext.translate.mainpage.css
index 68c6bae..778df66 100644
--- a/resources/css/ext.translate.mainpage.css
+++ b/resources/css/ext.translate.mainpage.css
@@ -255,6 +255,10 @@
        height: 180px;
 }
 
+.project-tile.linked {
+       cursor: pointer;
+}
+
 .project-tile:hover {
        border-color: #777;
        box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
diff --git a/resources/js/ext.translate.mainpage.js 
b/resources/js/ext.translate.mainpage.js
index 8e4502e..753c849 100644
--- a/resources/js/ext.translate.mainpage.js
+++ b/resources/js/ext.translate.mainpage.js
@@ -7,7 +7,7 @@
        'use strict';
 
        $( document ).ready( function () {
-               var $tiles, language;
+               var $tiles, language, $selector;
 
                $tiles = $( '.project-tile' );
 
@@ -27,10 +27,9 @@
 
                language = mw.config.get( 'wgUserLanguage' );
 
-               // Take the last tile
-               $tiles.eq( 7 )
-                       .empty()
-                       .addClass( 'more' )
+               // Prepare one project tile to be a message group selector.
+               $selector = $( '<div>' )
+                       .addClass( 'project-tile more' )
                        .text( mw.msg( 'twnmp-show-more-projects' ) )
                        .one( 'click', function () {
                                $.when(
@@ -47,6 +46,10 @@
                                        at: 'right bottom+275'
                                }
                        } );
+
+               // Replace the last shown tile with group selector.
+               // Users without JavaScript will just see the original one.
+               $tiles.eq( 7 ).replaceWith( $selector );
        } );
 }( jQuery, mediaWiki ) );
 
diff --git a/specials/SpecialTwnMainPage.php b/specials/SpecialTwnMainPage.php
index 5c0a2c8..dbedbb7 100644
--- a/specials/SpecialTwnMainPage.php
+++ b/specials/SpecialTwnMainPage.php
@@ -174,6 +174,18 @@
                        $proofread = round( 100 * $proofread / 
$stats[MessageGroupStats::TOTAL] );
                }
 
+               // Approximate project page links while we don't have config 
value for them
+               $projectPage = Title::newFromText( 
"Translating:{$group->getLabel()}" );
+               $dataUrl = $linked = '';
+               if ( $projectPage->exists() ) {
+                       $dataUrl = str_replace(
+                               'X',
+                               htmlspecialchars( $projectPage->getLocalUrl() ),
+                               'data-url="X"'
+                       );
+                       $linked = 'linked';
+               }
+
                $image = Html::element( 'div', array( 'class' => 
"project-icon-$id" ) );
                $label = htmlspecialchars( $group->getLabel( 
$this->getContext() ) );
                $stats = $statsbar->getHtml( $this->getContext() );
@@ -194,7 +206,7 @@
 
                $out = <<<HTML
 <div class="three columns twn-mainpage-project-tile">
-       <div class="project-tile">
+       <div class="project-tile $linked" $dataUrl>
                <div class="row project-top">
                        <div class="project-icon four columns">$image</div>
                        <div class="project-content eight columns">

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a85bef2773b91ca0cbc4ff27f196ced40ba4bae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TwnMainPage
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>

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

Reply via email to