couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [24/50] [abbrv] git commit: updated refs/heads/1684-feature-db-updates to ea07223
Date Mon, 22 Jul 2013 10:25:41 GMT
Add live CouchDB version info to Fauxton


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

Branch: refs/heads/1684-feature-db-updates
Commit: cbbd7d56b52a44937adb35678aa4a0b200334399
Parents: 85f3c8e
Author: Russell Branca <chewbranca@gmail.com>
Authored: Mon Jun 17 16:52:56 2013 -0700
Committer: Russell Branca <chewbranca@gmail.com>
Committed: Mon Jun 17 16:52:56 2013 -0700

----------------------------------------------------------------------
 src/fauxton/app/initialize.js           |  2 +-
 src/fauxton/app/modules/fauxton/base.js | 18 +++++++++++++++++-
 src/fauxton/app/router.js               |  5 ++++-
 src/fauxton/tasks/couchserver.js        | 20 ++++++++++++++------
 4 files changed, 36 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/cbbd7d56/src/fauxton/app/initialize.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/initialize.js b/src/fauxton/app/initialize.js
index e5dbc73..6fed729 100644
--- a/src/fauxton/app/initialize.js
+++ b/src/fauxton/app/initialize.js
@@ -37,7 +37,7 @@ function(app, _, Bootstrap) {
     // Thanks to: http://stackoverflow.com/a/2880929
     getParams: function(queryString) {
       if (typeof queryString !== "undefined") {
-        // I think this could be combined into one if 
+        // I think this could be combined into one if
         if (queryString.substring(0,1) === "?") {
           queryString = queryString.substring(1);
         } else if (queryString.indexOf('?') > -1) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/cbbd7d56/src/fauxton/app/modules/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
index 46bde66..b69f4ae 100644
--- a/src/fauxton/app/modules/fauxton/base.js
+++ b/src/fauxton/app/modules/fauxton/base.js
@@ -35,11 +35,27 @@ function(app, Backbone) {
     }
   });
 
+  Fauxton.VersionInfo = Backbone.Model.extend({
+    url: app.host
+  });
+
+  // TODO: this View should extend from FauxtonApi.View.
+  // Chicken and egg problem, api.js extends fauxton/base.js.
+  // Need to sort the loading order.
   Fauxton.Footer = Backbone.View.extend({
     template: "templates/fauxton/footer",
+
+    initialize: function() {
+      this.versionInfo = new Fauxton.VersionInfo();
+    },
+
+    establish: function() {
+      return [this.versionInfo.fetch()];
+    },
+
     serialize: function() {
       return {
-        version: app.version
+        version: this.versionInfo.get("version")
       };
     }
   });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/cbbd7d56/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index e90e6e7..de1b7e4 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -129,7 +129,10 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases,
Documents
       $("#app-container").html(this.masterLayout.el);
       this.masterLayout.render();
 
-      app.footer.render();
+      // TODO: move this to a proper Fauxton.View
+      $.when.apply(null, app.footer.establish()).done(function() {
+        app.footer.render();
+      });
     },
 
     triggerRouteEvent: function(event, args) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/cbbd7d56/src/fauxton/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
index 576893b..0d1dc7a 100644
--- a/src/fauxton/tasks/couchserver.js
+++ b/src/fauxton/tasks/couchserver.js
@@ -18,7 +18,7 @@ module.exports = function (grunt) {
     path = require("path"),
     httpProxy = require('http-proxy'),
     express = require("express"),
-    options = grunt.config('couchserver'), 
+    options = grunt.config('couchserver'),
     app = express();
 
     // Options
@@ -42,20 +42,28 @@ module.exports = function (grunt) {
       res.sendfile(path.join(dist_dir,req.url));
     });
 
+    // create proxy to couch for all couch requests
+    var proxy = new httpProxy.HttpProxy(proxy_settings);
+
     // serve main index file from here
+    // Also proxy out to the base CouchDB host for handle_welcome_req.
+    // We still need to reach the top level CouchDB host even through
+    // the proxy.
     app.get('/', function (req, res) {
-      res.sendfile(path.join(dist_dir, 'index.html'));
+      var accept = req.headers.accept.split(',');
+      if (accept[0] == 'application/json') {
+        proxy.proxyRequest(req, res);
+      } else {
+        res.sendfile(path.join(dist_dir, 'index.html'));
+      }
     });
 
-    // create proxy to couch for all couch requests
-    var proxy = new httpProxy.HttpProxy(proxy_settings);
-
     app.all('*', function (req, res) {
       proxy.proxyRequest(req, res);
     });
 
     // Fail this task if any errors have been logged
-    if (grunt.errors) { 
+    if (grunt.errors) {
       return false;
     }
 


Mime
View raw message