Mooeypoo has uploaded a new change for review.

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

Change subject: Add Gruntfile and fix style errors
......................................................................

Add Gruntfile and fix style errors

Adjust to the new VE style, add grunt jscs/jshint/csslint tasks
and remove this.$ references.

Change-Id: I42e6190d73fb94ead41f592b63cf47000ee1cdc2
---
M .gitignore
M .jscsrc
A Gruntfile.js
A LICENSE-MIT
M modules/ve.ui.CiteFromIDDialog.js
M modules/ve.ui.CiteFromIDDialogTool.js
A package.json
7 files changed, 109 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid 
refs/changes/47/190847/1

diff --git a/.gitignore b/.gitignore
index b4b9cdc..874939c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 .DS_Store
-*~
\ No newline at end of file
+*~
+node_modules
diff --git a/.jscsrc b/.jscsrc
index 926db0f..9d22e3f 100644
--- a/.jscsrc
+++ b/.jscsrc
@@ -1,5 +1,3 @@
 {
-       "preset": "wikimedia",
-       "disallowQuotedKeysInObjects": null,
-       "requireSpacesInsideArrayBrackets": null
-}
\ No newline at end of file
+       "preset": "wikimedia"
+}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..7fb9c36
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,42 @@
+/*!
+ * Grunt file
+ *
+ * @package Citoid
+ */
+
+/*jshint node:true */
+module.exports = function ( grunt ) {
+       grunt.loadNpmTasks( 'grunt-banana-checker' );
+       grunt.loadNpmTasks( 'grunt-contrib-csslint' );
+       grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+       grunt.loadNpmTasks( 'grunt-contrib-watch' );
+       grunt.loadNpmTasks( 'grunt-jscs' );
+
+       grunt.initConfig( {
+               pkg: grunt.file.readJSON( 'package.json' ),
+               jshint: {
+                       options: {
+                               jshintrc: true
+                       },
+                       all: [
+                               'modules/*.js'
+                       ]
+               },
+               jscs: {
+                       src: '<%= jshint.all %>'
+               },
+               banana: {
+                       all: 'i18n/'
+               },
+               watch: {
+                       files: [
+                               '.{csslintrc,jscsrc,jshintignore,jshintrc}',
+                               '<%= jshint.all %>'
+                       ],
+                       tasks: 'test'
+               }
+       } );
+
+       grunt.registerTask( 'test', [ 'jshint', 'jscs', 'banana' ] );
+       grunt.registerTask( 'default', 'test' );
+};
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..94c81a8
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,20 @@
+Copyright 2011-2015 Citoid Team and other contributors.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/modules/ve.ui.CiteFromIDDialog.js 
b/modules/ve.ui.CiteFromIDDialog.js
index 85c6a4f..90d4ad2 100644
--- a/modules/ve.ui.CiteFromIDDialog.js
+++ b/modules/ve.ui.CiteFromIDDialog.js
@@ -36,28 +36,22 @@
                // Booklet layout required due to inheriting from 
MWTemplateDialog
                this.bookletLayout = new OO.ui.BookletLayout(
                        ve.extendObject(
-                               { $: this.$ },
                                this.constructor.static.bookletLayoutConfig
                        )
                );
 
                this.searchInput = new OO.ui.TextInputWidget( {
-                       $: this.$,
                        multiline: false,
                        placeholder: mw.msg( 
'citoid-citeFromIDDialog-search-placeholder' )
                } );
 
                var panel = new OO.ui.PanelLayout( {
-                               $: this.$,
                                padded: true,
                                scrollable: true,
                                expanded: false
                        } ),
-                       inputsFieldset = new OO.ui.FieldsetLayout( {
-                               $: this.$
-                       } ),
+                       inputsFieldset = new OO.ui.FieldsetLayout(),
                        searchField = new OO.ui.FieldLayout( this.searchInput, {
-                               $: this.$,
                                align: 'top',
                                label: mw.msg( 
'citoid-citeFromIDDialog-search-label' )
                        } );
@@ -69,7 +63,7 @@
                panel.$element.append( inputsFieldset.$element );
                this.$body.append( panel.$element );
 
-               this.modules = ['ext.visualEditor.data'];
+               this.modules = [ 'ext.visualEditor.data' ];
 
        };
 
