Umherirrender has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/331904 )

Change subject: Fix build
......................................................................

Fix build

Similar to I215fabe129933a04644e05eb541cbf3b34699095

Update .gitignore to ignore package manager material (node_modules,
vendor and composer.lock).

PHP_CodeSniffer:

Fix up white spaces after comment character.
Add spaces next to parentheses.

PagePopups.hooks.php
Reindent with tabulations

npm:

Bump grunt to 1.x which now ship with a grunt CLI utility. Hence remove
grunt-cli which is no more needed.

Remove jscsc task. It does not pass yet, see BoilerPlates extension to
add it later.

Comment out 'banana' since there is no i18n files yet.

Change-Id: I25fdd0d99dfab483cc7bedd8c7b4e26dcc136978
---
M .gitignore
M Gruntfile.js
M NamespacePopups.hooks.php
M NamespacePopups.php
M package.json
5 files changed, 59 insertions(+), 42 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/NamespacePopups 
refs/changes/04/331904/1

diff --git a/.gitignore b/.gitignore
index b25c15b..abae72d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
+/node_modules
+/vendor
+/composer.lock
 *~
diff --git a/Gruntfile.js b/Gruntfile.js
index 6ad5e33..dbe381d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -3,7 +3,6 @@
        grunt.loadNpmTasks( 'grunt-contrib-jshint' );
        grunt.loadNpmTasks( 'grunt-jsonlint' );
        grunt.loadNpmTasks( 'grunt-banana-checker' );
-       grunt.loadNpmTasks( 'grunt-jscs' );
 
        grunt.initConfig( {
                jshint: {
@@ -26,6 +25,6 @@
                }
        } );
 
-       grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
+       grunt.registerTask( 'test', [ 'jshint', 'jsonlint', /* 'banana' */ ] );
        grunt.registerTask( 'default', 'test' );
 };
diff --git a/NamespacePopups.hooks.php b/NamespacePopups.hooks.php
index 71c76b2..b152a80 100644
--- a/NamespacePopups.hooks.php
+++ b/NamespacePopups.hooks.php
@@ -4,68 +4,84 @@
 
 class NamespacePopupsHooks {
        public static function onHtmlPageLinkRendererEnd( $renderer, $target, 
$isKnown, &$text, &$attribs, &$ret ) {
-                global $wgNamespacePopupsNamespaceMap, 
$wgNamespacePopupsAnchor;
+               global $wgNamespacePopupsNamespaceMap, $wgNamespacePopupsAnchor;
 
-                if(!$wgNamespacePopupsNamespaceMap) return true;
+               if ( !$wgNamespacePopupsNamespaceMap ) {
+                       return true;
+               }
 
-                // It does not work with $target instanceof TitleValue (as in 
"search for this page title")
-//                 $linkNS = $target->getSubjectNsText();
+               // It does not work with $target instanceof TitleValue (as in 
"search for this page title")
+               // $linkNS = $target->getSubjectNsText();
                global $wgContLang;
                $linkNS = $wgContLang->getNsText( MWNamespace::getSubject( 
$target->getNamespace() ) );
 
-                if(!$linkNS) $linkNS = ''; // needed?
+               if ( !$linkNS ) {
+                       $linkNS = ''; // needed?
+               }
 
-                $popupNS = isset($wgNamespacePopupsNamespaceMap[$linkNS]) ? 
$wgNamespacePopupsNamespaceMap[$linkNS] : null;
-                if(!$popupNS) $popupNS = 
isset($wgNamespacePopupsNamespaceMap['*']) ? 
$wgNamespacePopupsNamespaceMap['*'] : null;
-                if(!$popupNS) return true;
-                if($popupNS === '*') $popupNS = $linkNS;
+               $popupNS = isset( $wgNamespacePopupsNamespaceMap[$linkNS] )
+                       ? $wgNamespacePopupsNamespaceMap[$linkNS] : null;
+               if ( !$popupNS ) {
+                       $popupNS = isset( $wgNamespacePopupsNamespaceMap['*'] )
+                               ? $wgNamespacePopupsNamespaceMap['*'] : null;
+               }
+               if ( !$popupNS ) {
+                       return true;
+               }
+               if ( $popupNS === '*' ) {
+                       $popupNS = $linkNS;
+               }
 
                $remains = $target->getDBkey();
-                $anchor = $wgNamespacePopupsAnchor ? $wgNamespacePopupsAnchor 
: '↑';
-                $page = $popupNS === '' ? $remains : "$popupNS:$remains";
+               $anchor = $wgNamespacePopupsAnchor ? $wgNamespacePopupsAnchor : 
'↑';
+               $page = $popupNS === '' ? $remains : "$popupNS:$remains";
                $title = Title::newFromText( $page );
