You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2013/12/16 21:03:39 UTC

[19/50] git commit: updated refs/heads/1744-single-config-file to 1c344a9

Adding the initialize task to be able to set app.root


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b153e6af
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b153e6af
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b153e6af

Branch: refs/heads/1744-single-config-file
Commit: b153e6af50421c61e08e4027f4ca842ed78d76c9
Parents: f5a5862
Author: suelockwood <de...@gmail.com>
Authored: Tue Nov 26 14:20:00 2013 -0500
Committer: suelockwood <de...@apache.org>
Committed: Wed Dec 4 14:55:46 2013 -0500

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js                 |  7 ++-
 src/fauxton/app/initialize.js            |  9 +++-
 src/fauxton/app/initialize.js.underscore | 70 +++++++++++++++++++++++++++
 src/fauxton/tasks/fauxton.js             | 13 +++++
 4 files changed, 96 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b153e6af/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 6a8a73a..5e6c56e 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -326,6 +326,11 @@ module.exports = function(grunt) {
         src: "settings.json"
       }
     },
+    gen_initialize: {
+      "default": {
+        src: "settings.json"
+      }
+    },
 
     mkcouchdb: couch_config,
     rmcouchdb: couch_config,
@@ -400,7 +405,7 @@ module.exports = function(grunt) {
   grunt.registerTask('lint', ['clean', 'jshint']);
   grunt.registerTask('test', ['lint', 'mochaSetup','jst', 'concat:test_config_js', 'mocha_phantomjs']);
   // Fetch dependencies (from git or local dir), lint them and make load_addons
-  grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default']);
+  grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default', "gen_initialize:default"]);
   // build templates, js and css
   grunt.registerTask('build', ['less', 'concat:index_css', 'jst', 'requirejs', 'concat:requirejs', 'template:release']);
   // minify code and css, ready for release.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b153e6af/src/fauxton/app/initialize.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/initialize.js b/src/fauxton/app/initialize.js
index c0cca44..e374352 100644
--- a/src/fauxton/app/initialize.js
+++ b/src/fauxton/app/initialize.js
@@ -10,6 +10,12 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+
+/*
+ * ::WARNING::
+ * THIS IS A GENERATED FILE. DO NOT EDIT.
+ */
+
 define([
   // Application.
   "app",
@@ -26,8 +32,7 @@ function(app, _, Bootstrap) {
   _.extend(app, {
     // The root path to run the application through.
     // TODO: pick this up wither at build time or from the browser
-    root: "/_utils/fauxton/",
-
+    root: "/dashboard.beta/dashboard.assets/",
 
     renderView: function(baseView, selector, view, options, callback) {
       baseView.setView(selector, new view(options)).render().then(callback);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b153e6af/src/fauxton/app/initialize.js.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/app/initialize.js.underscore b/src/fauxton/app/initialize.js.underscore
new file mode 100644
index 0000000..cc0ea58
--- /dev/null
+++ b/src/fauxton/app/initialize.js.underscore
@@ -0,0 +1,70 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+/*
+ * ::WARNING::
+ * THIS IS A GENERATED FILE. DO NOT EDIT.
+ */
+
+define([
+  // Application.
+  "app",
+
+  // Libraries
+  "lodash",
+  "bootstrap"
+],
+
+function(app, _, Bootstrap) {
+
+  // Provide a global location to place configuration settings and module
+  // creation.
+  _.extend(app, {
+    // The root path to run the application through.
+    // TODO: pick this up wither at build time or from the browser
+    root: <%= '"' +root+ '"' %>,
+
+    renderView: function(baseView, selector, view, options, callback) {
+      baseView.setView(selector, new view(options)).render().then(callback);
+    },
+
+    // Thanks to: http://stackoverflow.com/a/2880929
+    getParams: function(queryString) {
+      if (queryString) {
+        // I think this could be combined into one if
+        if (queryString.substring(0,1) === "?") {
+          queryString = queryString.substring(1);
+        } else if (queryString.indexOf('?') > -1) {
+          queryString = queryString.split('?')[1];
+        }
+      }
+      var hash = window.location.hash.split('?')[1];
+      queryString = queryString || hash || window.location.search.substring(1);
+      var match,
+      urlParams = {},
+      pl     = /\+/g,  // Regex for replacing addition symbol with a space
+      search = /([^&=]+)=?([^&]*)/g,
+      decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
+      query  = queryString;
+
+      if (queryString) {
+        while ((match = search.exec(query))) {
+          urlParams[decode(match[1])] = decode(match[2]);
+        }
+      }
+
+      return urlParams;
+    }
+  });
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b153e6af/src/fauxton/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/fauxton.js b/src/fauxton/tasks/fauxton.js
index 833a86d..e466c9f 100644
--- a/src/fauxton/tasks/fauxton.js
+++ b/src/fauxton/tasks/fauxton.js
@@ -89,6 +89,19 @@ module.exports = function(grunt) {
     grunt.file.write(dest, tmpl({deps: deps}));
   });
 
+  grunt.registerMultiTask('gen_initialize', 'Generate the initialize.js file', function() {
+    var path = require('path');
+    var data = this.data;
+    var _ = grunt.util._;
+    var settingsFile = path.existsSync(data.src) ? data.src : "settings.json.default";
+    var settings = grunt.file.readJSON(settingsFile);
+    var template = "app/initialize.js.underscore";
+    var dest = "app/initialize.js";
+    var root = settings.root;
+    var tmpl = _.template(grunt.file.read(template));
+    grunt.file.write(dest, tmpl({root: root}));
+  });
+
   grunt.registerMultiTask('mochaSetup','Generate a config.js and runner.html for tests', function(){
     var data = this.data,
         configInfo,