You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/07/09 15:32:57 UTC
[7/7] git commit: updated refs/heads/1846-dev-server-improvements to
98a4a1b
Improved development server
Fauton: Much faster and simpler build server. Only updates changed files, uses
requirejs to load necessary dependancies.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/98a4a1b8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/98a4a1b8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/98a4a1b8
Branch: refs/heads/1846-dev-server-improvements
Commit: 98a4a1b862b22229b7bc96743118a20f217da7f8
Parents: 03d1b7e
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Jun 27 16:17:59 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Jul 9 15:32:26 2013 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 83 +-
src/fauxton/app/api.js | 2 +-
src/fauxton/app/app.js | 1 -
src/fauxton/app/config.js | 3 +-
src/fauxton/app/main.js | 13 +-
src/fauxton/app/modules/documents/views.js | 2 +-
src/fauxton/assets/index.underscore | 4 +-
src/fauxton/assets/js/libs/require.js | 1112 +++++++--------
.../assets/less/bootstrap/tests/buttons.html | 139 --
.../assets/less/bootstrap/tests/css-tests.css | 139 --
.../assets/less/bootstrap/tests/css-tests.html | 1296 ------------------
.../less/bootstrap/tests/forms-responsive.html | 71 -
.../assets/less/bootstrap/tests/forms.html | 179 ---
.../less/bootstrap/tests/navbar-fixed-top.html | 104 --
.../less/bootstrap/tests/navbar-static-top.html | 107 --
.../assets/less/bootstrap/tests/navbar.html | 107 --
src/fauxton/package.json | 16 +-
src/fauxton/settings.json.default | 23 +-
src/fauxton/tasks/couchserver.js | 73 +-
src/fauxton/tasks/fauxton.js | 2 +-
src/fauxton/tasks/helper.js | 6 +-
21 files changed, 707 insertions(+), 2775 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 7c9d4ec..886272d 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -78,22 +78,33 @@ module.exports = function(grunt) {
theAssets.img.push(imgPath + "/**");
}
});
- grunt.log.write(theAssets.img[0]);
return theAssets;
}();
var templateSettings = function(){
var defaultSettings = {
- "src": "assets/index.underscore",
- "dest": "dist/debug/index.html",
- "variables": {
- "assets_root": "./",
- "requirejs": "require.js",
- "base": null
+ "development": {
+ "src": "assets/index.underscore",
+ "dest": "dist/debug/index.html",
+ "variables": {
+ "requirejs": "/assets/js/libs/require.js",
+ "css": "./css/index.css",
+ "base": null
+ }
+ },
+ "release": {
+ "src": "assets/index.underscore",
+ "dest": "dist/debug/index.html",
+ "variables": {
+ "requirejs": "./js/require.js",
+ "css": "./css/index.css",
+ "base": null
+ }
}
};
+
var settings = helper.readSettingsFile();
- return {template: settings.template || defaultSettings};
+ return settings.template || defaultSettings;
}();
grunt.initConfig({
@@ -154,7 +165,7 @@ module.exports = function(grunt) {
// index.html.
concat: {
requirejs: {
- src: ["assets/js/libs/almond.js", "dist/debug/templates.js", "dist/debug/require.js"],
+ src: [ "assets/js/libs/require.js", "dist/debug/templates.js", "dist/debug/require.js"],
dest: "dist/debug/js/require.js"
},
@@ -206,8 +217,17 @@ module.exports = function(grunt) {
},
watch: {
- files: helper.watchFiles(["./app/**/*", "./assets/**/*"]),
- tasks: ['debug', 'template']
+ js: {
+ files: helper.watchFiles(['.js'], ["./app/**/*.js", '!./app/load_addons.js',"./assets/**/*.js"]),
+ tasks: ['watchRun'],
+ },
+ style: {
+ files: helper.watchFiles(['.less','.css'],["./app/**/*.css","./app/**/*.less","./assets/**/*.css", "./assets/**/*.less"]),
+ tasks: ['less', 'concat:index_css'],
+ },
+ options: {
+ nospawn: true,
+ }
},
requirejs: {
@@ -225,8 +245,8 @@ module.exports = function(grunt) {
// Do not wrap everything in an IIFE.
wrap: false,
- optimize: "none"
- }
+ optimize: "none",
+ }
}
},
@@ -294,6 +314,16 @@ module.exports = function(grunt) {
});
+ // on watch events configure jshint:all to only run on changed file
+ grunt.event.on('watch', function(action, filepath) {
+ if (!!filepath.match(/.js$/)) {
+ grunt.config(['jshint', 'all'], filepath);
+ }
+ /*} else if (!!filepath.match(/.css$|.less$/)) {
+ grunt.task.run(['less', 'concat:index_css']);
+ }*/
+ });
+
/*
* Load Grunt plugins
*/
@@ -302,11 +332,23 @@ module.exports = function(grunt) {
// Load the couchapp task
grunt.loadNpmTasks('grunt-couchapp');
// Load the copy task
- grunt.loadNpmTasks('grunt-contrib');
+ grunt.loadNpmTasks('grunt-contrib-watch');
// Load the exec task
grunt.loadNpmTasks('grunt-exec');
// Load Require.js task
- grunt.loadNpmTasks('grunt-requirejs');
+ grunt.loadNpmTasks('grunt-contrib-requirejs');
+ // Load Copy task
+ grunt.loadNpmTasks('grunt-contrib-copy');
+ // Load Clean task
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ // Load jshint task
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ // Load jst task
+ grunt.loadNpmTasks('grunt-contrib-jst');
+ // Load less task
+ grunt.loadNpmTasks('grunt-contrib-less');
+ // Load concat task
+ grunt.loadNpmTasks('grunt-contrib-concat');
// Load UglifyJS task
grunt.loadNpmTasks('grunt-contrib-uglify');
// Load CSSMin task
@@ -326,7 +368,7 @@ module.exports = function(grunt) {
// Fetch dependencies (from git or local dir), lint them and make load_addons
grunt.registerTask('dependencies', ['get_deps', 'jshint', 'gen_load_addons:default']);
// build templates, js and css
- grunt.registerTask('build', ['jst', 'requirejs', 'concat:requirejs', 'less', 'concat:index_css', 'template']);
+ grunt.registerTask('build', ['less', 'concat:index_css', 'jst', 'requirejs', 'concat:requirejs', 'template:release']);
// minify code and css, ready for release.
grunt.registerTask('minify', ['uglify', 'cssmin:compress']);
@@ -334,9 +376,12 @@ module.exports = function(grunt) {
* Build the app in either dev, debug, or release mode
*/
// dev server
- grunt.registerTask('dev', ['debug', 'couchserver']);
+ grunt.registerTask('dev', ['debugDev', 'couchserver']);
// build a debug release
- grunt.registerTask('debug', ['test', 'dependencies', 'build', 'copy:debug']);
+ grunt.registerTask('debug', ['test', 'dependencies', 'concat:requirejs','less', 'concat:index_css', 'template:development', 'copy:debug']);
+ grunt.registerTask('debugDev', ['test', 'dependencies', 'less', 'concat:index_css', 'template:development', 'copy:debug']);
+
+ grunt.registerTask('watchRun', ['dependencies']);
// build a release
grunt.registerTask('release', ['test' ,'dependencies', 'build', 'minify', 'copy:dist']);
@@ -348,7 +393,7 @@ module.exports = function(grunt) {
// make a minimized install that is server by mochiweb under _utils
grunt.registerTask('couchdb', ['release', 'copy:couchdb']);
// make an install that can be deployed as a couchapp
- grunt.registerTask('couchapp_setup', ['build', 'minify', 'copy:dist']);
+ grunt.registerTask('couchapp_setup', ['release']);
// install fauxton as couchapp
grunt.registerTask('couchapp_install', ['rmcouchdb:fauxton', 'mkcouchdb:fauxton', 'couchapp:fauxton']);
// setup and install fauxton as couchapp
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 4732528..0f3923e 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -78,7 +78,7 @@ function(app, Fauxton) {
}
return $.when(deferreds);
- },
+ };
FauxtonAPI.addRoute = function(route) {
app.router.route(route.route, route.name, route.callback);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index be0136d..df0894a 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -56,7 +56,6 @@ function($, _, Backbone, Helpers) {
} else {
// Put fetch into `async-mode`.
done = this.async();
-
// Seek out the template asynchronously.
return $.ajax({ url: app.root + path }).then(function(contents) {
done(JST[path] = _.template(contents));
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/app/config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/config.js b/src/fauxton/app/config.js
index c7ae1d6..d7d3b40 100644
--- a/src/fauxton/app/config.js
+++ b/src/fauxton/app/config.js
@@ -20,6 +20,8 @@ require.config({
"nv.d3": "../assets/js/libs/nv.d3"
},
+ baseUrl: '/',
+
shim: {
// Backbone library depends on lodash and jQuery.
backbone: {
@@ -51,5 +53,4 @@ require.config({
"plugins/jquery.form": ["jquery"]
}
-
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/app/main.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js
index 2f8f8fa..c06b0c4 100644
--- a/src/fauxton/app/main.js
+++ b/src/fauxton/app/main.js
@@ -23,16 +23,7 @@ function(app, Router) {
// Get the absolute root.
var root = location.protocol + "//" + location.host + app.root;
- // Ensure the root is part of the anchor href, meaning it's relative.
- if (href.prop && href.prop.slice(0, root.length) === root) {
- // Stop the default event to ensure the link will not cause a page
- // refresh.
- evt.preventDefault();
-
- // `Backbone.history.navigate` is sufficient for all Routers and will
- // trigger the correct events. The Router's internal `navigate` method
- // calls this anyways. The fragment is sliced from the root.
- Backbone.history.navigate(href.attr, true);
- }
+ evt.preventDefault();
+ Backbone.history.navigate(href.attr, true);
});
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index 59e3b7d..6c92cfa 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -764,7 +764,7 @@ function(app, FauxtonAPI, Documents, pouchdb, Codemirror, JSHint) {
var that = this,
promise,
- viewName = this.$('#index-name').val();
+ viewName = this.$('#index-name').val(),
ddocName = this.$('#ddoc :selected').val(),
ddoc = this.getCurrentDesignDoc();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/98a4a1b8/src/fauxton/assets/index.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/index.underscore b/src/fauxton/assets/index.underscore
index e29b4c4..7ccb930 100644
--- a/src/fauxton/assets/index.underscore
+++ b/src/fauxton/assets/index.underscore
@@ -24,7 +24,7 @@
<title>Project Fauxton</title>
<!-- Application styles. -->
- <link rel="stylesheet" href="<%= assets_root %>css/index.css">
+ <link rel="stylesheet" href="<%= css %>">
<style type="text/css">
body {
padding-top: 60px;
@@ -49,6 +49,6 @@
</div>
<!-- Application source. -->
- <script data-main="/app/config" src="<%= assets_root %>js/<%= requirejs %>"></script>
+ <script data-main="/config" src="<%= requirejs %>"></script>
</body>
</html>