diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000000..7083b1ad46 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,5 @@ +{ + "node": true, + "browser": true, + "undef": true +} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000000..c194f452e3 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,47 @@ + +var configureGrunt = function(grunt) { + + var cfg = { + // JSHint all the things! + jshint2: { + options: { + jshintrc: ".jshintrc" + }, + all: [ + // Lint files in the root, including Gruntfile.js + "*.js", + // Lint core files, but not libs + ["core/**/*.js", "!**/assets/lib/**/*.js"] + ] + }, + + // Unit test all the things! + nodeunit: { + all: ['core/test/ghost/**/test-*.js'] + }, + + // Compile all the SASS! + compass: { + options: { + config: "config.rb" + }, + // No need for config, but separated for future options + admin: {} + } + }; + + grunt.initConfig(cfg); + + grunt.loadNpmTasks("grunt-jshint2"); + grunt.loadNpmTasks("grunt-contrib-nodeunit"); + grunt.loadNpmTasks("grunt-contrib-compass"); + + // Prepare the project for development + // TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)? + grunt.registerTask("init", ["compass:admin"]); + + // Run tests and lint code + grunt.registerTask("validate", ["jshint2:all", "nodeunit:all"]); +}; + +module.exports = configureGrunt; \ No newline at end of file diff --git a/core/admin/assets/js/tagui.js b/core/admin/assets/js/tagui.js index 2713e8f8d3..fa3e3ca867 100644 --- a/core/admin/assets/js/tagui.js +++ b/core/admin/assets/js/tagui.js @@ -99,8 +99,8 @@ } } else if (e.keyCode === keys.ESC) { suggestions.hide(); - } else if ((e.keyCode === keys.ENTER || e.keyCode === keys.COMMA) - && searchTerm) { // Submit tag using enter or comma key + } else if ((e.keyCode === keys.ENTER || e.keyCode === keys.COMMA)&& searchTerm) { + // Submit tag using enter or comma key e.preventDefault(); if (suggestions.is(":visible") && suggestions.children(".selected").length !== 0) { diff --git a/core/ghost.js b/core/ghost.js index 30be09d74c..b1de1a4148 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -75,7 +75,7 @@ polyglot: function () { return polyglot; }, paths: function () { return { - 'activeTheme': __dirname + '/../content/' + config.themeDir + '/' + config.activeTheme + '/', + 'activeTheme': path.resolve(__dirname + '/../content/' + config.themeDir + '/' + config.activeTheme + '/'), 'adminViews': __dirname + '/admin/views/', 'lang': __dirname + '/lang/' }; @@ -158,7 +158,7 @@ )); app.set('views', self.paths().activeTheme); } else { - app.engine('hbs', hbs.express3({partialsDir: self.paths().adminViews + '/partials'})); + app.engine('hbs', hbs.express3({partialsDir: self.paths().adminViews + 'partials'})); app.set('views', self.paths().adminViews); app.use('/core/admin/assets', express['static'](path.join(__dirname, '/admin/assets'))); } diff --git a/package.json b/package.json index ae33d32f32..12531f82c1 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,17 @@ "css": "*", "moment": "*", "underscore": "*", - "nodeunit": "*", "showdown": "*", "node-polyglot": "*", "sqlite3": "2.1.7", "jugglingdb": "0.2.x", "jugglingdb-sqlite3": "git+https://github.com/jugglingdb/sqlite3-adapter.git#master" + }, + "devDependencies": { + "nodeunit": "*", + "grunt": "~0.4.1", + "grunt-contrib-nodeunit": "~0.1.2", + "grunt-jshint2": "~0.1.1", + "grunt-contrib-compass": "~0.2.0" } -} \ No newline at end of file +}