-               if(!$title) return true;
-                $url = $title->getLocalUrl();
+               if( !$title ) {
+                       return true;
+               }
+               $url = $title->getLocalUrl();
 
                $html = HtmlArmor::getHtml( $text );
                $html = Html::rawElement( 'a', $attribs, $html );
                if ( $title->isKnown() ) {
-                        $html .= Html::rawElement( 'a', [ 'class' => 
'mw-pagepopup', 'href' => $url ], $anchor );
+                       $html .= Html::rawElement( 'a', [ 'class' => 
'mw-pagepopup', 'href' => $url ], $anchor );
                } else {
-                        $html .= Html::rawElement( 'a', [ 'class' => 
'mw-pagepopup new', 'href' => $url ], $anchor );
+                       $html .= Html::rawElement( 'a', [ 'class' => 
'mw-pagepopup new', 'href' => $url ], $anchor );
                }
 
                $ret = $html;
-                return false;
+               return false;
        }
 
        public static function onParserAfterTidy( &$parser, &$text ) {
-                global $wgNamespacePopupsNamespaceMap;
+               global $wgNamespacePopupsNamespaceMap;
 
-                if(!$wgNamespacePopupsNamespaceMap) return;
+               if(!$wgNamespacePopupsNamespaceMap) return;
 
-                $parserOutput = $parser->getOutput();
+               $parserOutput = $parser->getOutput();
 
-                $oldLinks = [];
-                // The below algorithm enumerates all links. This may be a 
little inefficient
-                foreach($parserOutput->getLinks() as $linkNSid => $linksArray) 
{
-                        $linkNS = MWNamespace::getCanonicalName( $linkNSid );
-                        foreach(array_keys($linksArray) as $remains)
-                                $oldLinks[] = [ $linkNS, $remains ];
-                }
+               $oldLinks = [];
+               // The below algorithm enumerates all links. This may be a 
little inefficient
+               foreach($parserOutput->getLinks() as $linkNSid => $linksArray) {
+                       $linkNS = MWNamespace::getCanonicalName( $linkNSid );
+                       foreach(array_keys($linksArray) as $remains)
+                               $oldLinks[] = [ $linkNS, $remains ];
+               }
 
-                foreach($oldLinks as $linkInfo) {
-                        list($linkNS, $remains) = $linkInfo;
+               foreach($oldLinks as $linkInfo) {
+                       list($linkNS, $remains) = $linkInfo;
 
-                        $popupNS = @$wgNamespacePopupsNamespaceMap[$linkNS] ?: 
@$wgNamespacePopupsNamespaceMap['*'];
-                        if(!$popupNS) continue;
-                        if($popupNS === '*') {
-                                $popupPage = $linkPage;
-                        } else {
-                                $popupPage = $popupNS === '' ? $remains : 
"$popupNS:$remains";
-                        }
+                       $popupNS = @$wgNamespacePopupsNamespaceMap[$linkNS] ?: 
@$wgNamespacePopupsNamespaceMap['*'];
+                       if ( !$popupNS ) {
+                               continue;
+                       }
+                       if ( $popupNS === '*' ) {
+                               $popupPage = $linkPage;
+                       } else {
+                               $popupPage = $popupNS === '' ? $remains : 
"$popupNS:$remains";
+                       }
 
-                        $parserOutput->addLink( 
Title::newFromDBkey($popupPage) );
-                }
+                       $parserOutput->addLink( Title::newFromDBkey( $popupPage 
) );
+               }
        }
 }
diff --git a/NamespacePopups.php b/NamespacePopups.php
index 2834a93..fcefc6a 100644
--- a/NamespacePopups.php
+++ b/NamespacePopups.php
@@ -3,7 +3,7 @@
 if ( function_exists( 'wfLoadExtension' ) ) {
        wfLoadExtension( 'NamespacePopups' );
        // Keep i18n globals so mergeMessageFileList.php doesn't break
-       //$wgMessagesDirs['NamespacePopups'] = __DIR__ . '/i18n';
+       // $wgMessagesDirs['NamespacePopups'] = __DIR__ . '/i18n';
        /* wfWarn(
                'Deprecated PHP entry point used for NamespacePopups extension. 
Please use wfLoadExtension instead, ' .
                'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
diff --git a/package.json b/package.json
index ae122b3..afe0c25 100644
--- a/package.json
+++ b/package.json
@@ -4,8 +4,7 @@
     "test": "grunt test"
   },
   "devDependencies": {
-    "grunt": "0.4.5",
-    "grunt-cli": "0.1.13",
+    "grunt": "1.0.1",
     "grunt-contrib-jshint": "1.0.0",
     "grunt-banana-checker": "0.5.0",
     "grunt-jsonlint": "1.0.7"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25fdd0d99dfab483cc7bedd8c7b4e26dcc136978
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/NamespacePopups
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

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

Reply via email to