couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deathb...@apache.org
Subject [1/2] git commit: updated refs/heads/generate-root-from-settings to 753a748
Date Tue, 26 Nov 2013 20:40:45 GMT
Updated Branches:
  refs/heads/generate-root-from-settings [created] 753a74816


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/c1188d83
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c1188d83
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c1188d83

Branch: refs/heads/generate-root-from-settings
Commit: c1188d83adf890b0bd31c59d125bf082b21efb63
Parents: 4e57f8f
Author: suelockwood <deathbearbrown@gmail.com>
Authored: Tue Nov 26 14:20:00 2013 -0500
Committer: suelockwood <deathbearbrown@gmail.com>
Committed: Tue Nov 26 14:20:00 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/c1188d83/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 42e5e17..4af5a00 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -325,6 +325,11 @@ module.exports = function(grunt) {
         src: "settings.json"
       }
     },
+    gen_initialize: {
+      "default": {
+        src: "settings.json"
+      }
+    },
 
     mkcouchdb: couch_config,
     rmcouchdb: couch_config,
@@ -399,7 +404,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/c1188d83/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/c1188d83/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/c1188d83/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,


Mime
View raw message