Siebrand has uploaded a new change for review.

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

Change subject: Add tests
......................................................................

Add tests

Fix all issues so tests pass.

Change-Id: I26bc2be13e7e185ecf8120da727f9641803ec950
---
A .gitignore
A .jscsrc
A .jshintignore
M AjaxLogin.class.php
M AjaxLogin.css
M AjaxLogin.js
M AjaxLogin.php
M AjaxLogin.template.php
M ApiAjaxLogin.php
A Gruntfile.js
A composer.json
R lib/jqModal.js
R lib/jqModal.r16.js
A package.json
A phpcs.xml
15 files changed, 142 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AjaxLogin 
refs/changes/64/242264/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..854a2d2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+*~
+*.kate-swp
+.*.swp
+node_modules/
+/composer.lock
+/vendor/
diff --git a/.jscsrc b/.jscsrc
new file mode 100644
index 0000000..9d22e3f
--- /dev/null
+++ b/.jscsrc
@@ -0,0 +1,3 @@
+{
+       "preset": "wikimedia"
+}
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..18be9f9
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,2 @@
+# upstream libs
+lib/*
diff --git a/AjaxLogin.class.php b/AjaxLogin.class.php
index 311bf5c..dfdf676 100644
--- a/AjaxLogin.class.php
+++ b/AjaxLogin.class.php
@@ -41,7 +41,9 @@
        public static function addJSVariable( $vars ) {
                global $wgEnableAjaxLogin;
 
-               $vars['wgEnableAjaxLogin'] = ( is_array( $wgEnableAjaxLogin ) ) 
? in_array( $vars['skin'], $wgEnableAjaxLogin ) : false;
+               $vars['wgEnableAjaxLogin'] = ( is_array( $wgEnableAjaxLogin ) ) 
?
+                       in_array( $vars['skin'], $wgEnableAjaxLogin ) :
+                       false;
 
                return true;
        }
@@ -65,7 +67,8 @@
         * Adds the AjaxLogin form to the skin output for anonymous users on
         * non-login pages
         *
-        * @param string $data The data, AjaxLogin form in this case, to be 
added to the HTML output of a page
+        * @param string $data The data, AjaxLogin form in this case,
+        *   to be added to the HTML output of a page
         * @param Skin $skin
         * @return bool
         */
@@ -84,7 +87,7 @@
                {
                        // Fun fact: using include() instead of require_once() 
can break some
                        // skins in mysterious ways that are very "fun" to 
track down...
-                       require_once( 'AjaxLogin.template.php' );
+                       require_once 'AjaxLogin.template.php';
                        $template = new AjaxLoginTemplate;
 
                        // In MediaWiki 1.23, we can just do:
@@ -97,4 +100,4 @@
 
                return true;
        }
-}
\ No newline at end of file
+}
diff --git a/AjaxLogin.css b/AjaxLogin.css
index b3b7abb..e558f77 100644
--- a/AjaxLogin.css
+++ b/AjaxLogin.css
@@ -99,4 +99,4 @@
 
 body.skin-quartz div#userloginRound {
        width: auto;
-}
\ No newline at end of file
+}
diff --git a/AjaxLogin.js b/AjaxLogin.js
index cf0b0f4..738069e 100644
--- a/AjaxLogin.js
+++ b/AjaxLogin.js
@@ -272,4 +272,4 @@
 
                ajaxLogin.initialize();
        }
-});
\ No newline at end of file
+});
diff --git a/AjaxLogin.php b/AjaxLogin.php
index 51a0f72..be498f0 100644
--- a/AjaxLogin.php
+++ b/AjaxLogin.php
@@ -20,7 +20,7 @@
 $wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'AjaxLogin',
-       'version' => '2.3',
+       'version' => '2.4',
        'author' => array( 'Inez KorczyƄski', 'Jack Phoenix', 'Ryan Schmidt' ),
        'url' => 'https://www.mediawiki.org/wiki/Extension:AjaxLogin',
        'descriptionmsg' => 'ajaxlogin-desc',
