You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ry...@apache.org on 2013/05/11 07:49:03 UTC

[50/51] [partial] Restructure to simpler jam/erica style.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/addons/stats/templates/pie_table.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/pie_table.html b/src/fauxton/app/addons/stats/templates/pie_table.html
deleted file mode 100644
index fba4717..0000000
--- a/src/fauxton/app/addons/stats/templates/pie_table.html
+++ /dev/null
@@ -1,56 +0,0 @@
-<!--
-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.
--->
-
-<div class="row-fluid">
-  <div class="span8">
-    <h2>  <%= datatype %> </h2>
-  </div>
-</div>
-
-<div class="row-fluid">
-  <div class="span8" style="margin-top:70px">
-    <table class="table table-condensed table-striped">
-      <thead>
-        <tr>
-          <th> Description </th>
-          <th> current </th>
-          <th>  sum </th>
-          <th>  mean </th>
-          <th>  stddev </th>
-          <th>  min </th>
-          <th>  max </th>
-        </tr>
-      </thead>
-      <% _.each (statistics, function (stat_line) {
-        if (stat_line.get("sum")){
-       %>
-      <tr>
-        <td><%= stat_line.get("description") %></td>
-        <td><%= stat_line.get("current") %></td>
-        <td><%= stat_line.get("sum") %></td>
-        <td><%= stat_line.get("mean") %></td>
-        <td><%= stat_line.get("stddev") %></td>
-        <td><%= stat_line.get("min") %></td>
-        <td><%= stat_line.get("max") %></td>
-      </tr>
-      <% }}) %>
-    </table>
-  </div>
-
-  <div class="span4" style="height:430px;min-width: 430px">
-    <center>
-      <svg id="<%= datatype %>_graph"></svg>
-    </center>
-  </div>
-</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/addons/stats/templates/stats.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/stats.html b/src/fauxton/app/addons/stats/templates/stats.html
deleted file mode 100644
index ae7ce14..0000000
--- a/src/fauxton/app/addons/stats/templates/stats.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!--
-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.
--->
-
-<div class="datatypes">
-</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/addons/stats/templates/statselect.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/statselect.html b/src/fauxton/app/addons/stats/templates/statselect.html
deleted file mode 100644
index ef1133c..0000000
--- a/src/fauxton/app/addons/stats/templates/statselect.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-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.
--->
-
-<% _.each(datatypes, function (datatype) { %>
-<li> 
-<a href="#stats" class="datatype-select" data-type-select="<%= datatype %>"> 
-  <%= datatype %>
-  <i class="icon-chevron-right" style="float:right"></i>
-</a>
-</li>
-<% }); %>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/addons/stats/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/views.js b/src/fauxton/app/addons/stats/views.js
deleted file mode 100644
index 21454f9..0000000
--- a/src/fauxton/app/addons/stats/views.js
+++ /dev/null
@@ -1,172 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-  'addons/stats/resources',
-  "d3",
-  "nv.d3"
-
-],
-
-function(app, FauxtonAPI,Stats) {
-  console.log(arguments);
-  Views = {};
-
-  datatypeEventer = {};
-  _.extend(datatypeEventer, Backbone.Events);
-
-  Views.Legend = FauxtonAPI.View.extend({
-    tagName: 'ul',
-    template: "addons/stats/templates/legend",
-
-    serialize: function () {
-      return {
-        legend_items: this.collection.toJSON()
-      };
-    }
-  });
-
-  Views.Pie = FauxtonAPI.View.extend({
-    className: "datatype-section",
-    template: 'addons/stats/templates/pie_table',
-
-    initialize: function(args){
-      this.datatype = args.datatype;
-    },
-
-    serialize: function() {
-      return {
-        statistics: this.collection.where({type: this.datatype}),
-        datatype: this.datatype
-      };
-    },
-
-    afterRender: function(){
-        var collection = this.collection,
-            chartelem = "#" + this.datatype + '_graph',
-            series = _.map(this.collection.where({type: this.datatype}),
-          function(d, counter){
-            // TODO: x should be a counter
-            var point = {
-              y: d.get("sum") || 0,
-              key: d.id
-            };
-            return point;
-          }
-        );
-
-        series = _.filter(series, function(d){return d.y > 0;});
-        series = _.sortBy(series, function(d){return -d.y;});
-        console.log('series');
-        console.log(series);
-
-        nv.addGraph(function() {
-            var width = 550,
-                height = 400;
-
-            var chart = nv.models.pieChart()
-                .x(function(d) { return d.key; })
-                .y(function(d) { return d.y; })
-                .showLabels(true)
-                .showLegend(false)
-                .values(function(d) { return d; })
-                .color(d3.scale.category10().range())
-                .width(width)
-                .height(height);
-
-              d3.select(chartelem)
-                  .datum([series])
-                .transition().duration(300)
-                  .attr('width', width)
-                  .attr('height', height)
-                  .call(chart);
-
-            return chart;
-        });
-
-      this.$el.addClass(this.datatype + '_section');
-    }
-  });
-
-  Views.StatSelect = FauxtonAPI.View.extend({
-    className: 'nav nav-tabs nav-stacked',
-    tagName: 'ul',
-
-    template: "addons/stats/templates/statselect",
-
-    initialize: function (options) {
-      this.rows = [];
-    },
-
-    events: {
-      'click .datatype-select': "datatype_selected"
-    },
-
-    serialize: function () {
-      return {
-        datatypes: _.uniq(this.collection.pluck("type"))
-      };
-    },
-
-    afterRender: function () {
-      this.$('.datatype-select').first().addClass('active');
-    },
-
-    datatype_selected: function (event) {
-      var $target = $(event.currentTarget);
-
-      event.preventDefault();
-      event.stopPropagation();
-      this.$('.datatype-select').removeClass('active');
-      $target.addClass('active');
-      datatypeEventer.trigger('datatype-select', $target.attr('data-type-select'));
-    }
-  });
-
-  Views.Statistics = FauxtonAPI.View.extend({
-    template: "addons/stats/templates/stats",
-
-    initialize: function (options) {
-      this.rows = [];
-      datatypeEventer.on('datatype-select', this.display_datatype, this);
-    },
-
-    serialize: function () {
-      return {
-        datatypes: _.uniq(this.collection.pluck("type"))
-      };
-    },
-
-    beforeRender: function () {
-      _.each(_.uniq(this.collection.pluck("type")), function(datatype) {
-        this.rows[datatype] = this.insertView(".datatypes", new Views.Pie({
-          collection: this.collection,
-          datatype: datatype
-        }));
-      }, this);
-    },
-
-    afterRender: function () {
-      this.$('.datatype-section').hide().first().toggle();
-    },
-
-    display_datatype: function (datatype) {
-      this.$('.datatype-section').hide();
-      this.$('.' + datatype + '_section').show();
-    }
-  });
-
-  return Views;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
deleted file mode 100644
index 52e8611..0000000
--- a/src/fauxton/app/api.js
+++ /dev/null
@@ -1,101 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  // Modules
-  "modules/fauxton/base"
-],
-
-function(app, Fauxton) {
-  var FauxtonAPI = app.module();
-
-  FauxtonAPI.moduleExtensions = {
-    Routes: {
-    }
-  };
-
-  FauxtonAPI.addonExtensions = {
-    initialize: function() {}
-  };
-
-  // List of JSHINT errors to ignore
-  // Gets around problem of anonymous functions not being a valid statement
-  FauxtonAPI.excludedViewErrors = [
-    "Missing name in function declaration."
-  ];
-
-  FauxtonAPI.isIgnorableError = function(msg) {
-    return _.contains(FauxtonAPI.excludedViewErrors, msg);
-  };
-
-  FauxtonAPI.View = Backbone.View.extend({
-    // This should return an array of promises, an empty array, or null
-    establish: function() {
-      return null;
-    }
-  });
-
-  FauxtonAPI.navigate = function(url) {
-    Backbone.history.navigate(url, true);
-  };
-
-  FauxtonAPI.addHeaderLink = function(link) {
-    app.masterLayout.navBar.addLink(link);
-  };
-
-  FauxtonAPI.Deferred = function() {
-    return $.Deferred();
-  };
-
-  FauxtonAPI.addRoute = function(route) {
-    app.router.route(route.route, route.name, route.callback);
-  };
-
-  FauxtonAPI.module = function(extra) {
-    return app.module(_.extend(FauxtonAPI.moduleExtensions, extra));
-  };
-
-  FauxtonAPI.addon = function(extra) {
-    return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra);
-  };
-
-  FauxtonAPI.addNotification = function(options) {
-    options = _.extend({
-      msg: "Notification Event Triggered!",
-      type: "info",
-      selector: "#global-notifications"
-    }, options);
-    var view = new Fauxton.Notification(options);
-
-    return view.renderNotification();
-  };
-
-  FauxtonAPI.UUID = Backbone.Model.extend({
-    initialize: function(options) {
-      options = _.extend({count: 1}, options);
-      this.count = options.count;
-    },
-
-    url: function() {
-      return app.host + "/_uuids?count=" + this.count;
-    },
-
-    next: function() {
-      return this.get("uuids").pop();
-    }
-  });
-
-  app.fauxtonAPI = FauxtonAPI;
-  return app.fauxtonAPI;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
deleted file mode 100644
index e754c5f..0000000
--- a/src/fauxton/app/app.js
+++ /dev/null
@@ -1,75 +0,0 @@
-define([
-  // Libraries.
-  "jquery",
-  "lodash",
-  "backbone",
-
-  "helpers",
-
-  // Plugins.
-  "plugins/backbone.layoutmanager"
-],
-
-function($, _, Backbone, Helpers) {
-
-  // Make sure we have a console.log
-  if (typeof console == "undefined") {
-    console = {
-      log: function(){}
-    };
-  }
-
-  // Provide a global location to place configuration settings and module
-  // creation.
-  var app = {
-    // The root path to run the application.
-    root: "/",
-    version: "0.0.1"
-  };
-
-  // Localize or create a new JavaScript Template object.
-  var JST = window.JST = window.JST || {};
-
-  // Configure LayoutManager with Backbone Boilerplate defaults.
-  Backbone.Layout.configure({
-    // Allow LayoutManager to augment Backbone.View.prototype.
-    manage: true,
-
-    prefix: "app/",
-
-    // Inject app/helper.js for shared functionality across all html templates
-    render: function(template, context) {
-      return template(_.extend(Helpers, context));
-    },
-
-    fetch: function(path) {
-      // Initialize done for use in async-mode
-      var done;
-
-      // Concatenate the file extension.
-      path = path + ".html";
-
-      // If cached, use the compiled template.
-      if (JST[path]) {
-        return JST[path];
-      } 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));
-        });
-      }
-    }
-  });
-
-  // Mix Backbone.Events, and modules into the app object.
-  return _.extend(app, {
-    // Create a custom object with a nested Views object.
-    module: function(additionalProps) {
-      return _.extend({ Views: {} }, additionalProps);
-    }
-  }, Backbone.Events);
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/config.js b/src/fauxton/app/config.js
deleted file mode 100644
index 5bf1f87..0000000
--- a/src/fauxton/app/config.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// Set the require.js configuration for your application.
-require.config({
-
-  // Initialize the application with the main application file.
-  deps: ["main"],
-
-  paths: {
-    // JavaScript folders.
-    libs: "../assets/js/libs",
-    plugins: "../assets/js/plugins",
-
-    // Libraries.
-    jquery: "../assets/js/libs/jquery",
-    lodash: "../assets/js/libs/lodash",
-    backbone: "../assets/js/libs/backbone",
-    bootstrap: "../assets/js/libs/bootstrap",
-    codemirror: "../assets/js/libs/codemirror",
-    jshint: "../assets/js/libs/jshint",
-    d3: "../assets/js/libs/d3",
-    "nv.d3": "../assets/js/libs/nv.d3"
-  },
-
-  shim: {
-    // Backbone library depends on lodash and jQuery.
-    backbone: {
-      deps: ["lodash", "jquery"],
-      exports: "Backbone"
-    },
-
-    bootstrap: {
-      deps: ["jquery"],
-      exports: "Bootstrap"
-    },
-
-    codemirror: {
-      deps: ["jquery"],
-      exports: "CodeMirror"
-    },
-
-    jshint: {
-      deps: ["jquery"],
-      exports: "JSHINT"
-    },
-
-    // Backbone.LayoutManager depends on Backbone.
-    "plugins/backbone.layoutmanager": ["backbone"],
-
-    "plugins/codemirror-javascript": ["codemirror"],
-
-    "plugins/prettify": []
-  }
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/helpers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
deleted file mode 100644
index 6b3a7cd..0000000
--- a/src/fauxton/app/helpers.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any 
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-
-define([
-],
-
-function() {
-
-  var Helpers = {};
-
-  Helpers.imageUrl = function(path) {
-    // TODO: add dynamic path for different deploy targets
-    return path;
-  };
-
-  return Helpers;
-});
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/initialize.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/initialize.js b/src/fauxton/app/initialize.js
deleted file mode 100644
index 5699678..0000000
--- a/src/fauxton/app/initialize.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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.
-
-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: "/_utils/fauxton/",
-
-    host: window.location.protocol + "//" + window.location.host,
-
-    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 (typeof queryString !== "undefined") {
-        if (queryString.substring(0,1) === "?")
-          queryString = queryString.substring(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/4615a788/src/fauxton/app/load_addons.js.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/app/load_addons.js.underscore b/src/fauxton/app/load_addons.js.underscore
deleted file mode 100644
index 9686ad7..0000000
--- a/src/fauxton/app/load_addons.js.underscore
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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([
-  <%= '"' + deps.join('","') + '"' %>
-],
-function() {
-  var LoadAddons = {
-    addons: arguments
-  };
-
-  return LoadAddons;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/main.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js
deleted file mode 100644
index d3f8ac2..0000000
--- a/src/fauxton/app/main.js
+++ /dev/null
@@ -1,38 +0,0 @@
-require([
-  // Application.
-  "app",
-
-  // Main Router.
-  "router"
-],
-
-function(app, Router) {
-
-  // Define your master router on the application namespace and trigger all
-  // navigation from this instance.
-  app.router = new Router();
-  // Trigger the initial route and enable HTML5 History API support, set the
-  // root folder to '/' by default.  Change in app.js.
-  Backbone.history.start({ pushState: false, root: app.root });
-  // All navigation that is relative should be passed through the navigate
-  // method, to be processed by the router. If the link has a `data-bypass`
-  // attribute, bypass the delegation completely.
-  $(document).on("click", "a:not([data-bypass])", function(evt) {
-    // Get the absolute anchor href.
-    var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
-    // 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);
-    }
-  });
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/databases/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/base.js b/src/fauxton/app/modules/databases/base.js
deleted file mode 100644
index a5b4542..0000000
--- a/src/fauxton/app/modules/databases/base.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/databases/routes",
-  // Views
-  "modules/databases/views"
-
-],
-
-function(app, FauxtonAPI, Databases, Views) {
-  Databases.Views = Views;
-
-  // Utility functions
-  Databases.databaseUrl = function(database) {
-    var name = _.isObject(database) ? database.id : database;
-
-    return ["/database/", name, "/_all_docs?limit=10"].join('');
-  };
-
-  return Databases;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js
deleted file mode 100644
index 6927fd5..0000000
--- a/src/fauxton/app/modules/databases/resources.js
+++ /dev/null
@@ -1,148 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/documents/resources"
-],
-
-function(app, FauxtonAPI, Documents) {
-  var Databases = FauxtonAPI.module();
-
-  Databases.Model = Backbone.Model.extend({
-    initialize: function(options) {
-      this.status = new Databases.Status({
-        database: this
-      });
-    },
-
-    buildAllDocs: function(params) {
-      this.allDocs = new Documents.AllDocs(null, {
-        database: this,
-        params: params
-      });
-
-      return this.allDocs;
-    },
-
-    isNew: function(){
-      // Databases are never new, to make Backbone do a PUT
-      return false;
-    },
-
-    url: function(context) {
-      if (context === "index") {
-        return "/database/" + this.id + "/_all_docs";
-      } else if (context === "changes") {
-        return "/database/" + this.id + "/_changes?descending=true&limit=100";
-      } else if (context === "app") {
-        return "/database/" + this.id;
-      } else {
-        return app.host + "/" + this.id;
-      }
-    },
-
-    buildChanges: function (params) {
-      this.changes = new Databases.Changes({
-        database: this,
-        params: params
-      });
-
-      return this.changes;
-    }
-  });
-
-  Databases.Changes = Backbone.Collection.extend({
-
-    initialize: function(options) {
-      this.database = options.database;
-      this.params = options.params;
-    },
-
-    url: function () {
-      var query = "";
-      if (this.params) {
-        query = "?" + $.param(this.params);
-      }
-
-      return app.host + '/' + this.database.id + '/_changes' + query;
-    },
-
-    parse: function (resp) {
-      this.last_seq = resp.last_seq;
-      return resp.results;
-    }
-  });
-
-  Databases.Status = Backbone.Model.extend({
-    url: function() {
-      return app.host + "/" + this.database.id;
-    },
-
-    initialize: function(options) {
-      this.database = options.database;
-    },
-
-    numDocs: function() {
-      return this.get("doc_count");
-    },
-
-    updateSeq: function(full) {
-      var updateSeq = this.get("update_seq");
-      if (full || (typeof(updateSeq) === 'number')) {
-        return updateSeq;
-      } else if (updateSeq) {
-        return updateSeq.split('-')[0];
-      } else {
-        return 0;
-      }
-    },
-
-    humanSize: function() {
-      // cribbed from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable
-      var i = -1;
-      var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
-      var fileSizeInBytes = this.get("disk_size");
-      do {
-          fileSizeInBytes = fileSizeInBytes / 1024;
-          i++;
-      } while (fileSizeInBytes > 1024);
-
-      return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
-    }
-  });
-
-  // TODO: shared databases - read from the user doc
-  Databases.List = Backbone.Collection.extend({
-    model: Databases.Model,
-
-    url: function() {
-      return app.host + "/_all_dbs";
-    },
-
-    parse: function(resp) {
-      // TODO: pagination!
-      return _.map(resp, function(database) {
-        return {
-          id: encodeURIComponent(database),
-          name: database
-        };
-      });
-    }
-  });
-
-  return Databases;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js
deleted file mode 100644
index 2ba59d7..0000000
--- a/src/fauxton/app/modules/databases/routes.js
+++ /dev/null
@@ -1,70 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/databases/resources"
-],
-
-function(app, FauxtonAPI, Databases) {
-  var allDbsCallback = function() {
-    var data = {
-      databases: new Databases.List()
-    };
-    var deferred = FauxtonAPI.Deferred();
-
-    return {
-      layout: "with_sidebar",
-
-      data: data,
-
-      crumbs: [
-        {"name": "Databases", "link": "/_all_dbs"}
-      ],
-
-      views: {
-        "#dashboard-content": new Databases.Views.List({
-          collection: data.databases
-        }),
-
-        "#sidebar-content": new Databases.Views.Sidebar({
-          collection: data.databases
-        })
-      },
-
-      apiUrl: data.databases.url(),
-
-      establish: function() {
-        data.databases.fetch().done(function(resp) {
-          $.when.apply(null, data.databases.map(function(database) {
-            return database.status.fetch();
-          })).done(function(resp) {
-            deferred.resolve();
-          });
-        });
-        return [deferred];
-      }
-    };
-  };
-
-  Databases.Routes = {
-    "": allDbsCallback,
-    "index.html": allDbsCallback,
-    "_all_dbs(:params)": allDbsCallback
-  };
-
-  return Databases;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/views.js b/src/fauxton/app/modules/databases/views.js
deleted file mode 100644
index 1a02979..0000000
--- a/src/fauxton/app/modules/databases/views.js
+++ /dev/null
@@ -1,186 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "modules/fauxton/base",
-  "api"
-],
-
-function(app, Fauxton, FauxtonAPI) {
-  var Views = {};
-
-  Views.Item = FauxtonAPI.View.extend({
-    template: "templates/databases/item",
-    tagName: "tr",
-
-    serialize: function() {
-      return {
-        database: this.model
-      };
-    }
-  });
-
-  Views.List = FauxtonAPI.View.extend({
-    dbLimit: 10,
-    perPage: 10,
-    template: "templates/databases/list",
-    events: {
-      "click button.all": "selectAll",
-      "submit form.database-search": "switchDatabase"
-    },
-
-    initialize: function(options) {
-      var params = app.getParams();
-      this.page = params.page ? parseInt(params.page, 10) : 1;
-    },
-
-    serialize: function() {
-      return {
-        databases: this.collection
-      };
-    },
-
-    switchDatabase: function(event) {
-      event.preventDefault();
-      var dbname = this.$el.find("input.search-query").val();
-
-      if (dbname) {
-        // TODO: switch to using a model, or Databases.databaseUrl()
-        // Neither of which are in scope right now
-        // var db = new Database.Model({id: dbname});
-        var url = ["/database/", dbname, "/_all_docs?limit=10"].join('');
-        FauxtonAPI.navigate(url);
-      }
-    },
-
-    paginated: function() {
-      var start = (this.page - 1) * this.perPage;
-      var end = this.page * this.perPage - 1;
-      return this.collection.slice(start, end);
-    },
-
-    beforeRender: function() {
-      _.each(this.paginated(), function(database) {
-        this.insertView("table.databases tbody", new Views.Item({
-          model: database
-        }));
-      }, this);
-
-      this.insertView("#database-pagination", new Fauxton.Pagination({
-        page: this.page,
-        perPage: this.perPage,
-        total: this.collection.length,
-        urlFun: function(page) {
-          return "#/_all_dbs?page=" + page;
-        }
-      }));
-    },
-
-    afterRender: function() {
-      var dbLimit = this.dbLimit;
-      var ajaxReq;
-
-      this.$el.find("input.search-query").typeahead({
-        source: function(query, process) {
-          var url = [
-            app.host,
-            "/_all_dbs?startkey=%22",
-            query,
-            "%22&endkey=%22",
-            query,
-            "\u9999%22&limit=",
-            dbLimit
-          ].join('');
-          if (ajaxReq) ajaxReq.abort();
-          ajaxReq = $.ajax({
-            url: url,
-            dataType: 'json',
-            success: function(data) {
-              process(data);
-            }
-          });
-        }
-      });
-    },
-
-    selectAll: function(evt){
-      $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
-    }
-  });
-
-  Views.Sidebar = FauxtonAPI.View.extend({
-    template: "templates/databases/sidebar",
-    events: {
-      "click a#new": "newDatabase",
-      "click a#owned": "showMine",
-      "click a#shared": "showShared"
-    },
-
-    newDatabase: function() {
-      var notification;
-      var db;
-      // TODO: use a modal here instead of the prompt
-      var name = prompt('Name of database', 'newdatabase');
-      if (name === null) {
-        return;
-      } else if (name.length === 0) {
-        notification = FauxtonAPI.addNotification({
-          msg: "Please enter a valid database name",
-          type: "error",
-          clear: true
-        });
-        return;
-      }
-      db = new this.collection.model({
-        id: encodeURIComponent(name),
-        name: name
-      });
-      notification = FauxtonAPI.addNotification({msg: "Creating database."});
-      db.save().done(function() {
-        notification = FauxtonAPI.addNotification({
-          msg: "Database created successfully",
-          type: "success",
-          clear: true
-        });
-        var route = "#/database/" +  name + "/_all_docs?limit=100";
-        app.router.navigate(route, { trigger: true });
-      }
-      ).error(function(xhr) {
-        var responseText = JSON.parse(xhr.responseText).reason;
-        notification = FauxtonAPI.addNotification({
-          msg: "Create database failed: " + responseText,
-          type: "error",
-          clear: true
-        });
-      }
-      );
-    },
-
-    showMine: function(){
-      $.contribute(
-        'Show unshared databases',
-        'app/addons/databases/views.js'
-      );
-    },
-
-    showShared: function(){
-      $.contribute(
-        'Show shared databases (e.g. continuous replications to/from the database)',
-        'app/addons/databases/views.js'
-      );
-    }
-  });
-
-  return Views;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/documents/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/base.js b/src/fauxton/app/modules/documents/base.js
deleted file mode 100644
index 96e4ada..0000000
--- a/src/fauxton/app/modules/documents/base.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/documents/routes"
-],
-
-function(app, FauxtonAPI, Documents) {
-  return Documents;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
deleted file mode 100644
index 3f07238..0000000
--- a/src/fauxton/app/modules/documents/resources.js
+++ /dev/null
@@ -1,261 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Views
-  "modules/documents/views"
-
-  // Plugins
-],
-
-function(app, FauxtonAPI, Views) {
-  var Documents = app.module();
-
-  Documents.Doc = Backbone.Model.extend({
-    idAttribute: "_id",
-
-    url: function(context) {
-      if (context === "app") {
-        return this.getDatabase().url("app") + "/" + this.safeID();
-      } else {
-        return app.host + "/" + this.getDatabase().id + "/" + this.id;
-      }
-    },
-
-    initialize: function() {
-      if (this.collection && this.collection.database) {
-        this.database = this.collection.database;
-      }
-    },
-
-    // HACK: the doc needs to know about the database, but it may be
-    // set directly or indirectly in all docs
-    getDatabase: function() {
-      return this.database ? this.database : this.collection.database;
-    },
-
-    docType: function() {
-      return this.id.match(/^_design/) ? "design doc" : "doc";
-    },
-
-    isEditable: function() {
-      return this.docType() != "reduction";
-    },
-
-    isDdoc: function() {
-      return this.docType() === "design doc";
-    },
-
-    hasViews: function() {
-      if (!this.isDdoc()) return false;
-      var doc = this.get('doc');
-      return doc && doc.views && _.keys(doc.views).length > 0;
-    },
-
-    getDdocView: function(view) {
-      if (!this.isDdoc() || !this.hasViews()) return false;
-
-      var doc = this.get('doc');
-      return doc.views[view];
-    },
-
-    viewHasReduce: function(viewName) {
-      var view = this.getDdocView(viewName);
-
-      return view && view.reduce;
-    },
-
-    // Need this to work around backbone router thinking _design/foo
-    // is a separate route. Alternatively, maybe these should be
-    // treated separately. For instance, we could default into the
-    // json editor for docs, or into a ddoc specific page.
-    safeID: function() {
-      return this.id.replace('/', '%2F');
-    },
-
-    destroy: function() {
-      var url = this.url() + "?rev=" + this.get('_rev');
-      return $.ajax({
-        url: url,
-        dataType: 'json',
-        type: 'DELETE'
-      });
-    },
-
-    parse: function(resp) {
-      if (resp.rev) {
-        resp._rev = resp.rev;
-        delete resp.rev;
-      }
-      if (resp.id) {
-        if (typeof(this.id) === "undefined") {
-          resp._id = resp.id;
-        }
-        delete resp.id;
-      }
-      if (resp.ok) {
-        delete resp.ok;
-      }
-
-      return resp;
-    },
-
-    prettyJSON: function() {
-      var data = this.get("doc") ? this.get("doc") : this;
-
-      return JSON.stringify(data, null, "  ");
-    }
-  });
-
-  Documents.ViewRow = Backbone.Model.extend({
-    docType: function() {
-      if (!this.id) return "reduction";
-
-      return this.id.match(/^_design/) ? "design doc" : "doc";
-    },
-
-    url: function(context) {
-      if (!this.isEditable()) return false;
-
-      return this.collection.database.url(context) + "/" + this.id;
-    },
-
-    isEditable: function() {
-      return this.docType() != "reduction";
-    },
-
-    prettyJSON: function() {
-      //var data = this.get("doc") ? this.get("doc") : this;
-      return JSON.stringify(this, null, "  ");
-    }
-  });
-
-  Documents.NewDoc = Documents.Doc.extend({
-    fetch: function() {
-      var uuid = new FauxtonAPI.UUID();
-      var deferred = this.deferred = $.Deferred();
-      var that = this;
-
-      uuid.fetch().done(function() {
-        that.set("_id", uuid.next());
-        deferred.resolve();
-      });
-
-      return deferred.promise();
-    }
-  });
-
-  Documents.AllDocs = Backbone.Collection.extend({
-    model: Documents.Doc,
-
-    initialize: function(_models, options) {
-      this.database = options.database;
-      this.params = options.params;
-    },
-
-    url: function() {
-      var query = "";
-      if (this.params) {
-        query = "?" + $.param(this.params);
-      }
-      return app.host + "/" + this.database.id + "/_all_docs" + query;
-    },
-
-    totalRows: function() {
-      return this.viewMeta.total_rows || "unknown";
-    },
-
-    updateSeq: function() {
-      return this.viewMeta.update_seq || false;
-    },
-
-    parse: function(resp) {
-      that = this;
-      this.viewMeta = {
-        total_rows: resp.total_rows,
-        offest: resp.offest,
-        update_seq: resp.update_seq
-      };
-      return _.map(resp.rows, function(row) {
-        return {
-          _id: row.id,
-          _rev: row.value.rev,
-          value: row.value,
-          key: row.key,
-          doc: row.doc || undefined
-        };
-      });
-    }
-  });
-
-  Documents.IndexCollection = Backbone.Collection.extend({
-    model: Documents.ViewRow,
-
-    initialize: function(_models, options) {
-      this.database = options.database;
-      this.view = options.view;
-      this.design = options.design;
-      this.params = _.extend({limit: 10, reduce: false}, options.params);
-      this.idxType = "_view";
-    },
-
-    url: function() {
-      var query = "";
-      if (this.params) {
-        query = "?" + $.param(this.params);
-      }
-      var url = [app.host, this.database.id, "_design", this.design, this.idxType, this.view];
-      return url.join("/") + query;
-    },
-
-    totalRows: function() {
-      return this.viewMeta.total_rows || "unknown";
-    },
-
-    updateSeq: function() {
-      return this.viewMeta.update_seq || false;
-    },
-
-    parse: function(resp) {
-      that = this;
-      this.viewMeta = {
-        total_rows: resp.total_rows,
-        offest: resp.offest,
-        update_seq: resp.update_seq
-      };
-      return _.map(resp.rows, function(row) {
-        return {
-          value: row.value,
-          key: row.key,
-          doc: row.doc,
-          id: row.id
-        };
-      });
-    },
-
-    buildAllDocs: function(){
-      this.fetch();
-    },
-
-    allDocs: function(){
-      return this.models;
-    }
-  });
-
-  Documents.Views = Views;
-
-  return Documents;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/app/modules/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
deleted file mode 100644
index 34b00d8..0000000
--- a/src/fauxton/app/modules/documents/routes.js
+++ /dev/null
@@ -1,426 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/documents/resources",
-  "modules/databases/base"
-],
-
-function(app, FauxtonAPI, Documents, Databases) {
-  // TODO: look at using:
-  // var Documents = require("modules/documents/models_collections");
-  // var Databases = require("modules/databases/module");
-
-  var codeEditorCallback = function(databaseName, docID) {
-    var data = {
-      database: new Databases.Model({id:databaseName}),
-      doc: new Documents.Doc({
-        "_id": docID
-      }),
-      selected: "code_editor"
-    };
-    data.doc.database = data.database;
-    data.designDocs = new Documents.AllDocs(null, {
-      database: data.database,
-      params: {startkey: '"_design"',
-        endkey: '"_design1"',
-        include_docs: true}
-    });
-
-    var options = app.getParams();
-    options.include_docs = true;
-    data.database.buildAllDocs(options);
-
-    return {
-      layout: "one_pane",
-
-      data: data,
-
-      crumbs: [
-        {"name": "Databases", "link": "/_all_dbs"},
-        {"name": data.database.id, "link": Databases.databaseUrl(data.database)},
-        {"name": docID, "link": "#"}
-      ],
-
-      views: {
-        "#dashboard-content": new Documents.Views.Doc({
-          model: data.doc
-        }),
-
-        "#tabs": new Documents.Views.FieldEditorTabs({
-          selected: data.selected,
-          model: data.doc
-        })
-      },
-
-      apiUrl: data.doc.url()
-    };
-  };
-
-  var newViewEditorCallback = function(databaseName) {
-    var data = {
-      database: new Databases.Model({id:databaseName})
-    };
-    data.designDocs = new Documents.AllDocs(null, {
-      database: data.database,
-      params: {startkey: '"_design"',
-               endkey: '"_design1"',
-               include_docs: true}
-    });
-
-    return {
-      layout: "with_tabs_sidebar",
-
-      data: data,
-
-      crumbs: [
-        {"name": "Databases", "link": "/_all_dbs"},
-        {"name": data.database.id, "link": data.database.url('app')}
-      ],
-
-      views: {
-        "#sidebar-content": new Documents.Views.Sidebar({
-          collection: data.designDocs
-        }),
-
-        "#tabs": new Documents.Views.Tabs({
-          collection: data.designDocs,
-          database: data.database
-        }),
-
-        "#dashboard-content": new Documents.Views.ViewEditor({
-          model: data.database,
-          ddocs: data.designDocs
-        })
-      },
-
-      apiUrl: data.database.url()
-    };
-  };
-
-  // HACK: this kind of works
-  // Basically need a way to share state between different routes, for
-  // instance making a new doc won't work for switching back and forth
-  // between code and field editors
-  var newDocCodeEditorCallback = function(databaseName) {
-    var data = {
-      database: new Databases.Model({id:databaseName}),
-      doc: new Documents.NewDoc(),
-      selected: "code_editor"
-    };
-    data.doc.database = data.database;
-    data.designDocs = new Documents.AllDocs(null, {
-      database: data.database,
-      params: {startkey: '"_design"',
-        endkey: '"_design1"',
-        include_docs: true}
-    });
-
-    var options = app.getParams();
-    options.include_docs = true;
-    data.database.buildAllDocs(options);
-
-    return {
-      layout: "one_pane",
-
-      data: data,
-
-      crumbs: [
-        {"name": "Databases", "link": "/_all_dbs"},
-        {"name": data.database.id, "link": Databases.databaseUrl(data.database)},
-        {"name": "new", "link": "#"}
-      ],
-
-      views: {
-        "#dashboard-content": new Documents.Views.Doc({
-          model: data.doc
-        }),
-
-        "#tabs": new Documents.Views.FieldEditorTabs({
-          selected: data.selected,
-          model: data.doc
-        })
-      },
-
-      apiUrl: data.doc.url()
-    };
-  };
-
-  Documents.Routes = {
-    "database/:database/:doc/field_editor": function(databaseName, docID) {
-      var data = {
-        database: new Databases.Model({id:databaseName}),
-        doc: new Documents.Doc({
-          "_id": docID
-        }),
-        selected: "field_editor"
-      };
-      data.doc.database = data.database;
-      data.designDocs = new Documents.AllDocs(null, {
-        database: data.database,
-        params: {startkey: '"_design"',
-          endkey: '"_design1"',
-          include_docs: true}
-      });
-
-      var options = app.getParams();
-      options.include_docs = true;
-      data.database.buildAllDocs(options);
-
-      return {
-        layout: "one_pane",
-
-        data: data,
-
-        crumbs: [
-          {"name": "Databases", "link": "/_all_dbs"},
-          {"name": data.database.id, "link": Databases.databaseUrl(data.database)},
-          {"name": docID, "link": "#"}
-        ],
-
-        views: {
-          "#dashboard-content": new Documents.Views.DocFieldEditor({
-            model: data.doc
-          }),
-
-          "#tabs": new Documents.Views.FieldEditorTabs({
-            selected: data.selected,
-            model: data.doc
-          })
-        },
-
-        apiUrl: data.doc.url()
-      };
-    },
-
-    "database/:database/:doc/code_editor": codeEditorCallback,
-    "database/:database/:doc": codeEditorCallback,
-    "database/:database/_design%2F:doc": function(database, doc) {
-      var docID = "_design/"+doc;
-      return codeEditorCallback(database, docID);
-    },
-
-    // HACK
-    // The ordering of routes is different in this object that the
-    // routes object in the Backbone.Router. As a result, the
-    // declaration order of show doc and _handler methods has been
-    // switched. This is a brittle solution that needs to be fixed.
-    // Conflicts with route: "database/:database/_:handler"
-    //
-    // TODO: add support for regex based rotues
-    // Javascript does not handle a regex as an object key very well,
-    // and it turns it into its string representation when you use in
-    // non object literal form, which does get recast back as a regex
-    // when we need it.
-    // The inability to use regex based routes here is a design flaw
-    // and should be rectified.
-    "old_database/:database/:doc": function(databaseName, docID) {
-      var data = {
-        database: new Databases.Model({id:databaseName}),
-        doc: new Documents.Doc({
-          "_id": docID
-        })
-      };
-      data.doc.database = data.database;
-      data.designDocs = new Documents.AllDocs(null, {
-        database: data.database,
-        params: {startkey: '"_design"',
-          endkey: '"_design1"',
-          include_docs: true}
-      });
-
-      var options = app.getParams();
-      options.include_docs = true;
-      data.database.buildAllDocs(options);
-
-      return {
-        layout: "with_sidebar",
-
-        data: data,
-
-        crumbs: [
-          {"name": "Databases", "link": "/_all_dbs"},
-          {"name": data.database.id, "link": Databases.databaseUrl(data.database)},
-          {"name": docID, "link": "#"}
-        ],
-
-        views: {
-          "#dashboard-content": new Documents.Views.Doc({
-            model: data.doc
-          }),
-
-          "#sidebar-content": new Documents.Views.Sidebar({
-            collection: data.designDocs
-          })
-        },
-
-        apiUrl: data.doc.url()
-      };
-    },
-
-    "database/:database/_all_docs(:extra)": function(databaseName, page) {
-      var data = {
-        database: new Databases.Model({id:databaseName})
-      };
-      data.designDocs = new Documents.AllDocs(null, {
-        database: data.database,
-        params: {startkey: '"_design"',
-          endkey: '"_design1"',
-          include_docs: true}
-      });
-
-      var options = app.getParams();
-      options.include_docs = true;
-      data.database.buildAllDocs(options);
-
-      return {
-        layout: "with_tabs_sidebar",
-
-        data: data,
-
-        crumbs: [
-          {"name": "Databases", "link": "/_all_dbs"},
-          {"name": data.database.id, "link": Databases.databaseUrl(data.database)}
-        ],
-
-        views: {
-          "#dashboard-content": new Documents.Views.AllDocsList({
-            collection: data.database.allDocs
-          }),
-
-          "#sidebar-content": new Documents.Views.Sidebar({
-            collection: data.designDocs
-          }),
-
-          "#tabs": new Documents.Views.Tabs({
-            collection: data.designDocs,
-            database: data.database
-          })
-        },
-
-        apiUrl: data.database.allDocs.url()
-      };
-    },
-
-    "database/:database/_changes(:params)": function(databaseName, params) {
-      var data = {
-        database: new Databases.Model({id:databaseName})
-      };
-
-      var options = app.getParams();
-      data.database.buildChanges(options);
-
-      return {
-        layout: "with_tabs",
-
-        data: data,
-
-        crumbs: [
-          {"name": "Databases", "link": "/_all_dbs"},
-          {"name": data.database.id, "link": Databases.databaseUrl(data.database)},
-          {"name": "_changes", "link": "/_changes"}
-        ],
-
-        views: {
-          "#dashboard-content": new Documents.Views.Changes({
-            model: data.database
-          }),
-
-          "#tabs": new Documents.Views.Tabs({
-            collection: data.designDocs,
-            database: data.database,
-            active_id: 'changes'
-          })
-        },
-
-        apiUrl: data.database.changes.url()
-      };
-    },
-
-    "database/:database/new": newDocCodeEditorCallback,
-    "database/:database/new_view": newViewEditorCallback,
-
-    // TODO: fix optional search params
-    // Can't get ":view(?*search)" to work
-    // However ":view?*search" does work
-    //"database/:database/_design/:ddoc/_view/:view(\?*options)": function(databaseName, ddoc, view, options) {
-    "database/:database/_design/:ddoc/_view/:view": function(databaseName, ddoc, view, options) {
-      // hack around backbone router limitations
-      view = view.replace(/\?.*$/,'');
-      var params = app.getParams();
-      var data = {
-        database: new Databases.Model({id:databaseName})
-      };
-
-      data.indexedDocs = new Documents.IndexCollection(null, {
-        database: data.database,
-        design: ddoc,
-        view: view,
-        params: params
-      });
-
-      data.designDocs = new Documents.AllDocs(null, {
-        database: data.database,
-        params: {startkey: '"_design"',
-          endkey: '"_design1"',
-          include_docs: true}
-      });
-
-      var ddocInfo = {
-        id: "_design/" + ddoc,
-        currView: view,
-        designDocs: data.designDocs
-      };
-
-      return {
-        layout: "with_tabs_sidebar",
-
-        data: data,
-        // TODO: change dashboard-content
-        views: {
-          "#dashboard-content": new Documents.Views.AllDocsList({
-            collection: data.indexedDocs,
-            nestedView: Documents.Views.Row,
-            viewList: true,
-            ddocInfo: ddocInfo,
-            params: params
-          }),
-
-          "#sidebar-content": new Documents.Views.Sidebar({
-            collection: data.designDocs,
-            ddocInfo: ddocInfo
-          }),
-
-          "#tabs": new Documents.Views.Tabs({
-            collection: data.designDocs,
-            database: data.database
-          })
-        },
-
-        crumbs: [
-          {"name": "Databases", "link": "/_all_dbs"},
-          {"name": data.database.id, "link": Databases.databaseUrl(data.database)},
-          {"name": ddoc + "/" + view, "link": data.indexedDocs.url()}
-        ],
-        // TODO: change to view URL
-        apiUrl: data.indexedDocs.url()
-      };
-    }
-  };
-
-  return Documents;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/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
deleted file mode 100644
index 558f0c1..0000000
--- a/src/fauxton/app/modules/documents/views.js
+++ /dev/null
@@ -1,950 +0,0 @@
-// 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.
-
-define([
-  "app",
-
-  "api",
-
-  // Libs
-  "codemirror",
-  "jshint",
-
-  // Plugins
-  "plugins/codemirror-javascript",
-  "plugins/prettify"
-],
-
-function(app, FauxtonAPI, Codemirror, JSHint) {
-  var Views = {};
-
-  Views.Tabs = FauxtonAPI.View.extend({
-    template: "templates/documents/tabs",
-    initialize: function(options){
-      this.collection = options.collection;
-      this.database = options.database;
-      this.active_id = options.active_id;
-    },
-
-    events: {
-      "click #delete-database": "delete_database"
-    },
-
-    serialize: function () {
-      return {
-        // TODO make this not hard coded here
-        changes_url: '#' + this.database.url('changes'),
-        db_url: '#' + this.database.url('index') + '?limit=100'
-      };
-    },
-
-    beforeRender: function(manage) {
-      this.insertView("#search", new Views.SearchBox({
-        collection: this.collection,
-        database: this.database.id
-      }));
-    },
-
-    afterRender: function () {
-      if (this.active_id) {
-        this.$('.active').removeClass('active');
-        this.$('#'+this.active_id).addClass('active');
-      }
-    },
-
-    delete_database: function (event) {
-      event.preventDefault();
-
-      var result = confirm("Are you sure you want to delete this database?");
-
-      if (!result) { return; }
-
-      return this.database.destroy().done(function () {
-        app.router.navigate('/', {trigger: true});
-      });
-    }
-  });
-
-  Views.SearchBox = FauxtonAPI.View.extend({
-    template: "templates/documents/search",
-    tagName: "form",
-    initialize: function(options){
-      this.collection = options.collection;
-      this.database = options.database;
-    },
-    afterRender: function(){
-      var collection = this.collection;
-      var form = this.$el;
-      var searchbox = form.find("input#searchbox");
-      var database = this.database;
-
-      form.submit(function(evt){
-        evt.preventDefault();
-        var viewname = form.find("input#view").val().split('/');
-        var url = "#database/" + database + "/_design/";
-        url += viewname[0] + "/_view/" + viewname[1];
-        if (searchbox.val() !== ""){
-          // TODO: this'll need to work when val() is a number etc.
-          url += '?startkey="' + searchbox.val() + '"';
-        }
-        FauxtonAPI.navigate(url);
-      });
-
-      searchbox.typeahead({
-        source: function(query, process) {
-          // TODO: include _all_docs and view keys somehow
-          var views = _.map(collection.pluck('doc'), function(d){
-            return _.map(_.keys(d.views), function(view){
-              return d._id.split('/')[1] + "/" + view;
-            });
-          });
-          return _.flatten(views);
-        },
-        minLength: 3,
-        updater: function(item){
-          // TODO: some way to return the original search box
-          this.$element.removeClass('span12');
-          this.$element.addClass('span6');
-          this.$element.attr('placeholder', 'Search by view key');
-          $('<span class="add-on span6">' + item +'</span>').insertBefore(this.$element);
-          $('<input type="hidden" id="view" value="' + item +'"/>').insertBefore(this.$element);
-          // Remove the type ahead for now
-          $('.typehead').unbind();
-        }
-      });
-    }
-  });
-
-  Views.FieldEditorTabs = FauxtonAPI.View.extend({
-    template: "templates/documents/doc_field_editor_tabs",
-
-    initialize: function(options) {
-      this.selected = options.selected;
-    },
-
-    events: {
-      "click button.delete": "destroy",
-      "click button.duplicate": "duplicate"
-    },
-
-    destroy: function(event) {
-      if (!window.confirm("Are you sure you want to delete this doc?")) {
-        return false;
-      }
-
-      var database = this.model.database;
-
-      this.model.destroy().then(function(resp) {
-        FauxtonAPI.addNotification({
-          msg: "Succesfully destroyed your doc"
-        });
-        FauxtonAPI.navigate(database.url("index"));
-      }, function(resp) {
-        FauxtonAPI.addNotification({
-          msg: "Failed to destroy your doc!",
-          type: "error"
-        });
-      });
-    },
-
-    duplicate: function(event) {
-      FauxtonAPI.addNotification({
-        type: "warning",
-        msg: "Duplicate functionality coming soon."
-      });
-    },
-
-    serialize: function() {
-      var selected = this.selected;
-      return {
-        doc: this.model,
-        isSelectedClass: function(item) {
-          return item && item === selected ? "active" : "";
-        }
-      };
-    },
-
-    establish: function() {
-      return [this.model.fetch()];
-    }
-  });
-
-  Views.Document = FauxtonAPI.View.extend({
-    template: "templates/documents/all_docs_item",
-    tagName: "tr",
-    className: "all-docs-item",
-
-    events: {
-      "click button.delete": "destroy"
-    },
-
-    attributes: function() {
-      return {
-        "data-id": this.model.id
-      };
-    },
-
-    serialize: function() {
-      return {
-        doc: this.model
-      };
-    },
-
-    establish: function() {
-      return [this.model.fetch()];
-    },
-
-    destroy: function(event) {
-      event.preventDefault();
-      var that = this;
-
-      if (!window.confirm("Are you sure you want to delete this doc?")) {
-        return false;
-      }
-
-      this.model.destroy().then(function(resp) {
-        FauxtonAPI.addNotification({
-          msg: "Succesfully destroyed your doc"
-        });
-        that.$el.fadeOut();
-        that.model.collection.remove(that.id);
-      }, function(resp) {
-        FauxtonAPI.addNotification({
-          msg: "Failed to destroy your doc!",
-          type: "error"
-        });
-      });
-    }
-  });
-
-  Views.Row = FauxtonAPI.View.extend({
-    template: "templates/documents/index_row_docular",
-    tagName: "tr",
-
-    serialize: function() {
-      return {
-        doc: this.model
-      };
-    }
-  });
-
-  Views.IndexItem = FauxtonAPI.View.extend({
-    template: "templates/documents/index_menu_item",
-    tagName: "li",
-
-    initialize: function(options){
-      this.index = options.index;
-      this.ddoc = options.ddoc;
-      this.database = options.database;
-      this.selected = !! options.selected;
-    },
-
-    serialize: function() {
-      return {
-        index: this.index,
-        ddoc: this.ddoc,
-        database: this.database,
-        selected: this.selected
-      };
-    },
-
-    afterRender: function() {
-      if (this.selected) {
-        $("#sidenav ul.nav-list li").removeClass("active");
-        this.$el.addClass("active");
-      }
-    }
-  });
-
-  // TODO: Rename to reflect that this is a list of rows or documents
-  Views.AllDocsList = FauxtonAPI.View.extend({
-    template: "templates/documents/all_docs_list",
-    events: {
-      "click button.all": "selectAll",
-      "click button.bulk-delete": "bulkDelete",
-      "change form.view-query-update input": "updateFilters",
-      "change form.view-query-update select": "updateFilters",
-      "submit form.view-query-update": "updateView"
-    },
-
-    initialize: function(options){
-      this.nestedView = options.nestedView || Views.Document;
-      this.rows = {};
-      this.viewList = !! options.viewList;
-      this.params = options.params;
-      if (options.ddocInfo) {
-        this.designDocs = options.ddocInfo.designDocs;
-        this.ddocID = options.ddocInfo.id;
-      }
-    },
-
-    establish: function() {
-      var deferreds = [
-        this.collection.fetch().error(function() {
-          // TODO: handle error requests that slip through
-          // This should just throw a notification, not break the page
-          console.log("ERROR: ", arguments);
-        })
-      ];
-      if (this.designDocs) {
-        deferreds.push(this.designDocs.fetch());
-      }
-      return deferreds;
-    },
-
-    selectAll: function(evt){
-      $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
-    },
-
-    // TODO:: HACK::
-    // Hack to grab info about the ddoc and current view to determine whether
-    // or not the view has a reduce function so we can display the advanced
-    // options appropriately.
-    //
-    // NOTE: we have this here temporarily because we have to wait for the
-    // design docs to be present.
-    //
-    // NOTE: We should probably refactor this View out into a separate View
-    // dedicated to displaying view query results.
-    // If nothing else, we should at least switch to something along the lines
-    // of fetchOnce to ensure we're not reloading the ddocs here in addition to
-    // the sidebar.
-    setDdocInfo: function() {
-      if (!this.ddoc && this.designDocs) {
-        this.ddoc = this.designDocs.get(this.ddocID);
-      }
-    },
-
-    serialize: function() {
-      this.setDdocInfo();
-      var data = {
-        database: this.collection,
-        viewList: this.viewList,
-        hasReduce: false,
-        params: this.params,
-        ddocs: this.designDocs
-      };
-      if (this.ddoc) {
-        data.ddoc = this.ddoc;
-        data.hasReduce = this.ddoc.viewHasReduce(this.collection.view);
-      }
-      return data;
-    },
-
-    updateView: function(event) {
-      event.preventDefault();
-      var $form = $(event.currentTarget);
-
-      // Ignore params without a value
-      var params = _.filter($form.serializeArray(), function(param) {
-        return param.value;
-      });
-
-      // Validate *key* params to ensure they're valid JSON
-      var keyParams = ["key","keys","startkey","endkey"];
-      var errorParams = _.filter(params, function(param) {
-        if (_.contains(keyParams, param.name)) {
-          try {
-            JSON.parse(param.value);
-            return false;
-          } catch(e) {
-            return true;
-          }
-        } else {
-          return false;
-        }
-      });
-
-      if (_.any(errorParams)) {
-        _.map(errorParams, function(param) {
-
-          // TODO: Where to add this error?
-          // bootstrap wants the error on a control-group div, but we're not using that
-          //$('form.view-query-update input[name='+param+'], form.view-query-update select[name='+param+']').addClass('error');
-
-          return FauxtonAPI.addNotification({
-            msg: "JSON Parse Error on field: "+param.name,
-            type: "error",
-            selector: ".view.show .all-docs-list.errors-container"
-          });
-        });
-
-        FauxtonAPI.addNotification({
-          msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
-          type: "warning",
-          selector: ".view.show .all-docs-list.errors-container"
-        });
-
-        return false;
-      }
-
-      var fragment = window.location.hash.replace(/\?.*$/, '');
-      fragment = fragment + '?' + $.param(params);
-      FauxtonAPI.navigate(fragment);
-    },
-
-    updateFilters: function(event) {
-      event.preventDefault();
-      var $ele = $(event.currentTarget);
-      var name = $ele.attr('name');
-      this.updateFiltersFor(name, $ele);
-    },
-
-    updateFiltersFor: function(name, $ele) {
-      var $form = $ele.parents("form.view-query-update:first");
-      switch (name) {
-        // Reduce constraints
-        //   - Can't include_docs for reduce=true
-        //   - can't include group_level for reduce=false
-        case "reduce":
-          if ($ele.prop('checked') === true) {
-            if ($form.find("input[name=include_docs]").prop("checked") === true) {
-              $form.find("input[name=include_docs]").prop("checked", false);
-              var notification = FauxtonAPI.addNotification({
-                msg: "include_docs has been disabled as you cannot include docs on a reduced view",
-                type: "warn",
-                selector: ".view.show .all-docs-list.errors-container"
-              });
-            }
-            $form.find("input[name=include_docs]").prop("disabled", true);
-            $form.find("select[name=group_level]").prop("disabled", false);
-          } else {
-            $form.find("select[name=group_level]").prop("disabled", true);
-            $form.find("input[name=include_docs]").prop("disabled", false);
-          }
-          break;
-        case "include_docs":
-          break;
-      }
-    },
-
-    /*
-     * TODO: this should be reconsidered
-     * This currently performs delete operations on the model level,
-     * when we could be using bulk docs with _deleted = true. Using
-     * individual models is cleaner from a backbone standpoint, but
-     * not from the couchdb api.
-     * Also, the delete method is naive and leaves the body intact,
-     * when we should switch the doc to only having id/rev/deleted.
-     */
-    bulkDelete: function() {
-      var that = this;
-      // yuck, data binding ftw?
-      var eles = this.$el.find("input.row-select:checked").parents("tr.all-docs-item").map(function(e) { return $(this).attr("data-id"); }).get();
-
-      if (!window.confirm("Are you sure you want to delete these " + eles.length + " docs?")) {
-        return false;
-      }
-
-      _.each(eles, function(ele) {
-        var model = this.collection.get(ele);
-
-        model.destroy().then(function(resp) {
-          that.rows[ele].$el.fadeOut();
-
-          model.collection.remove(model.id);
-        }, function(resp) {
-          FauxtonAPI.addNotification({
-            msg: "Failed to destroy your doc!",
-            type: "error"
-          });
-        });
-      }, this);
-    },
-
-    beforeRender: function() {
-      this.setDdocInfo();
-      if (this.viewList) {
-        this.viewEditorView = this.insertView("#edit-index-container", new Views.ViewEditor({
-          model: this.ddoc,
-          ddocs: this.designDocs,
-          viewCollection: this.collection
-        }));
-      }
-      this.collection.each(function(doc) {
-        this.rows[doc.id] = this.insertView("table.all-docs tbody", new this.nestedView({
-          model: doc
-        }));
-      }, this);
-    },
-
-    afterRender: function(){
-      prettyPrint();
-      if (this.params) {
-        var $form = this.$el.find("form.view-query-update");
-        _.each(this.params, function(val, key) {
-          var $ele;
-          switch (key) {
-            case "limit":
-            case "group_level":
-              $form.find("select[name='"+key+"']").val(val);
-              break;
-            case "include_docs":
-            case "stale":
-            case "descending":
-            case "inclusive_end":
-              $form.find("input[name='"+key+"']").prop('checked', true);
-              break;
-            case "reduce":
-              $ele = $form.find("input[name='"+key+"']");
-              if (val == "true") {
-                $ele.prop('checked', true);
-              }
-              this.updateFiltersFor(key, $ele);
-              break;
-            default:
-              $form.find("input[name='"+key+"']").val(val);
-              break;
-          }
-        }, this);
-      }
-    }
-  });
-
-  Views.Doc = FauxtonAPI.View.extend({
-    template: "templates/documents/doc",
-
-    events: {
-      "click button.save-doc": "saveDoc"
-    },
-
-    updateValues: function() {
-      var notification;
-      if (this.model.changedAttributes()) {
-        notification = FauxtonAPI.addNotification({
-          msg: "Document saved successfully.",
-          type: "success",
-          clear: true
-        });
-        this.editor.setValue(this.model.prettyJSON());
-      }
-    },
-
-    establish: function() {
-      return [this.model.fetch()];
-    },
-
-    saveDoc: function(event) {
-      var json, notification;
-      if (this.hasValidCode()) {
-        json = JSON.parse(this.editor.getValue());
-        this.model.clear({silent:true});
-        this.model.set(json);
-        notification = FauxtonAPI.addNotification({msg: "Saving document."});
-        this.model.save().error(function(xhr) {
-          var responseText = JSON.parse(xhr.responseText).reason;
-          notification = FauxtonAPI.addNotification({
-            msg: "Save failed: " + responseText,
-            type: "error",
-            clear: true
-          });
-        });
-      } else {
-        notification = FauxtonAPI.addNotification({
-          msg: "Please fix the JSON errors and try again.",
-          type: "error",
-          selector: "#doc .errors-container"
-        });
-      }
-    },
-
-    hasValidCode: function() {
-      return JSHINT(this.editor.getValue()) !== false;
-    },
-
-    runJSHint: function() {
-      var json = this.editor.getValue();
-      var output = JSHint(json);
-
-      // Clear existing markers
-      for (var i = 0, l = this.editor.lineCount(); i < l; i++) {
-        this.editor.clearMarker(i);
-      }
-
-      if (output === false) {
-        _.map(JSHint.errors, function(error) {
-          var line = error.line - 1;
-          var className = "view-code-error-line-" + line;
-          this.editor.setMarker(line, "●", "view-code-error "+className);
-
-          setTimeout(function() {
-            $(".CodeMirror ."+className).tooltip({
-              title: "ERROR: " + error.reason
-            });
-          }, 0);
-        }, this);
-      }
-    },
-
-    serialize: function() {
-      return {
-        doc: this.model
-      };
-    },
-
-    afterRender: function() {
-      this.model.on("sync", this.updateValues, this);
-      var that = this;
-      this.editor = Codemirror.fromTextArea(this.$el.find("textarea.doc-code").get()[0], {
-        mode: "application/json",
-        json: false,
-        lineNumbers: true,
-        matchBrackets: true,
-        lineWrapping: true,
-        onChange: function() {
-          that.runJSHint();
-        },
-        extraKeys: {
-          "Ctrl-S": function(instance) { that.saveDoc(); },
-          "Ctrl-/": "undo"
-        }
-      });
-    }
-  });
-
-  Views.DocFieldEditor = FauxtonAPI.View.extend({
-    template: "templates/documents/doc_field_editor",
-
-    events: {
-      "click button.save": "saveDoc"
-    },
-
-    saveDoc: function(event) {
-      FauxtonAPI.addNotification({
-        type: "warning",
-        msg: "Save functionality coming soon."
-      });
-    },
-
-    serialize: function() {
-      return {
-        doc: this.getModel()
-      };
-    },
-
-    getModel: function() {
-      return this.model;
-    },
-
-    establish: function() {
-      return [this.model.fetch()];
-    }
-  });
-
-  Views.ViewEditor = FauxtonAPI.View.extend({
-    template: "templates/documents/view_editor",
-    builtinReduces: ['_sum', '_count', '_stats'],
-
-    events: {
-      "click button.save": "saveView",
-      "click button.preview": "previewView",
-      "change select#reduce-function-selector": "updateReduce"
-    },
-
-    langTemplates: {
-      "javascript": {
-        map: "function(doc) {\n  emit(null, doc);\n}",
-        reduce: "function(keys, values, rereduce){\n  if (rereduce){\n    return sum(values);\n  } else {\n    return values.length;\n  }\n}"
-      }
-    },
-
-    defaultLang: "javascript",
-
-    initialize: function(options) {
-      this.ddocs = options.ddocs;
-      this.viewCollection = options.viewCollection;
-      this.reduceFunStr = this.model.viewHasReduce(this.viewCollection.view);
-      this.newView = false;
-    },
-
-    updateValues: function() {
-      var notification;
-      if (this.model.changedAttributes()) {
-        notification = FauxtonAPI.addNotification({
-          msg: "Document saved successfully.",
-          type: "success",
-          clear: true
-        });
-        this.editor.setValue(this.model.prettyJSON());
-      }
-    },
-
-    updateReduce: function(event) {
-      var $ele = $("#reduce-function-selector");
-      var $reduceContainer = $(".control-group.reduce-function");
-      if ($ele.val() == "CUSTOM") {
-        $reduceContainer.show();
-      } else {
-        $reduceContainer.hide();
-      }
-    },
-
-    establish: function() {
-      //return [this.ddocs.fetch(), this.model.fetch()];
-      return [];
-    },
-
-    previewView: function(event) {
-      FauxtonAPI.addNotification({
-        msg: "<strong>Warning!</strong> Preview executes the Map/Reduce functions in your browser, and may behave differently from CouchDB.",
-        type: "warning",
-        selector: "#define-view .errors-container",
-        fade: false
-      });
-      FauxtonAPI.addNotification({
-        msg: "Preview Functionality Coming Soon",
-        type: "warning",
-        selector: "#define-view .errors-container"
-      });
-    },
-
-    saveView: function(event) {
-      var json, notification;
-      if (this.hasValidCode()) {
-        var mapVal = this.mapEditor.getValue();
-        var reduceVal = this.reduceEditor.getValue();
-        /*
-        notification = FauxtonAPI.addNotification({
-          msg: "Saving document.",
-          selector: "#define-view .errors-container"
-        });
-        */
-        FauxtonAPI.addNotification({
-          msg: "Save Functionality Coming Soon",
-          type: "warning",
-          selector: "#define-view .errors-container"
-        });
-        /*
-        this.model.save().error(function(xhr) {
-          var responseText = JSON.parse(xhr.responseText).reason;
-          notification = FauxtonAPI.addNotification({
-            msg: "Save failed: " + responseText,
-            type: "error",
-            clear: true
-          });
-        });
-        */
-      } else {
-        notification = FauxtonAPI.addNotification({
-          msg: "Please fix the JSON errors and try again.",
-          type: "error",
-          selector: "#define-view .errors-container"
-        });
-      }
-    },
-
-    isCustomReduceEnabled: function() {
-      return $("#reduce-function-selector").val() == "CUSTOM";
-    },
-
-    reduceVal: function() {
-    },
-
-    hasValidCode: function() {
-      return _.every(["mapEditor", "reduceEditor"], function(editorName) {
-        var editor = this[editorName];
-        if (editorName == "reduceEditor" && ! this.isCustomReduceEnabled()) {
-          return true;
-        } else if (JSHINT(editor.getValue()) !== false) {
-          return true;
-        } else {
-          // By default CouchDB view functions don't pass lint
-          return _.every(JSHINT.errors, function(error) {
-            return FauxtonAPI.isIgnorableError(error.reason);
-          });
-        }
-      }, this);
-    },
-
-    runJSHint: function(editorName) {
-      var editor = this[editorName];
-      var json = editor.getValue();
-      var output = JSHint(json);
-
-      // Clear existing markers
-      for (var i = 0, l = editor.lineCount(); i < l; i++) {
-        editor.clearMarker(i);
-      }
-
-      if (output === false) {
-        _.map(JSHint.errors, function(error) {
-          // By default CouchDB view functions don't pass lint
-          if (FauxtonAPI.isIgnorableError(error.reason)) return true;
-
-          var line = error.line - 1;
-          var className = "view-code-error-line-" + line;
-          editor.setMarker(line, "●", "view-code-error "+className);
-
-          setTimeout(function() {
-            $(".CodeMirror ."+className).tooltip({
-              title: "ERROR: " + error.reason
-            });
-          }, 0);
-        }, this);
-      }
-    },
-
-    serialize: function() {
-      return {
-        //database: this.model,
-        ddocs: this.ddocs,
-        ddoc: this.model,
-        viewCollection: this.viewCollection,
-        reduceFunStr: this.reduceFunStr,
-        isCustomReduce: this.hasCustomReduce(),
-        newView: this.newView
-      };
-    },
-
-    hasCustomReduce: function() {
-      return this.reduceFunStr && ! _.contains(this.builtinReduces, this.reduceFunStr);
-    },
-
-    afterRender: function() {
-      var that = this;
-      var mapFun = $("#map-function");
-      var reduceFun = $("#reduce-function");
-      if (this.newView) {
-        mapFun.val(this.langTemplates[this.defaultLang].map);
-        reduceFun.val(this.langTemplates[this.defaultLang].reduce);
-      }
-      this.mapEditor = Codemirror.fromTextArea(mapFun.get()[0], {
-        mode: "javascript",
-        lineNumbers: true,
-        matchBrackets: true,
-        lineWrapping: true,
-        onChange: function() {
-          that.runJSHint("mapEditor");
-        },
-        extraKeys: {
-          "Ctrl-S": function(instance) { that.saveView(); },
-          "Ctrl-/": "undo"
-        }
-      });
-      this.reduceEditor = Codemirror.fromTextArea(reduceFun.get()[0], {
-        mode: "javascript",
-        lineNumbers: true,
-        matchBrackets: true,
-        lineWrapping: true,
-        onChange: function() {
-          that.runJSHint("reduceEditor");
-        },
-        extraKeys: {
-          "Ctrl-S": function(instance) { that.saveView(); },
-          "Ctrl-/": "undo"
-        }
-      });
-      // HACK: this should be in the html
-      // but CodeMirror's head explodes and it won't set the hight properly.
-      // So render it first, set the editor, then hide.
-      if ( ! this.hasCustomReduce()) {
-        $(".control-group.reduce-function").hide();
-      }
-    }
-  });
-
-  Views.Sidebar = FauxtonAPI.View.extend({
-    template: "templates/documents/sidebar",
-    events: {
-      "click a.new#index": "newIndex"
-    },
-
-    initialize: function(options) {
-      if (options.ddocInfo) {
-        this.ddocID = options.ddocInfo.id;
-        this.currView = options.ddocInfo.currView;
-      }
-    },
-
-    establish: function() {
-      if (this.collection) {
-        return [this.collection.fetch()];
-      } else {
-        return null;
-      }
-    },
-
-    serialize: function() {
-      return {
-        index: [1,2,3],
-        view: [1,2],
-        database: this.collection.database
-      };
-    },
-
-    newIndex:  function(event){
-      event.preventDefault();
-      $.contribute(
-        'Create a new view.',
-        'app/addons/documents/views.js'
-      );
-    },
-
-    toggleView: function(event){
-      event.preventDefault();
-      $.contribute(
-        'Filter data by type or view',
-        'app/addons/databases/views.js'
-      );
-      url = event.currentTarget.href.split('#')[1];
-      app.router.navigate(url);
-    },
-
-    buildIndexList: function(collection, selector, design){
-
-      _.each(_.keys(collection), function(key){
-        var selected = this.ddocID == "_design/"+design;
-        this.insertView("ul.nav." + selector, new Views.IndexItem({
-          ddoc: design,
-          index: key,
-          database: this.collection.database.id,
-          selected: selected && key == this.currView
-        }));
-      }, this);
-    },
-
-    beforeRender: function(manage) {
-      this.collection.each(function(design) {
-        if (design.has('doc')){
-          var ddoc = design.id.split('/')[1];
-          if (design.get('doc').views){
-            this.buildIndexList(design.get('doc').views, "views", ddoc);
-          }
-        }
-      }, this);
-    }
-
-  });
-
-  Views.Indexed = FauxtonAPI.View.extend({});
-
-  Views.Changes = FauxtonAPI.View.extend({
-    template: "templates/documents/changes",
-
-    establish: function() {
-      return [
-        this.model.changes.fetch()
-      ];
-    },
-
-    serialize: function () {
-      return {
-        changes: this.model.changes.toJSON(),
-        database: this.model
-      };
-    }
-
-  });
-
-
-  return Views;
-});