summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Branca <chewbranca@gmail.com>2013-06-17 16:52:56 -0700
committerRussell Branca <chewbranca@gmail.com>2013-06-17 16:52:56 -0700
commitcbbd7d56b52a44937adb35678aa4a0b200334399 (patch)
tree68a4c7aadf21df2a9063825bee4d0eb5e3274024
parent85f3c8ed5a62ea48dd27c7f078ced6d3aa2c4dca (diff)
downloadcouchdb-cbbd7d56b52a44937adb35678aa4a0b200334399.tar.gz
Add live CouchDB version info to Fauxton
-rw-r--r--src/fauxton/app/initialize.js2
-rw-r--r--src/fauxton/app/modules/fauxton/base.js18
-rw-r--r--src/fauxton/app/router.js5
-rw-r--r--src/fauxton/tasks/couchserver.js20
4 files changed, 36 insertions, 9 deletions
diff --git a/src/fauxton/app/initialize.js b/src/fauxton/app/initialize.js
index e5dbc739c..6fed7293c 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) {
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
index 46bde6679..b69f4ae1d 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")
};
}
});
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index e90e6e785..de1b7e486 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) {
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
index 576893b29..0d1dc7a34 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;
}