@@ -30,14 +30,14 @@
 // ResourceLoader support for MediaWiki 1.17+
 $wgResourceModules['ext.ajaxLogin.css'] = array(
        'styles' => 'AjaxLogin.css',
-       'localBasePath' => dirname( __FILE__ ),
+       'localBasePath' => __DIR__,
        'remoteExtPath' => 'AjaxLogin'
 );
 
 $wgResourceModules['ext.ajaxLogin.js'] = array(
-       'scripts' => array( 'jqModal.js', 'AjaxLogin.js' ),
+       'scripts' => array( 'lib/jqModal.js', 'AjaxLogin.js' ),
        'messages' => array( 'ajaxLogin1', 'ajaxLogin2' ),
-       'localBasePath' => dirname( __FILE__ ),
+       'localBasePath' => __DIR__,
        'remoteExtPath' => 'AjaxLogin'
 );
 
@@ -51,18 +51,17 @@
 );
 
 // Autoload AjaxLogin API interface
-$dir = dirname( __FILE__ ) . '/';
-$wgAutoloadClasses['ApiAjaxLogin'] = $dir . 'ApiAjaxLogin.php';
+$wgAutoloadClasses['ApiAjaxLogin'] = __DIR__ . '/ApiAjaxLogin.php';
 $wgAPIModules['ajaxlogin'] = 'ApiAjaxLogin';
 
 // Internationalization file
-$wgMessagesDirs['AjaxLogin'] = $dir . 'i18n';
+$wgMessagesDirs['AjaxLogin'] = __DIR__ . '/i18n';
 
 // Main PHP class, which contains all the hooked functions
-$wgAutoloadClasses['AjaxLogin'] = $dir . 'AjaxLogin.class.php';
+$wgAutoloadClasses['AjaxLogin'] = __DIR__ . '/AjaxLogin.class.php';
 
 // Hook things up
 $wgHooks['BeforePageDisplay'][] = 'AjaxLogin::loadAssets';
 $wgHooks['SkinAfterContent'][] = 'AjaxLogin::onSkinAfterContent';
 $wgHooks['ResourceLoaderGetConfigVars'][] = 'AjaxLogin::addJSVariable';
-$wgHooks['EditPage::showEditForm:fields'][] = 'AjaxLogin::onEditPage';
\ No newline at end of file
+$wgHooks['EditPage::showEditForm:fields'][] = 'AjaxLogin::onEditPage';
diff --git a/AjaxLogin.template.php b/AjaxLogin.template.php
index edb26a7..feecffb 100644
--- a/AjaxLogin.template.php
+++ b/AjaxLogin.template.php
@@ -23,38 +23,58 @@
 
                // The main div has display:none in order to prevent a Flash of 
Unstyled
                // Content