@@ -80,7 +74,7 @@
        ve.ui.CiteFromIDDialog.prototype.insertTemplate = function ( 
searchResults ) {
 
                var transclusion, template, templateName, templateTypeMap, 
partPromise, item, fragment,
-                       citation = searchResults[0], //uses the first citation 
result for the time being
+                       citation = searchResults[ 0 ], // Uses the first 
citation result for the time being
                        dialog = this,
                        surfaceModel = this.getFragment().getSurface(),
                        doc = surfaceModel.getDocument(),
@@ -117,7 +111,7 @@
                        // if TemplateName is undefined, this means that items 
of this citoid
                        // type does not have a Template defined within the 
message.
                        if ( !templateName ) {
-                               mw.notify( mw.msg( 
'citoid-typeMap-config-error') );
+                               mw.notify( mw.msg( 
'citoid-typeMap-config-error' ) );
                                dialog.popPending();
                                return;
                        }
@@ -164,20 +158,20 @@
                        // Construct parameters
                        if ( typeof templateField === 'string' && 
citation[citoidField] !== undefined ) {
                                // Case: Citoid parameter directly equivalent 
to TemplateData parameter
-                               template.addParameter( new 
ve.dm.MWParameterModel( template, templateField, citation[citoidField] ) );
+                               template.addParameter( new 
ve.dm.MWParameterModel( template, templateField, citation[citoidField ] ) );
                        } else if ( Array.isArray( citation[citoidField] ) ) {
                                // Case: Citoid parameter equivalent to 1 or 2D 
Array of TD parameters
-                               for ( i = 0; i < citation[citoidField].length; 
i++ ) {
+                               for ( i = 0; i < citation[ citoidField 
].length; i++ ) {
                                        // Iterate through first dimension of 
array
-                                       if ( typeof citation[citoidField][i] 
=== 'string' && templateField[i] !== undefined) {
+                                       if ( typeof citation[ citoidField ][ i 
] === 'string' && templateField[i] !== undefined ) {
                                                // Case: Citoid parameter 
equivalent to 1D Array of TD parameters
-                                               template.addParameter( new 
ve.dm.MWParameterModel( template, templateField[i], citation[citoidField][i] ) 
);
-                                       } else if ( Array.isArray( 
citation[citoidField][i] ) ) {
+                                               template.addParameter( new 
ve.dm.MWParameterModel( template, templateField[i], citation[ citoidField ][ i 
] ) );
+                                       } else if ( Array.isArray( citation[ 
citoidField ][ i ] ) ) {
                                                // Case: Citoid parameter 
equivalent to 2D Array of TD parameters
-                                               for ( j = 0; j < 
citation[citoidField][i].length; j++ ) {
+                                               for ( j = 0; j < citation[ 
citoidField ][ i ].length; j++ ) {
                                                        // Iterate through 2nd 
dimension of Array
-                                                       if (typeof 
citation[citoidField][i][j] === 'string' && templateField[i][j] !== undefined) {
-                                                               
template.addParameter( new ve.dm.MWParameterModel( template, 
templateField[i][j], citation[citoidField][i][j]) );
+                                                       if ( typeof citation[ 
citoidField ][ i ][ j ] === 'string' && templateField[ i ][ j ] !== undefined ) 
{
+                                                               
template.addParameter( new ve.dm.MWParameterModel( template, templateField[ i 
][ j ], citation[ citoidField ][ i ][ j ] ) );
                                                        }
                                                }
                                        }
@@ -216,7 +210,7 @@
                                                // choosing to insert that 
citation here but to notify the user.
                                                if ( response.status === 520 ) {
                                                        dialog.insertTemplate( 
response.responseJSON );
-                                                       mw.notify( mw.message 
('citoid-520-error') );
+                                                       mw.notify( mw.message( 
'citoid-520-error' ) );
                                                } else {
                                                        mw.notify( 'Status: '  
+ textStatus +  'Error: ' + errorThrown );
                                                }
@@ -240,7 +234,7 @@
                // Parent method
                
ve.ui.CiteFromIDDialog.super.prototype.onTransclusionReady.call( this );
                // TODO- disable when no input
-               this.actions.setAbilities( { 'apply': true, 'insert': true } );
+               this.actions.setAbilities( { apply: true, insert: true } );
        };
 
        /**
@@ -267,7 +261,7 @@
                return 
ve.ui.CiteFromIDDialog.super.prototype.getTeardownProcess.call( this, data )
                        .first( function () {
                                // Clear search input box
-                               this.searchInput.setValue('');
+                               this.searchInput.setValue( '' );
                        }, this );
        };
 
diff --git a/modules/ve.ui.CiteFromIDDialogTool.js 
b/modules/ve.ui.CiteFromIDDialogTool.js
index 721eb9c..849ee09 100644
--- a/modules/ve.ui.CiteFromIDDialogTool.js
+++ b/modules/ve.ui.CiteFromIDDialogTool.js
@@ -11,7 +11,7 @@
         * @param {Object} [config] Configuration options
         */
 
-       //Don't create tool unless the configuration message is present
+       // Don't create tool unless the configuration message is present
        try {
                JSON.parse( mw.message( 'citoid-template-type-map.json' 
).plain() );
        } catch ( e ) {
@@ -33,10 +33,10 @@
        ve.ui.commandRegistry.register(
                new ve.ui.Command(
                        'citefromid', 'window', 'open',
-                       { args: ['citefromid'], supportedSelections: ['linear'] 
}
+                       { args: [ 'citefromid' ], supportedSelections: [ 
'linear' ] }
                )
        );
 
        ve.ui.toolFactory.register( ve.ui.CiteFromIDDialogTool );
 
-});
+} );
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..0d4f330
--- /dev/null
+++ b/package.json
@@ -0,0 +1,25 @@
+{
+  "name": "citoid",
+  "version": "0.0.0",
+  "scripts": {
+    "test": "grunt test"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Citoid.git";
+  },
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": 
"https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FCitoid.git/master/LICENSE-MIT";
+    }
+  ],
+  "devDependencies": {
+    "grunt": "0.4.5",
+    "grunt-banana-checker": "0.2.0",
+    "grunt-contrib-csslint": "0.4.0",
+    "grunt-contrib-jshint": "0.11.0",
+    "grunt-contrib-watch": "0.6.1",
+    "grunt-jscs": "1.5.0"
+  }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42e6190d73fb94ead41f592b63cf47000ee1cdc2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

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

Reply via email to