-?>
-<!--[if lt IE 9]><style type="text/css">#userloginRound { width: 350px 
!important; }</style><![endif]-->
-<div id="userloginRound" class="roundedDiv jqmWindow" style="display: none">
-       <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b 
class="xb3"></b><b class="xb4"></b></b>
-       <div class="r_boxContent">
-               <div>
-                       <div id="wpClose"><a href="#" 
tabindex="108"><span>X</span></a></div>
-                       <div class="boxHeader color1"><?php echo wfMessage( 
'login' )->plain() ?></div>
-               </div>
-               <form action="" method="post" name="userajaxloginform" 
id="userajaxloginform">
-                       <div id="wpError"></div>
-                       <label><?php echo wfMessage( 'loginprompt' )->parse() 
?></label><br /><br />
-                       <label for="wpName1"><?php echo wfMessage( 'yourname' 
)->plain() ?></label><br />
-                       <input type="text" class="loginText" name="wpName" 
id="wpName1" tabindex="101" size="20" /><br />
-                       <label for="wpPassword1"><?php echo wfMessage( 
'yourpassword' )->plain() ?></label><br />
-                       <input type="password" class="loginPassword" 
name="wpPassword" id="wpPassword1" tabindex="102" size="20" /><br />
-                       <div id="ajaxLoginRememberMe">
-                               <input type="checkbox" name="wpRemember" 
tabindex="104" value="1" id="wpRemember1"<?php echo ( $wgUser->getOption( 
'rememberpassword' ) ? ' checked="checked"' : '' ) ?> />
-                               <label for="wpRemember1"><?php echo wfMessage( 
'remembermypassword' )->numParams( $expirationDays )->text() ?></label><br />
+               ?>
+               <!--[if lt IE 9]>
+               <style type="text/css">#userloginRound {
+                       width: 350px !important;
+               }</style><![endif]-->
+               <div id="userloginRound" class="roundedDiv jqmWindow" 
style="display: none">
+                       <b class="xtop"><b class="xb1"></b><b 
class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
+
+                       <div class="r_boxContent">
+                               <div>
+                                       <div id="wpClose"><a href="#" 
tabindex="108"><span>X</span></a></div>
+                                       <div class="boxHeader color1"><?php 
echo wfMessage( 'login' )->plain() ?></div>
+                               </div>
+                               <form action="" method="post" 
name="userajaxloginform" id="userajaxloginform">
+                                       <div id="wpError"></div>
+                                       <label><?php echo wfMessage( 
'loginprompt' )->parse() ?></label><br/><br/>
+                                       <label for="wpName1"><?php echo 
wfMessage( 'yourname' )->plain() ?></label><br/>
+                                       <input type="text" class="loginText" 
name="wpName" id="wpName1" tabindex="101" size="20"/><br/>
+                                       <label for="wpPassword1"><?php echo 
wfMessage( 'yourpassword' )->plain() ?></label><br/>
+                                       <input type="password" 
class="loginPassword" name="wpPassword" id="wpPassword1" tabindex="102"
+                                                  size="20"/><br/>
+
+                                       <div id="ajaxLoginRememberMe">
+                                               <input type="checkbox" 
name="wpRemember" tabindex="104" value="1"
+                                                          id="wpRemember1"<?php
+                                               echo ( $wgUser->getOption( 
'rememberpassword' ) ? ' checked="checked"' : '' )
+                                               ?> />
+                                               <label
+                                                       for="wpRemember1"><?php
+                                                       echo wfMessage( 
'remembermypassword' )->numParams( $expirationDays )->text()
+                                                       ?></label><br/>
+                                       </div>
+                                       <input type="submit" 
name="wpLoginattempt" id="wpLoginattempt" tabindex="105"
+                                                  value="<?php echo wfMessage( 
'login' )->plain() ?>"/>
+                                       <?php if ( $wgEnableEmail && 
$wgAuth->allowPasswordChange() ) { ?>
+                                               <!--<br />--><input 
type="submit" name="wpMailmypassword" id="wpMailmypassword" tabindex="106"
+                                                                               
        value="<?php echo wfMessage( 'mailmypassword' )->plain() ?>"/>
+                                       <?php
+}
+                                       // Originally the link below used the 
core MediaWiki message 'nologinlink',
+                                       // but it wouldn't work too well for 
Finnish, so I changed it. -Jack Phoenix
+                                       ?>
+                                       <br/><a id="wpAjaxRegister" 
tabindex="107"
+                                                       href="<?php
+                                                       echo htmlspecialchars( 
$link ) ?>"><?php
+                                               echo wfMessage( 
'ajaxlogin-create' )->plain()
+                                               ?></a>
+                               </form>
                        </div>
-                       <input type="submit" name="wpLoginattempt" 
id="wpLoginattempt" tabindex="105" value="<?php echo wfMessage( 'login' 
)->plain() ?>" />
-                       <?php if ( $wgEnableEmail && 
$wgAuth->allowPasswordChange() ) { ?>
-                       <!--<br />--><input type="submit" 
name="wpMailmypassword" id="wpMailmypassword" tabindex="106" value="<?php echo 
wfMessage( 'mailmypassword' )->plain() ?>" />
-                       <?php }
-                       // Originally the link below used the core MediaWiki 
message 'nologinlink',
-                       // but it wouldn't work too well for Finnish, so I 
changed it. -Jack Phoenix
-                       ?>
-                       <br /><a id="wpAjaxRegister" tabindex="107" href="<?php 
echo htmlspecialchars( $link ) ?>"><?php echo wfMessage( 'ajaxlogin-create' 
)->plain() ?></a>
-               </form>
-       </div>
-       <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b 
class="xb2"></b><b class="xb1"></b></b>
-</div>
-<?php
+                       <b class="xbottom"><b class="xb4"></b><b class="xb3">
+                               </b><b class="xb2"></b><b class="xb1"></b></b>
+               </div>
+               <?php
        }
-}
\ No newline at end of file
+}
diff --git a/ApiAjaxLogin.php b/ApiAjaxLogin.php
index eada585..6a0625b 100644
--- a/ApiAjaxLogin.php
+++ b/ApiAjaxLogin.php
@@ -93,9 +93,10 @@
                                        $result['text'] = wfMessage( 
'al-createblocked' )->text();
                                        break;
                                case LoginForm::THROTTLED:
-                                       global $wgPasswordAttemptThrottle, 
$wgLang;
+                                       global $wgPasswordAttemptThrottle;
                                        $result['result'] = 'Throttled';
-                                       $result['text'] = wfMessage( 
'al-throttled' )->numParams( intval( $wgPasswordAttemptThrottle['seconds'] ) 
)->parse();
+                                       $result['text'] = wfMessage( 
'al-throttled' )
+                                               ->numParams( intval( 
$wgPasswordAttemptThrottle['seconds'] ) )->parse();
                                        break;
                                case LoginForm::USER_BLOCKED:
                                        $result['result'] = 'Blocked';
@@ -123,11 +124,11 @@
                        } elseif ( $wgUser->isBlocked() ) {
                                $result['result'] = 'blocked-mailpassword';
                                $result['text'] = wfMessage( 
'blocked-mailpassword' )->text();
-                       } elseif ( '' == $loginForm->mName ) {
+                       } elseif ( '' == $loginForm->getName() ) {
                                $result['result'] = 'noname';
                                $result['text'] = wfMessage( 'noname' )->text();
                        } else {
-                               $u = User::newFromName( $loginForm->mName );
+                               $u = User::newFromName( $loginForm->getName() );
                                if ( is_null( $u ) ) {
                                        $result['result'] = 'noname';
                                        $result['text'] = wfMessage( 'noname' 
)->text();
@@ -137,7 +138,8 @@
                                } elseif ( $u->isPasswordReminderThrottled() ) {
                                        global $wgPasswordReminderResendTime;
                                        $result['result'] = 
'throttled-mailpassword';
-                                       $result['text'] = wfMessage( 
'throttled-mailpassword' )->numParams( round( $wgPasswordReminderResendTime, 3 
) )->parse();
+                                       $result['text'] = wfMessage( 
'throttled-mailpassword' )
+                                               ->numParams( round( 
$wgPasswordReminderResendTime, 3 ) )->parse();
                                } else {
                                        $res = 
$loginForm->mailPasswordInternal( $u, true );
                                        if ( !$res->isGood() ) {
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..9c56558
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,20 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+       grunt.loadNpmTasks( 'grunt-banana-checker' );
+       grunt.loadNpmTasks( 'grunt-jsonlint' );
+
+       grunt.initConfig( {
+               banana: {
+                       all: 'i18n/'
+               },
+               jsonlint: {
+                       all: [
+                               '**/*.json',
+                               '!node_modules/**'
+                       ]
+               }
+       } );
+
+       grunt.registerTask( 'test', [ 'jsonlint', 'banana' ] );
+       grunt.registerTask( 'default', 'test' );
+};
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..4365e8a
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,12 @@
+{
+       "require-dev": {
+               "jakub-onderka/php-parallel-lint": "0.9",
+               "mediawiki/mediawiki-codesniffer": "0.4.0"
+       },
+       "scripts": {
+               "test": [
+                       "parallel-lint . --exclude vendor",
+                       "phpcs -p -s"
+               ]
+       }
+}
diff --git a/jqModal.js b/lib/jqModal.js
similarity index 99%
rename from jqModal.js
rename to lib/jqModal.js
index 76896fa..a0bd562 100644
--- a/jqModal.js
+++ b/lib/jqModal.js
@@ -227,4 +227,4 @@
                                });
                        });
                };
-})( jQuery );
\ No newline at end of file
+})( jQuery );
diff --git a/jqModal.r16.js b/lib/jqModal.r16.js
similarity index 99%
rename from jqModal.r16.js
rename to lib/jqModal.r16.js
index 9931ca8..5f59d18 100644
--- a/jqModal.r16.js
+++ b/lib/jqModal.r16.js
@@ -340,4 +340,4 @@
        I = 0,   // modal ID increment (for nested modals)
        A = [];  // array of active modals (used to lock interactivity to 
appropriate modal)
 
-})( jQuery, window );
\ No newline at end of file
+})( jQuery, window );
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..76e8a82
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+  "private": true,
+  "scripts": {
+    "test": "grunt test"
+  },
+  "devDependencies": {
+    "grunt": "0.4.5",
+    "grunt-cli": "0.1.13",
+    "grunt-banana-checker": "0.2.2",
+    "grunt-jsonlint": "1.0.4"
+  }
+}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset>
+       <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+       <file>.</file>
+       <arg name="extensions" value="php,php5,inc"/>
+       <arg name="encoding" value="utf8"/>
+       <exclude-pattern>vendor</exclude-pattern>
+</ruleset>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26bc2be13e7e185ecf8120da727f9641803ec950
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AjaxLogin
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>

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

Reply via email to