couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject [23/26] Remove fauxton from 1.4.x branch.
Date Wed, 07 Aug 2013 16:04:54 GMT
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/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 9e68ae3..0000000
--- a/src/fauxton/app/modules/documents/routes.js
+++ /dev/null
@@ -1,367 +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/views",
-       "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 DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
-    layout: "one_pane",
-
-    initialize: function(route, masterLayout, options) {
-      var databaseName = options[0], docID = options[1];
-
-      this.database = this.database || new Databases.Model({id: databaseName});
-      this.doc = new Documents.Doc({
-        _id: docID
-      }, {
-        database: this.database
-      });
-
-      this.tabsView = this.setView("#tabs", new Documents.Views.FieldEditorTabs({
-        selected: "code_editor",
-        model: this.doc
-      }));
-
-    },
-
-    routes: {
-      "database/:database/:doc/field_editor": "field_editor",
-      "database/:database/:doc/code_editor": "code_editor",
-      "database/:database/:doc": "code_editor"
-    },
-
-    events: {
-      "route:reRenderDoc": "reRenderDoc",
-      "route:duplicateDoc": "duplicateDoc"
-    },
-
-    crumbs: function() {
-      return [
-        {"name": "Databases", "link": "/_all_dbs"},
-        {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
-        {"name": this.docID, "link": "#"}
-      ];
-    },
-
-    code_editor: function (database, doc) {
-      this.tabsView.updateSelected('code_editor');
-
-      this.docView = this.setView("#dashboard-content", new Documents.Views.Doc({
-        model: this.doc,
-        database: this.database
-      }));
-    },
-
-    reRenderDoc: function () {
-      this.docView.forceRender();
-    },
-
-    field_editor: function(events) {
-      this.tabsView.updateSelected('field_editor');
-      this.docView = this.setView("#dashboard-content", new Documents.Views.DocFieldEditor({
-        model: this.doc
-      }));
-    },
-
-    duplicateDoc: function (newId) {
-      var doc = this.doc,
-      docView = this.docView,
-      database = this.database;
-
-      doc.copy(newId).then(function () {
-        doc.set({_id: newId}); 
-        docView.forceRender();
-        FauxtonAPI.navigate('/database/' + database.id + '/' + newId, {trigger: true});
-        FauxtonAPI.addNotification({
-          msg: "Document has been duplicated."
-        });
-
-      }, function (error) {
-        var errorMsg = "Could not duplicate document, reason: " + error.responseText + ".";
-        FauxtonAPI.addNotification({
-          msg: errorMsg,
-          type: "error"
-        });
-      });
-    },
-
-    apiUrl: function() {
-      return this.doc.url();
-    }
-  });
-
-  var NewDocEditorRouteObject = DocEditorRouteObject.extend({
-    initialize: function (route, masterLayout, options) {
-      var databaseName = options[0];
-
-      this.database = this.database || new Databases.Model({id: databaseName});
-      this.doc = new Documents.NewDoc(null,{
-        database: this.database
-      });
-
-      this.tabsView = this.setView("#tabs", new Documents.Views.FieldEditorTabs({
-        selected: "code_editor",
-        model: this.doc
-      }));
-
-    },
-
-    routes: {
-      "database/:database/new": "code_editor"
-    },
-
-  });
-
-  var DocumentsRouteObject = FauxtonAPI.RouteObject.extend({
-    layout: "with_tabs_sidebar",
-
-    routes: {
-      "database/:database/_all_docs(:extra)": "allDocs", 
-      "database/:database/_design/:ddoc/_view/:view": {
-        route: "viewFn",
-        roles: ['_admin']
-      },
-      "database/:database/new_view": "newViewEditor"
-    },
-
-    events: {
-      "route:updateAllDocs": "updateAllDocsFromView",
-      "route:updatePreviewDocs": "updateAllDocsFromPreview",
-      "route:reloadDesignDocs": "reloadDesignDocs"
-    },
-
-    initialize: function (route, masterLayout, options) {
-      var docOptions = app.getParams();
-      docOptions.include_docs = true;
-
-      this.databaseName = options[0];
-
-      this.data = {
-        database: new Databases.Model({id:this.databaseName})
-      };
-
-      this.data.designDocs = new Documents.AllDocs(null, {
-        database: this.data.database,
-        params: {startkey: '"_design"',
-          endkey: '"_design1"',
-          include_docs: true}
-      });
-
-      this.sidebar = this.setView("#sidebar-content", new Documents.Views.Sidebar({
-        collection: this.data.designDocs,
-        database: this.data.database
-      }));
-
-      this.setView("#tabs", new Documents.Views.Tabs({
-        collection: this.data.designDocs,
-        database: this.data.database
-      }));
-    },
-
-    establish: function () {
-      return this.data.designDocs.fetch();
-    },
-
-    allDocs: function(databaseName, options) {
-      var docOptions = app.getParams(options);
-
-      docOptions.include_docs = true;
-      this.data.database.buildAllDocs(docOptions);
-
-      if (docOptions.startkey && docOptions.startkey.indexOf('_design') > -1) {
-        this.sidebar.setSelectedTab('design-docs');
-      } else {
-        this.sidebar.setSelectedTab('all-docs');
-      }
-
-      if (this.viewEditor) { this.viewEditor.remove(); }
-
-      this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
-        collection: this.data.database.allDocs
-      }));
-
-      this.crumbs = [
-        {"name": "Databases", "link": "/_all_dbs"},
-        {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
-      ];
-
-      this.apiUrl = this.data.database.allDocs.url();
-    },
-
-    viewFn: function (databaseName, ddoc, view) {
-      var params = app.getParams();
-
-      view = view.replace(/\?.*$/,'');
-
-      this.data.indexedDocs = new Documents.IndexCollection(null, {
-        database: this.data.database,
-        design: ddoc,
-        view: view,
-        params: params
-      });
-
-      var ddocInfo = {
-        id: "_design/" + ddoc,
-        currView: view,
-        designDocs: this.data.designDocs
-      };
-
-      this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({
-        model: this.data.database,
-        ddocs: this.data.designDocs,
-        viewName: view,
-        params: params,
-        newView: false,
-        database: this.data.database,
-        ddocInfo: ddocInfo
-      }));
-
-      this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
-        database: this.data.database,
-        collection: this.data.indexedDocs,
-        nestedView: Documents.Views.Row,
-        viewList: true,
-        ddocInfo: ddocInfo
-      }));
-
-      this.sidebar.setSelectedTab(ddoc + '_' + view);
-
-      this.crumbs = function () {
-        return [
-          {"name": "Databases", "link": "/_all_dbs"},
-          {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)},
-          {"name": ddoc + "/" + view, "link": this.data.indexedDocs.url()}
-        ];
-      };
-
-      this.apiUrl = this.data.indexedDocs.url();
-    },
-
-    newViewEditor: function () {
-      var params = app.getParams();
-
-      this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({
-        ddocs: this.data.designDocs,
-        params: params,
-        database: this.data.database,
-        newView: true
-      }));
-
-      this.sidebar.setSelectedTab('new-view');
-    },
-
-    updateAllDocsFromView: function (event) {
-      var view = event.view,
-      ddoc = event.ddoc;
-
-      this.data.indexedDocs = new Documents.IndexCollection(null, {
-        database: this.data.database,
-        design: ddoc,
-        view: view,
-        params: app.getParams()
-      });
-
-      this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
-        database: this.data.database,
-        collection: this.data.indexedDocs,
-        nestedView: Documents.Views.Row,
-        viewList: true
-      }));
-    },
-
-    updateAllDocsFromPreview: function (event) {
-      var view = event.view,
-      rows = event.rows,
-      ddoc = event.ddoc;
-
-      this.data.indexedDocs = new Documents.PouchIndexCollection(null, {
-        database: this.data.database,
-        design: ddoc,
-        view: view,
-        rows: rows
-      });
-
-      this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
-        database: this.data.database,
-        collection: this.data.indexedDocs,
-        nestedView: Documents.Views.Row,
-        viewList: true
-      }));
-    },
-
-    reloadDesignDocs: function (event) {
-      this.sidebar.forceRender();
-
-      if (event && event.selectedTab) {
-        this.sidebar.setSelectedTab(event.selectedTab);
-      }
-    }
-  });
-
-  var ChangesRouteObject = FauxtonAPI.RouteObject.extend({
-    layout: "with_tabs",
-
-    crumbs: function () {
-      return [
-        {"name": "Databases", "link": "/_all_dbs"},
-        {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
-        {"name": "_changes", "link": "/_changes"}
-      ];
-    },
-
-    routes: {
-      "database/:database/_changes(:params)": "changes"
-    },
-
-    initialize: function (route, masterLayout, options) {
-      this.databaseName = options[0];
-      this.database = new Databases.Model({id: this.databaseName});
-
-      var docOptions = app.getParams();
-
-      this.database.buildChanges(docOptions);
-
-      this.setView("#tabs", new Documents.Views.Tabs({
-        collection: this.designDocs,
-        database: this.database,
-        active_id: 'changes'
-      }));
-    },
-
-    changes: function (event) {
-      this.setView("#dashboard-content", new Documents.Views.Changes({
-        model: this.database
-      }));
-    },
-
-    apiUrl: function() {
-      return this.database.changes.url();
-    }
-
-  });
-
-  Documents.RouteObjects = [DocEditorRouteObject, NewDocEditorRouteObject, DocumentsRouteObject, ChangesRouteObject];
-
-  return Documents;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/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 2ef4d41..0000000
--- a/src/fauxton/app/modules/documents/views.js
+++ /dev/null
@@ -1,1399 +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/documents/resources",
-       "modules/pouchdb/base",
-
-       // Libs
-       "codemirror",
-       "jshint",
-
-       // Plugins
-       "plugins/codemirror-javascript",
-       "plugins/prettify"
-
-],
-
-function(app, FauxtonAPI, Documents, pouchdb, 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.UploadModal = FauxtonAPI.View.extend({
-    template: "templates/documents/upload_modal",
-
-    initialize: function (options) {
-      _.bindAll(this);
-    },
-
-    events: {
-      "click a#upload-btn": "uploadFile"
-    },
-
-    uploadFile: function (event) {
-      event.preventDefault();
-
-      var docRev = this.model.get('_rev'),
-          $form = this.$('#file-upload');
-
-      if (!docRev) {
-        return this.set_error_msg('The document needs to be saved before adding an attachment.');
-      }
-
-      if ($('input[type="file"]')[0].files.length === 0) {
-        return this.set_error_msg('Selected a file to be uploaded.');
-      }
-
-      this.$('#_rev').val(docRev);
-
-      $form.ajaxSubmit({
-        url: this.model.url(),
-        type: 'POST',
-        beforeSend: this.beforeSend,
-        uploadProgress: this.uploadProgress,
-        success: this.success,
-        error: function () {
-          console.log('ERR on upload', arguments);
-        }
-      });
-    },
-
-    success: function (resp) {
-      var hideModal = this.hideModal,
-      $form = this.$('#file-upload');
-
-      FauxtonAPI.triggerRouteEvent('reRenderDoc');
-      //slight delay to make this transistion a little more fluid and less jumpy
-      setTimeout(function () {
-        $form.clearForm();
-        hideModal();
-      }, 1000);
-    },
-
-    uploadProgress: function(event, position, total, percentComplete) {
-      this.$('.bar').css({width: percentComplete + '%'});
-    },
-
-    beforeSend: function () {
-      this.$('.progress').removeClass('hide');
-    },
-
-    showModal: function () {
-      this.$('.bar').css({width: '0%'});
-      this.$('.progress').addClass('hide');
-      this.clear_error_msg();
-      this.$('.modal').modal();
-      // hack to get modal visible 
-      $('.modal-backdrop').css('z-index',1025);
-    },
-
-    hideModal: function () {
-      this.$('.modal').modal('hide');
-    },
-
-    set_error_msg: function (msg) {
-      var text;
-      if (typeof(msg) == 'string') {
-        text = msg;
-      } else {
-        text = JSON.parse(msg.responseText).reason;
-      }
-      this.$('#modal-error').text(text).removeClass('hide');
-    },
-
-    clear_error_msg: function () {
-      this.$('#modal-error').text(' ').addClass('hide');
-    },
-
-    serialize: function () {
-      return this.model.toJSON();
-    }
-  });
-
-  Views.DuplicateDocModal = FauxtonAPI.View.extend({
-    template: "templates/documents/duplicate_doc_modal",
-
-    initialize: function () {
-      _.bindAll(this);
-    },
-
-    events: {
-      "click #duplicate-btn":"duplicate"
-
-    },
-
-    duplicate: function (event) {
-      event.preventDefault();
-      var newId = this.$('#dup-id').val();
-
-      this.hideModal();
-      FauxtonAPI.triggerRouteEvent('duplicateDoc', newId);
-    },
-
-    _showModal: function () {
-      this.$('.bar').css({width: '0%'});
-      this.$('.progress').addClass('hide');
-      this.clear_error_msg();
-      this.$('.modal').modal();
-      // hack to get modal visible 
-      $('.modal-backdrop').css('z-index',1025);
-    },
-
-    showModal: function () {
-      var showModal = this._showModal,
-          setDefaultIdValue = this.setDefaultIdValue,
-          uuid = new FauxtonAPI.UUID();
-
-      uuid.fetch().then(function () {
-        setDefaultIdValue(uuid.next());
-        showModal();
-      });
-    },
-
-    setDefaultIdValue: function (id) {
-      this.$('#dup-id').val(id);
-    },
-
-    hideModal: function () {
-      this.$('.modal').modal('hide');
-    },
-
-    set_error_msg: function (msg) {
-      var text;
-      if (typeof(msg) == 'string') {
-        text = msg;
-      } else {
-        text = JSON.parse(msg.responseText).reason;
-      }
-      this.$('#modal-error').text(text).removeClass('hide');
-    },
-
-    clear_error_msg: function () {
-      this.$('#modal-error').text(' ').addClass('hide');
-    },
-
-    serialize: function () {
-      return this.model.toJSON();
-    }
-
-  });
-
-  Views.FieldEditorTabs = FauxtonAPI.View.extend({
-    template: "templates/documents/doc_field_editor_tabs",
-
-    disableLoader: true,
-
-    initialize: function(options) {
-      this.selected = options.selected;
-    },
-
-    events: {
-      "click button.delete": "destroy",
-      "click button.duplicate": "duplicate",
-      "click button.upload": "upload"
-    },
-
-    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"
-        });
-      });
-    },
-
-    beforeRender: function () {
-      this.uploadModal = this.setView('#upload-modal', new Views.UploadModal({model: this.model}));
-      this.uploadModal.render();
-
-      this.duplicateModal = this.setView('#duplicate-modal', new Views.DuplicateDocModal({model: this.model}));
-      this.duplicateModal.render();
-    },
-
-    upload: function (event) {
-      event.preventDefault();
-      if (this.model.isNewDoc()) {
-        FauxtonAPI.addNotification({
-          msg: 'Please save the document before uploading an attachment.',
-          type: 'warning'
-        });
-        return;
-      }
-      this.uploadModal.showModal();
-    },
-
-    duplicate: function(event) {
-      event.preventDefault();
-      this.duplicateModal.showModal();
-    },
-
-    updateSelected: function (selected) {
-      this.selected = selected;
-      this.$('.active').removeClass('active');
-      this.$('#'+this.selected).addClass('active');
-    },
-
-    serialize: function() {
-      var selected = this.selected;
-      return {
-        doc: this.model,
-        isNewDoc: this.model.isNewDoc(),
-        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"
-    },
-
-    initialize: function(options){
-      this.nestedView = options.nestedView || Views.Document;
-      this.rows = {};
-      this.viewList = !! options.viewList;
-      this.database = options.database;
-      if (options.ddocInfo) {
-        this.designDocs = options.ddocInfo.designDocs;
-        this.ddocID = options.ddocInfo.id;
-      }
-      this.newView = options.newView || false;
-    },
-
-    establish: function() {
-      if (this.newView) { return null; }
-
-      return this.collection.fetch().fail(function() {
-        // TODO: handle error requests that slip through
-        // This should just throw a notification, not break the page
-        console.log("ERROR: ", arguments);
-      });
-    },
-
-    selectAll: function(evt){
-      $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
-    },
-
-    serialize: function() {
-      var totalRows = 0,
-      updateSeq = false;
-
-      if (!this.newView) {
-        totalRows = this.collection.totalRows();
-        updateSeq = this.collection.updateSeq();
-      }
-
-      var info = {
-        updateSeq: updateSeq,
-        totalRows: totalRows,
-        numModels: this.collection.models.length,
-        viewList: this.viewList,
-        requestDuration: null
-      };
-
-      if (this.collection.requestDurationInString) {
-        info.requestDuration = this.collection.requestDurationInString();
-      }
-
-      return info;
-    },
-
-    /*
-     * 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.collection.each(function(doc) {
-        this.rows[doc.id] = this.insertView("table.all-docs tbody", new this.nestedView({
-          model: doc
-        }));
-      }, this);
-    },
-
-    afterRender: function(){
-      prettyPrint();
-    }
-  });
-
-  Views.Doc = FauxtonAPI.View.extend({
-    template: "templates/documents/doc",
-
-    events: {
-      "click button.save-doc": "saveDoc"
-    },
-
-    initialize: function (options) {
-      this.database = options.database;
-    },
-
-    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, 
-      that = this,
-      validDoc = this.getDocFromEditor();
-
-      if (validDoc) {
-        this.getDocFromEditor();
-
-        notification = FauxtonAPI.addNotification({msg: "Saving document."});
-
-        this.model.save().then(function () {
-          FauxtonAPI.navigate('/database/' + that.database.id + '/' + that.model.id);
-        }).fail(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"
-        });
-      }
-    },
-
-    getDocFromEditor: function () {
-      if (!this.hasValidCode()) {
-        return false;
-      }
-
-      json = JSON.parse(this.editor.getValue());
-      this.model.clear({silent:true});
-      this.model.set(json);
-
-      return this.model;
-    },
-
-    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,
-        attachments: this.getAttachments()
-      };
-    },
-
-    getAttachments: function () {
-      var attachments = this.model.get('_attachments');
-
-      if (!attachments) { return false; }
-
-      return _.map(attachments, function (att, key) {
-        return {
-          fileName: key,
-          size: att.length,
-          contentType: att.content_type,
-          url: this.model.url() + '/' + key
-        };
-      }, this);
-    },
-
-    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() {
-          try {
-            that.runJSHint();
-          } catch (e) {
-            console.log('ERROR for jshint',e);
-          }
-        },
-        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.getModelWithoutAttachments(),
-        attachments: this.getAttachments()
-      };
-    },
-
-    getModelWithoutAttachments: function() {
-      var model = this.model.toJSON();
-      delete model._attachments;
-      return model;
-    },
-
-    getAttachments: function () {
-      var attachments = this.model.get('_attachments');
-
-      if (!attachments) { return []; }
-
-      return _.map(attachments, function (att, key) {
-        return {
-          fileName: key,
-          size: att.length,
-          contentType: att.content_type,
-          url: this.model.url() + '/' + key
-        };
-      }, this);
-    },
-
-    establish: function() {
-      return [this.model.fetch()];
-    }
-  });
-
-  //TODO split this into two smaller views, one for advance query options and other for index editing
-  Views.ViewEditor = FauxtonAPI.View.extend({
-    template: "templates/documents/view_editor",
-    builtinReduces: ['_sum', '_count', '_stats'],
-
-    events: {
-      "click button.save": "saveView",
-      "click button.preview": "previewView",
-      "click button.delete": "deleteView",
-      "change select#reduce-function-selector": "updateReduce",
-      "change form.view-query-update input": "updateFilters",
-      "change form.view-query-update select": "updateFilters",
-      "change select#ddoc": "updateDesignDoc",
-      "submit form.view-query-update": "updateView"
-    },
-
-    langTemplates: {
-      "javascript": {
-        map: "function(doc) {\n  emit(doc.id, 1);\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.newView = options.newView || false;
-      this.ddocs = options.ddocs;
-      this.params = options.params;
-      this.database = options.database;
-      if (this.newView) {
-        this.viewName = 'newView';
-      } else {
-        this.ddocID = options.ddocInfo.id;
-        this.viewName = options.viewName;
-        this.ddocInfo = new Documents.DdocInfo({_id: this.ddocID},{database: this.database});
-      } 
-    },
-
-    establish: function () {
-      if (this.ddocInfo) {
-        return this.ddocInfo.fetch();
-      }
-    },
-
-    updateDesignDoc: function () {
-
-      if (this.$('#ddoc :selected').prop('id') === 'new-doc') {
-        this.$('#new-ddoc-section').show();
-
-      } else {
-        this.$('#new-ddoc-section').hide();
-      }
-
-    },
-
-    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();
-      }
-    },
-
-    queryParams: function () {
-      var $form = $(".view-query-update");
-      // 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;
-        }
-      });
-
-      return {params: params, errorParams: errorParams};
-    },
-
-    deleteView: function (event) {
-      event.preventDefault();
-
-      if (this.newView) { return alert('Cannot delete a new view.'); }
-      if (!confirm('Are you sure you want to delete this view?')) {return;}
-
-      var that = this,
-          promise,
-          viewName = this.$('#index-name').val(),
-          ddocName = this.$('#ddoc :selected').val(),
-          ddoc = this.getCurrentDesignDoc();
-
-      ddoc.removeDdocView(viewName);
-
-      if (ddoc.hasViews()) {
-        promise = ddoc.save(); 
-      } else {
-        promise = ddoc.destroy();
-      }
-
-      promise.then(function () {
-        FauxtonAPI.navigate('/database/' + that.database.id + '/_all_docs?limit=100');
-        FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
-      });
-    },
-
-    updateView: function(event) {
-      event.preventDefault();
-
-      if (this.newView) { return alert('Please save this new view before querying it.'); }
-
-      var paramInfo = this.queryParams(),
-      errorParams = paramInfo.errorParams,
-      params = paramInfo.params;
-
-      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, {trigger: false});
-
-      FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: this.ddocID, view: this.viewName});
-    },
-
-    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;
-      }
-    },
-
-    previewView: function(event) {
-      var that = this,
-      mapVal = this.mapEditor.getValue(),
-      reduceVal = this.reduceVal(),
-      paramsArr = this.queryParams().params;
-
-      var params = _.reduce(paramsArr, function (params, param) {
-        params[param.name] = param.value;
-        return params;
-      }, {reduce: false});
-
-      event.preventDefault();
-
-      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: true
-      });
-
-      var promise = FauxtonAPI.Deferred();
-
-      if (!this.database.allDocs) {
-        this.database.buildAllDocs({limit: "100", include_docs: true});
-        promise = this.database.allDocs.fetch();
-      } else {
-        promise.resolve();
-      }
-
-      promise.then(function () {
-        params.docs = that.database.allDocs.map(function (model) { return model.get('doc');}); 
-
-        var queryPromise = pouchdb.runViewQuery({map: mapVal, reduce: reduceVal}, params);
-        queryPromise.then(function (results) {
-          FauxtonAPI.triggerRouteEvent('updatePreviewDocs', {rows: results.rows, ddoc: that.getCurrentDesignDoc().id, view: that.viewName});
-        });
-      });
-    },
-
-    saveView: function(event) {
-      var json, notification,
-      that = this;
-
-      event.preventDefault();
-
-      if (this.hasValidCode()) {
-        var mapVal = this.mapEditor.getValue(), 
-        reduceVal = this.reduceVal(),
-        viewName = this.$('#index-name').val(),
-        ddoc = this.getCurrentDesignDoc(),
-        ddocName = ddoc.id;
-
-        this.viewName = viewName;
-
-        notification = FauxtonAPI.addNotification({
-          msg: "Saving document.",
-          selector: "#define-view .errors-container"
-        });
-
-        ddoc.setDdocView(viewName, mapVal, reduceVal);
-
-        ddoc.save().then(function () {
-          FauxtonAPI.addNotification({
-            msg: "View has been saved.",
-            type: "success",
-            selector: "#define-view .errors-container"
-          });
-
-          if (that.newView) {
-            var fragment = '/database/' + that.database.id +'/' + ddocName + '/_view/' + viewName; 
-
-            FauxtonAPI.navigate(fragment, {trigger: false});
-            FauxtonAPI.triggerRouteEvent('reloadDesignDocs',{selectedTab: ddocName.replace('_design/','') + '_' + viewName});
-
-            that.newView = false;
-          }
-
-          FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: ddocName, view: viewName});
-
-        }, 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 Javascript errors and try again.",
-          type: "error",
-          selector: "#define-view .errors-container"
-        });
-      }
-    },
-
-    getCurrentDesignDoc: function () {
-      if (this.newDesignDoc()) {
-        var doc = {
-          _id: '_design/' + this.$('#new-ddoc').val(),
-          views: {},
-          language: "javascript"
-        };
-        return new Documents.Doc(doc, {database: this.database});
-      } else {
-        var ddocName = this.$('#ddoc').val();
-        return this.ddocs.find(function (ddoc) {
-          return ddoc.id === ddocName;
-        }).dDocModel();
-      }
-
-    },
-
-    newDesignDoc: function () {
-      return this.$('#ddoc :selected').prop('id') === 'new-doc';
-    },
-
-    isCustomReduceEnabled: function() {
-      return $("#reduce-function-selector").val() == "CUSTOM";
-    },
-
-    reduceVal: function() {
-      var reduceOption = this.$('#reduce-function-selector :selected').val(),
-      reduceVal = "";
-
-      if (reduceOption === 'CUSTOM') {
-        reduceVal = this.reduceEditor.getValue();
-      } else if ( reduceOption !== 'NONE') {
-        reduceVal = reduceOption;
-      }
-
-      return reduceVal;
-    },
-
-    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.raw);
-          });
-        }
-      }, 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 {
-        ddocs: this.ddocs,
-        ddoc: this.model,
-        ddocName: this.model.id,
-        viewName: this.viewName,
-        reduceFunStr: this.reduceFunStr,
-        hasReduce: this.reduceFunStr,
-        isCustomReduce: this.hasCustomReduce(),
-        newView: this.newView,
-        langTemplates: this.langTemplates.javascript
-      };
-    },
-
-    hasCustomReduce: function() {
-      return this.reduceFunStr && ! _.contains(this.builtinReduces, this.reduceFunStr);
-    },
-
-    beforeRender: function () {
-
-      if (this.newView) {
-        this.reduceFunStr = '_sum';
-        if (this.ddocs.length === 0) {
-          this.model = new Documents.Doc(null, {database: this.database});
-        } else {
-          this.model = this.ddocs.first().dDocModel();
-        }
-        this.ddocID = this.model.id;
-      } else {
-        this.model = this.ddocs.get(this.ddocID).dDocModel();
-        this.reduceFunStr = this.model.viewHasReduce(this.viewName);
-        this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
-      }
-    },
-
-    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.updateDesignDoc();
-
-      this.mapEditor = Codemirror.fromTextArea(mapFun.get()[0], {
-        mode: "javascript",
-        lineNumbers: true,
-        matchBrackets: true,
-        lineWrapping: true,
-        onChange: function() {
-          try {
-            that.runJSHint("mapEditor");
-          } catch (e) {
-            console.log('ERROR for jshint',e);
-          }
-        },
-        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() {
-          try {
-            that.runJSHint("reduceEditor");
-          } catch (e) {
-            console.log('ERROR for jshint',e);
-          }
-        },
-        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();
-      }
-
-      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.Sidebar = FauxtonAPI.View.extend({
-    template: "templates/documents/sidebar",
-    events: {
-      "click a.new#index": "newIndex",
-      "submit #jump-to-doc": "jumpToDoc"
-    },
-
-    initialize: function(options) {
-      this.database = options.database;
-      if (options.ddocInfo) {
-        this.ddocID = options.ddocInfo.id;
-        this.currView = options.ddocInfo.currView;
-      }
-    },
-
-    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);
-    },
-
-    jumpToDoc: function (event) {
-      event.preventDefault();
-      var docId = this.$('#jump-to-doc-id').val();
-      FauxtonAPI.navigate('/database/' + this.database.id +'/' + docId, {trigger: true});
-    },
-
-    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);
-    },
-
-    afterRender: function () {
-      if (this.selectedTab) {
-        this.setSelectedTab(this.selectedTab);
-      }
-    },
-
-    setSelectedTab: function (selectedTab) {
-      this.selectedTab = selectedTab;
-      this.$('li').removeClass('active');
-      this.$('#' + selectedTab).parent().addClass('active');
-    }
-
-  });
-
-  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
-      };
-    },
-
-    afterRender: function(){
-      prettyPrint();
-    }
-  });
-
-  Views.DdocInfo = FauxtonAPI.View.extend({
-    template: "templates/documents/ddoc_info",
-
-    initialize: function (options) {
-      this.refreshTime = options.refreshTime || 5000;
-      this.listenTo(this.model, 'change', this.render);
-    },
-
-    serialize: function () {
-      return {
-        view_index: this.model.get('view_index')
-      };
-    },
-
-    afterRender: function () {
-      this.startRefreshInterval();
-    },
-
-    startRefreshInterval: function () {
-      var model = this.model;
-
-      // Interval already set
-      if (this.intervalId) { return ; }
-
-      this.intervalId = setInterval(function () {
-        model.fetch();
-      }, this.refreshTime);
-    },
-
-    stopRefreshInterval: function () {
-      clearInterval(this.intervalId);
-    },
-
-    cleanup: function () {
-      this.stopRefreshInterval();
-    }
-  });
-
-  Documents.Views = Views;
-  return Documents;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/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
deleted file mode 100644
index 716e9e7..0000000
--- a/src/fauxton/app/modules/fauxton/base.js
+++ /dev/null
@@ -1,191 +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",
-       // Libs
-       "backbone"
-
-],
-
-function(app, Backbone) {
-  var Fauxton = app.module();
-
-  Fauxton.Breadcrumbs = Backbone.View.extend({
-    template: "templates/fauxton/breadcrumbs",
-
-    serialize: function() {
-      var crumbs = _.clone(this.crumbs);
-      return {
-        crumbs: crumbs
-      };
-    },
-
-    initialize: function(options) {
-      this.crumbs = options.crumbs;
-    }
-  });
-
-  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: this.versionInfo.get("version")
-      };
-    }
-  });
-
-  Fauxton.NavBar = Backbone.View.extend({
-    template: "templates/fauxton/nav_bar",
-    // TODO: can we generate this list from the router?
-    navLinks: [
-      {href:"#/_all_dbs", title:"Databases"}
-    ],
-
-    initialize: function() {
-    },
-
-    serialize: function() {
-      return {navLinks: this.navLinks};
-    },
-
-    addLink: function(link) {
-      if (link.top){
-        this.navLinks.unshift(link);
-      } else {
-        this.navLinks.push(link);
-      }
-      this.trigger("link:add");
-
-      this.render();
-    },
-
-    beforeRender: function () {
-      this.addLinkViews();
-    },
-
-    addLinkViews: function () {
-      var that = this;
-
-      _.each(this.navLinks, function (link) {
-        if (!link.view) { return; }
-
-        //TODO check if establish is a function
-        var establish = link.establish || [];
-        $.when.apply(null, establish).then( function () {
-          that.insertView('#nav-links', link.view).render();
-        });
-      }, this);
-    }
-
-    // TODO: ADD ACTIVE CLASS
-  });
-
-  Fauxton.ApiBar = Backbone.View.extend({
-    template: "templates/fauxton/api_bar",
-    endpoint: '_all_docs',
-
-    serialize: function() {
-      return {endpoint: this.endpoint};
-    },
-
-    update: function(endpoint) {
-      // Take endpoint and write it into the api bar.
-      console.log('ApiBar endpoint: ' + endpoint);
-      this.endpoint = endpoint;
-      this.render();
-    }
-
-  });
-
-  Fauxton.Notification = Backbone.View.extend({
-    fadeTimer: 5000,
-
-    initialize: function(options) {
-      this.msg = options.msg;
-      this.type = options.type || "info";
-      this.selector = options.selector;
-      this.fade = options.fade === undefined ? true : options.fade;
-      this.clear = options.clear;
-      this.data = options.data || "";
-      this.template = options.template || "templates/fauxton/notification";
-    },
-
-    serialize: function() {
-      return {
-        data: this.data,
-        msg: this.msg,
-        type: this.type
-      };
-    },
-
-    delayedFade: function() {
-      var that = this;
-      if (this.fade) {
-        setTimeout(function() {
-          that.$el.fadeOut();
-        }, this.fadeTimer);
-      }
-    },
-
-    renderNotification: function(selector) {
-      selector = selector || this.selector;
-      if (this.clear) {
-        $(selector).html('');
-      }
-      this.render().view.$el.appendTo(selector);
-      this.delayedFade();
-      return this;
-    }
-  });
-
-  Fauxton.Pagination = Backbone.View.extend({
-    template: "templates/fauxton/pagination",
-
-    initialize: function(options) {
-      this.page = options.page;
-      this.perPage = options.perPage;
-      this.total = options.total;
-      this.totalPages = Math.ceil(this.total / this.perPage);
-      this.urlFun = options.urlFun;
-
-    },
-
-    serialize: function() {
-      return {
-        page: this.page,
-        perPage: this.perPage,
-        total: this.total,
-        totalPages: this.totalPages,
-        urlFun: this.urlFun
-      };
-    }
-  });
-
-  return Fauxton;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/fauxton/layout.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/layout.js b/src/fauxton/app/modules/fauxton/layout.js
deleted file mode 100644
index d964b7b..0000000
--- a/src/fauxton/app/modules/fauxton/layout.js
+++ /dev/null
@@ -1,96 +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(["backbone"],
-
-function(Backbone) {
-
-  // A wrapper of the main Backbone.layoutmanager
-  // Allows the main layout of the page to be changed by any plugin.
-  // Exposes the different views:
-  //    navBar -> the top navigation bar
-  //    dashboardContent -> Main display view
-  //    breadcrumbs -> Breadcrumbs navigation section
-  var Layout = function (navBar, apiBar) {
-    this.navBar = navBar;
-    this.apiBar = apiBar;
-
-    this.layout = new Backbone.Layout({
-      template: "templates/layouts/with_sidebar",
-
-      views: {
-        "#primary-navbar": this.navBar,
-        "#api-navbar": this.apiBar
-      }
-    });
-
-    this.layoutViews = {};
-    this.hooks = {};
-
-    this.el = this.layout.el;
-  };
-
-  // creatings the dashboard object same way backbone does
-  _.extend(Layout.prototype, {
-
-    render: function () {
-      return this.layout.render();
-    },
-
-    setTemplate: function(template) {
-      if (template.prefix){
-        this.layout.template = template.prefix + template.name;
-      } else{
-        this.layout.template = "templates/layouts/" + template;
-      }
-      // If we're changing layouts all bets are off, so kill off all the
-      // existing views in the layout.
-      _.each(this.layoutViews, function(view){view.remove();});
-      this.layoutViews = {};
-      this.render();
-    },
-
-    setTabs: function(view){
-      // TODO: Not sure I like this - seems fragile/repetitive
-      this.tabs = this.layout.setView("#tabs", view);
-      this.tabs.render();
-    },
-
-    setBreadcrumbs: function(view) {
-      this.breadcrumbs = this.layout.setView("#breadcrumbs", view);
-      this.breadcrumbs.render();
-    },
-
-    clearBreadcrumbs: function () {
-      if (!this.breadcrumbs) {return ;}
-
-      this.breadcrumbs.remove();
-    },
-
-    setView: function(selector, view) {
-      this.layoutViews[selector] = this.layout.setView(selector, view, false);
-    },
-
-    renderView: function(selector) {
-      var view = this.layoutViews[selector];
-      if (!view) {
-        return false;
-      } else {
-        return view.render();
-      }
-    }
-
-  });
-
-  return Layout;
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/pouchdb/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/pouchdb/base.js b/src/fauxton/app/modules/pouchdb/base.js
deleted file mode 100644
index ddaf06d..0000000
--- a/src/fauxton/app/modules/pouchdb/base.js
+++ /dev/null
@@ -1,60 +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.
-
-
-/*
- * NOTE:
- * This temporarily uses the PouchDB map reduce implementation
- * These files are modified locally until we make a more general version and
- * push it back upstream.
- */
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/pouchdb/pouchdb.mapreduce.js"
-],
-
-function(app, FauxtonAPI, MapReduce) {
-  var Pouch = {};
-  Pouch.MapReduce = MapReduce;
-
-  Pouch.runViewQuery = function(fun, opts) {
-    /*docs = [
-      {_id: 'test_doc_1', foo: 'bar-1'},
-      {_id: 'test_doc_2', foo: 'bar-2'},
-      {_id: 'test_doc_3', foo: 'bar-3'},
-      {_id: 'test_doc_4', foo: 'bar-4'},
-      {_id: 'test_doc_5', foo: 'bar-5'},
-      {_id: 'test_doc_6', foo: 'bar-6'},
-      {_id: 'test_doc_7', foo: 'bar-7'},
-      {_id: 'test_doc_8', foo: 'bar-8'},
-      {_id: 'test_doc_9', foo: 'bar-9'},
-      {_id: 'test_doc_10', foo: 'bar-10'}
-    ];*/
-
-    var deferred = FauxtonAPI.Deferred();
-    var complete = function(resp, rows) {
-      deferred.resolve(rows);
-    };
-
-    var options = _.extend(opts, {complete: complete});
-
-    Pouch.MapReduce.query(fun, options);
-    return deferred;
-  };
-  //pdb.runViewQuery({map:function(doc) { emit(doc._id, doc.foo) }})
-  return Pouch;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/pouchdb/pouch.collate.js b/src/fauxton/app/modules/pouchdb/pouch.collate.js
deleted file mode 100644
index 7cc5f9c..0000000
--- a/src/fauxton/app/modules/pouchdb/pouch.collate.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * NOTE:
- * This temporarily uses the PouchDB map reduce implementation
- * These files are modified locally until we make a more general version and
- * push it back upstream.
- * Original file:
- * https://github.com/daleharvey/pouchdb/blob/master/src/pouch.collate.js
- */
-
-/*
-(function() {
-  // a few hacks to get things in the right place for node.js
-  if (typeof module !== 'undefined' && module.exports) {
-    module.exports = Pouch;
-  }
-*/
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/pouchdb/pouch.collate.js"
-],
-
-function(app, FauxtonAPI, Collate) {
-  var Pouch = {};
-
-  Pouch.collate = function(a, b) {
-    var ai = collationIndex(a);
-    var bi = collationIndex(b);
-    if ((ai - bi) !== 0) {
-      return ai - bi;
-    }
-    if (a === null) {
-      return 0;
-    }
-    if (typeof a === 'number') {
-      return a - b;
-    }
-    if (typeof a === 'boolean') {
-      return a < b ? -1 : 1;
-    }
-    if (typeof a === 'string') {
-      return stringCollate(a, b);
-    }
-    if (Array.isArray(a)) {
-      return arrayCollate(a, b);
-    }
-    if (typeof a === 'object') {
-      return objectCollate(a, b);
-    }
-  };
-
-  var stringCollate = function(a, b) {
-    // See: https://github.com/daleharvey/pouchdb/issues/40
-    // This is incompatible with the CouchDB implementation, but its the
-    // best we can do for now
-    return (a === b) ? 0 : ((a > b) ? 1 : -1);
-  };
-
-  var objectCollate = function(a, b) {
-    var ak = Object.keys(a), bk = Object.keys(b);
-    var len = Math.min(ak.length, bk.length);
-    for (var i = 0; i < len; i++) {
-      // First sort the keys
-      var sort = Pouch.collate(ak[i], bk[i]);
-      if (sort !== 0) {
-        return sort;
-      }
-      // if the keys are equal sort the values
-      sort = Pouch.collate(a[ak[i]], b[bk[i]]);
-      if (sort !== 0) {
-        return sort;
-      }
-
-    }
-    return (ak.length === bk.length) ? 0 :
-      (ak.length > bk.length) ? 1 : -1;
-  };
-
-  var arrayCollate = function(a, b) {
-    var len = Math.min(a.length, b.length);
-    for (var i = 0; i < len; i++) {
-      var sort = Pouch.collate(a[i], b[i]);
-      if (sort !== 0) {
-        return sort;
-      }
-    }
-    return (a.length === b.length) ? 0 :
-      (a.length > b.length) ? 1 : -1;
-  };
-
-  // The collation is defined by erlangs ordered terms
-  // the atoms null, true, false come first, then numbers, strings,
-  // arrays, then objects
-  var collationIndex = function(x) {
-    var id = ['boolean', 'number', 'string', 'object'];
-    if (id.indexOf(typeof x) !== -1) {
-      if (x === null) {
-        return 1;
-      }
-      return id.indexOf(typeof x) + 2;
-    }
-    if (Array.isArray(x)) {
-      return 4.5;
-    }
-  };
-
-  return Pouch;
-
-//}).call(this);
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js b/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
deleted file mode 100644
index a2d0b91..0000000
--- a/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * NOTE:
- * This temporarily uses the PouchDB map reduce implementation
- * These files are modified locally until we make a more general version and
- * push it back upstream.
- * Original file:
- * https://github.com/daleharvey/pouchdb/blob/master/src/plugins/pouchdb.mapreduce.js
- */
-
-/*global Pouch: true */
-
-//"use strict";
-
-// This is the first implementation of a basic plugin, we register the
-// plugin object with pouch and it is mixin'd to each database created
-// (regardless of adapter), adapters can override plugins by providing
-// their own implementation. functions on the plugin object that start
-// with _ are reserved function that are called by pouchdb for special
-// notifications.
-
-// If we wanted to store incremental views we can do it here by listening
-// to the changes feed (keeping track of our last update_seq between page loads)
-// and storing the result of the map function (possibly using the upcoming
-// extracted adapter functions)
-
-define([
-  "app",
-
-  "api",
-
-  // Modules
-  "modules/pouchdb/pouch.collate.js"
-],
-
-function(app, FauxtonAPI, Collate) {
-  var Pouch = {};
-  Pouch.collate = Collate.collate;
-
-  //var MapReduce = function(db) {
-  var MapReduce = function() {
-
-    var builtInReduce = {
-      "_sum": function(keys, values){
-        return sum(values);
-      },
-
-      "_count": function(keys, values, rereduce){
-        if (rereduce){
-          return sum(values);
-        } else {
-          return values.length;
-        }
-      },
-
-      "_stats": function(keys, values, rereduce){
-        return {
-          'sum': sum(values),
-          'min': Math.min.apply(null, values),
-          'max': Math.max.apply(null, values),
-          'count': values.length,
-          'sumsqr': (function(){
-            _sumsqr = 0;
-            for(var idx in values){
-              _sumsqr += values[idx] * values[idx];
-            }
-            return _sumsqr;
-          })()
-        };
-      }
-    };
-
-    function viewQuery(fun, options) {
-      console.log("IN VIEW QUERY");
-      if (!options.complete) {
-        return;
-      }
-
-      function sum(values) {
-        return values.reduce(function(a, b) { return a + b; }, 0);
-      }
-
-      var results = [];
-      var current = null;
-      var num_started= 0;
-      var completed= false;
-
-      var emit = function(key, val) {
-        //console.log("IN EMIT: ", key, val, current);
-        var viewRow = {
-          id: current.doc._id,
-          key: key,
-          value: val
-        }; 
-        //console.log("VIEW ROW: ", viewRow);
-
-        if (options.startkey && Pouch.collate(key, options.startkey) < 0) return;
-        if (options.endkey && Pouch.collate(key, options.endkey) > 0) return;
-        if (options.key && Pouch.collate(key, options.key) !== 0) return;
-        num_started++;
-        if (options.include_docs) {
-          // TODO:: FIX
-          throw({error: "Include Docs not supported"});
-          /*
-
-          //in this special case, join on _id (issue #106)
-          if (val && typeof val === 'object' && val._id){
-            db.get(val._id,
-                function(_, joined_doc){
-                  if (joined_doc) {
-                    viewRow.doc = joined_doc;
-                  }
-                  results.push(viewRow);
-                  checkComplete();
-                });
-            return;
-          } else {
-            viewRow.doc = current.doc;
-          }
-          */
-        }
-        console.log("EMITTING: ", viewRow);
-        results.push(viewRow);
-      };
-
-      // ugly way to make sure references to 'emit' in map/reduce bind to the
-      // above emit
-      eval('fun.map = ' + fun.map.toString() + ';');
-      if (fun.reduce && options.reduce) {
-        if (builtInReduce[fun.reduce]) {
-          console.log('built in reduce');
-          fun.reduce = builtInReduce[fun.reduce];
-        }
-        eval('fun.reduce = ' + fun.reduce.toString() + ';');
-      }
-
-      // exclude  _conflicts key by default
-      // or to use options.conflicts if it's set when called by db.query
-      var conflicts = ('conflicts' in options ? options.conflicts : false);
-
-      //only proceed once all documents are mapped and joined
-      var checkComplete= function(){
-        console.log('check');
-        if (completed && results.length == num_started){
-          results.sort(function(a, b) {
-            return Pouch.collate(a.key, b.key);
-          });
-          if (options.descending) {
-            results.reverse();
-          }
-          if (options.reduce === false) {
-            return options.complete(null, {rows: results});
-          }
-
-          console.log('reducing', options);
-          var groups = [];
-          results.forEach(function(e) {
-            var last = groups[groups.length-1] || null;
-            if (last && Pouch.collate(last.key[0][0], e.key) === 0) {
-              last.key.push([e.key, e.id]);
-              last.value.push(e.value);
-              return;
-            }
-            groups.push({key: [[e.key, e.id]], value: [e.value]});
-          });
-          groups.forEach(function(e) {
-            e.value = fun.reduce(e.key, e.value) || null;
-            e.key = e.key[0][0];
-          });
-          console.log('GROUPs', groups);
-          options.complete(null, {rows: groups});
-        }
-      };
-
-      if (options.docs) {
-        //console.log("RUNNING MR ON DOCS: ", options.docs);
-        _.each(options.docs, function(doc) {
-          current = {doc: doc};
-          fun.map.call(this, doc);
-        }, this);
-        completed = true;
-        return checkComplete();//options.complete(null, {rows: results});
-      } else {
-        //console.log("COULD NOT FIND DOCS");
-        return false;
-      }
-
-      /*
-      db.changes({
-        conflicts: conflicts,
-        include_docs: true,
-        onChange: function(doc) {
-          if (!('deleted' in doc)) {
-            current = {doc: doc.doc};
-            fun.map.call(this, doc.doc);
-          }
-        },
-        complete: function() {
-          completed= true;
-          checkComplete();
-        }
-      });
-      */
-    }
-
-    /*
-    function httpQuery(fun, opts, callback) {
-
-      // List of parameters to add to the PUT request
-      var params = [];
-      var body = undefined;
-      var method = 'GET';
-
-      // If opts.reduce exists and is defined, then add it to the list
-      // of parameters.
-      // If reduce=false then the results are that of only the map function
-      // not the final result of map and reduce.
-      if (typeof opts.reduce !== 'undefined') {
-        params.push('reduce=' + opts.reduce);
-      }
-      if (typeof opts.include_docs !== 'undefined') {
-        params.push('include_docs=' + opts.include_docs);
-      }
-      if (typeof opts.limit !== 'undefined') {
-        params.push('limit=' + opts.limit);
-      }
-      if (typeof opts.descending !== 'undefined') {
-        params.push('descending=' + opts.descending);
-      }
-      if (typeof opts.startkey !== 'undefined') {
-        params.push('startkey=' + encodeURIComponent(JSON.stringify(opts.startkey)));
-      }
-      if (typeof opts.endkey !== 'undefined') {
-        params.push('endkey=' + encodeURIComponent(JSON.stringify(opts.endkey)));
-      }
-      if (typeof opts.key !== 'undefined') {
-        params.push('key=' + encodeURIComponent(JSON.stringify(opts.key)));
-      }
-
-      // If keys are supplied, issue a POST request to circumvent GET query string limits
-      // see http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
-      if (typeof opts.keys !== 'undefined') {
-        method = 'POST';
-        body = JSON.stringify({keys:opts.keys});
-      }
-
-      // Format the list of parameters into a valid URI query string
-      params = params.join('&');
-      params = params === '' ? '' : '?' + params;
-
-      // We are referencing a query defined in the design doc
-      if (typeof fun === 'string') {
-        var parts = fun.split('/');
-        db.request({
-          method: method,
-          url: '_design/' + parts[0] + '/_view/' + parts[1] + params,
-          body: body
-        }, callback);
-        return;
-      }
-
-      // We are using a temporary view, terrible for performance but good for testing
-      var queryObject = JSON.parse(JSON.stringify(fun, function(key, val) {
-        if (typeof val === 'function') {
-          return val + ''; // implicitly `toString` it
-        }
-        return val;
-      }));
-
-      db.request({
-        method:'POST',
-        url: '_temp_view' + params,
-        body: queryObject
-      }, callback);
-    }
-    */
-
-    function query(fun, opts, callback) {
-      if (typeof opts === 'function') {
-        callback = opts;
-        opts = {};
-      }
-
-      if (callback) {
-        opts.complete = callback;
-      }
-
-      /*
-      if (db.type() === 'http') {
-        return httpQuery(fun, opts, callback);
-      }
-      */
-
-      if (typeof fun === 'object') {
-        console.log("RUNNING VIEW QUERY", fun, opts, arguments);
-        return viewQuery(fun, opts);
-      }
-
-      throw({error: "Shouldn't have gotten here"});
-
-      /*
-      var parts = fun.split('/');
-      db.get('_design/' + parts[0], function(err, doc) {
-        if (err) {
-          if (callback) callback(err);
-          return;
-        }
-        viewQuery({
-          map: doc.views[parts[1]].map,
-          reduce: doc.views[parts[1]].reduce
-        }, opts);
-      });
-      */
-    }
-
-    return {'query': query};
-  };
-
-  // Deletion is a noop since we dont store the results of the view
-  MapReduce._delete = function() { };
-
-  //Pouch.plugin('mapreduce', MapReduce);
-
-  return MapReduce();
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
deleted file mode 100644
index c12d951..0000000
--- a/src/fauxton/app/router.js
+++ /dev/null
@@ -1,147 +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([
-       // Load require for use in nested requiring
-       // as per the note in: http://requirejs.org/docs/api.html#multiversion
-       "require",
-
-       // Application.
-       "app",
-
-       // Initialize application
-       "initialize",
-
-       // Load Fauxton API
-       "api",
-
-       // Modules
-       "modules/fauxton/base",
-       // Layout
-       "modules/fauxton/layout",
-
-       // Routes return the module that they define routes for
-       "modules/databases/base",
-       "modules/documents/base",
-       "modules/pouchdb/base",
-
-
-       // this needs to be added as a plugin later
-       // "modules/logs/base",
-       // "modules/config/base",
-
-       "load_addons"
-],
-
-function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents, Pouch, LoadAddons) {
-
-  // TODO: auto generate this list if possible
-  var modules = [Databases, Documents];
-
-  var Router = app.router = Backbone.Router.extend({
-    routes: {},
-
-    addModuleRouteObject: function(RouteObject) {
-      var that = this; //change that to that
-      var masterLayout = this.masterLayout,
-      routeUrls = RouteObject.prototype.getRouteUrls();
-
-      _.each(routeUrls, function(route) {
-        this.route(route, route.toString(), function() {
-          var args = Array.prototype.slice.call(arguments),
-          roles = RouteObject.prototype.getRouteRoles(route),
-          authPromise = app.auth.checkAccess(roles);
-
-          authPromise.then(function () {
-            if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
-              that.activeRouteObject = new RouteObject(route, masterLayout, args);
-            }
-
-            var routeObject = that.activeRouteObject;
-            routeObject.routeCallback(route, args);
-            routeObject.renderWith(route, masterLayout, args);
-          }, function () {
-            FauxtonAPI.auth.authDeniedCb();
-          });
-
-        }); 
-      }, this);
-    },
-
-    setModuleRoutes: function() {
-      _.each(modules, function(module) {
-        if (module){
-          _.each(module.RouteObjects, this.addModuleRouteObject, this);
-        }
-      }, this);
-      _.each(LoadAddons.addons, function(module) {
-        if (module){
-          module.initialize();
-          // This is pure routes the addon provides
-          if (module.RouteObjects) {
-            _.each(module.RouteObjects, this.addModuleRouteObject, this);
-          }
-        }
-      }, this);
-    },
-
-    setAddonHooks: function() {
-      _.each(LoadAddons.addons, function(module) {
-        // This is updates to views by the addon
-        if (module && module.hooks){
-          _.each(module.hooks, function(callback, route){
-            if (this.masterLayout.hooks[route]) {
-              this.masterLayout.hooks[route].push(callback);
-            } else {
-              this.masterLayout.hooks[route] = [callback];
-            }
-          }, this);
-        }
-      }, this);
-    },
-
-    initialize: function() {
-      //TODO: It would be nice to handle this with a router
-      this.navBar = app.navBar = new Fauxton.NavBar();
-      this.apiBar = app.apiBar = new Fauxton.ApiBar();
-      this.auth = app.auth = FauxtonAPI.auth;
-      app.session = FauxtonAPI.session;
-
-      app.masterLayout = this.masterLayout = new Layout(this.navBar, this.apiBar);
-      app.footer = new Fauxton.Footer({el: "#footer-content"});
-
-      // NOTE: This must be below creation of the layout
-      // FauxtonAPI header links and others depend on existence of the layout
-      this.setAddonHooks();
-      this.setModuleRoutes();
-
-      $("#app-container").html(this.masterLayout.el);
-      this.masterLayout.render();
-
-      // TODO: move this to a proper Fauxton.View
-      $.when.apply(null, app.footer.establish()).done(function() {
-        app.footer.render();
-      });
-    },
-
-    triggerRouteEvent: function(event, args) {
-      if (this.activeRouteObject) {
-        var eventArgs = [event].concat(args);
-        this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs );
-        this.activeRouteObject.renderWith(eventArgs, this.masterLayout, args);
-      }
-    }
-  });
-
-  return Router;
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/databases/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/item.html b/src/fauxton/app/templates/databases/item.html
deleted file mode 100644
index 32a749a..0000000
--- a/src/fauxton/app/templates/databases/item.html
+++ /dev/null
@@ -1,20 +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.
--->
-
-<td>
-  <a href="#/database/<%= database.get("name") %>/_all_docs?limit=100"><%= database.get("name") %></a>
-</td>
-<td><%= database.status.humanSize() %></td>
-<td><%= database.status.numDocs() %></td>
-<td><%= database.status.updateSeq() %></td>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/databases/list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/list.html b/src/fauxton/app/templates/databases/list.html
deleted file mode 100644
index 808c950..0000000
--- a/src/fauxton/app/templates/databases/list.html
+++ /dev/null
@@ -1,30 +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="result-tools" style="">
-  <form class="navbar-form pull-right database-search">
-    <input type="text" class="search-query" placeholder="Search by database name">
-  </form>
-</div>
-<table class="databases table table-striped">
-  <thead>
-    <th>Name</th>
-    <th>Size</th>
-    <th>Number of Documents</th>
-    <th>Update Seq</th>
-  </thead>
-  <tbody>
-  </tbody>
-</table>
-<div id="database-pagination"></div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/databases/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/sidebar.html b/src/fauxton/app/templates/databases/sidebar.html
deleted file mode 100644
index a8bbd89..0000000
--- a/src/fauxton/app/templates/databases/sidebar.html
+++ /dev/null
@@ -1,31 +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">
-  <a href="http://couchdb.org" target="_blank"><img src="img/couchdblogo.png"/></a>
-  <br/>
-</div>
-<hr>
-<ul class="nav nav-list">
-  <!-- <li class="nav-header">Database types</li> -->
-  <li class="active"><a class="toggle-view" id="owned">Your databases</a></li>
-  <li><a class="btn new" id="new"><i class="icon-plus"></i> New database</a></li>
-</ul>
-<hr>
-
-<div>
-  <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/CouchDB" data-widget-id="314360971646869505">Tweets by @CouchDB</a>
-<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
-
-</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/all_docs_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_item.html b/src/fauxton/app/templates/documents/all_docs_item.html
deleted file mode 100644
index c4c0754..0000000
--- a/src/fauxton/app/templates/documents/all_docs_item.html
+++ /dev/null
@@ -1,26 +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.
--->
-
-<td class="select"><input type="checkbox" class="row-select"></td>
-<td>
-  <div>
-    <pre class="prettyprint"><%= doc.prettyJSON() %></pre>
-    <% if (doc.isEditable()) { %>
-      <div class="btn-group">
-        <a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
-        <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
-      </div>
-    <% } %>
-  </div>
-</td>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_list.html b/src/fauxton/app/templates/documents/all_docs_list.html
deleted file mode 100644
index c0a0d40..0000000
--- a/src/fauxton/app/templates/documents/all_docs_list.html
+++ /dev/null
@@ -1,59 +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="view show">
-  <% if (!viewList) { %>
-    <div class="row">
-      <div class="btn-toolbar span6">
-        <button type="button" class="btn all" data-toggle="button">✓ All</button>
-        <button class="btn btn-small disabled bulk-delete"><i class="icon-trash"></i></button>
-      </div>
-      <!-- TODO::REENABLE
-      <div class="btn-toolbar pull-right">
-        <a href="#new-view-index" class="btn btn-small toggle-edit disabled"><i class="icon-wrench"></i> Edit index</a>
-        <a href="#params" class="btn btn-small toggle-params"><i class="icon-plus"></i> API preview</a>
-      </div>
-      -->
-    </div>
-  <% } %>
-
-  <p>
-    Showing 1-<%= numModels %> of <%= totalRows %> rows
-    <% if (updateSeq) { %>
-      -- Update Sequence: <%= updateSeq %>
-    <% } %>
-    <% if (requestDuration) { %>
-  <span class="view-request-duration">
-    View request duration: <strong> <%= requestDuration %> </strong> 
-   </span>
-   <% } %>
-  </p>
-  <table class="all-docs table table-striped table-condensed">
-    <tbody></tbody>
-  </table>
-  <!--
-  <div class="pagination pagination-centered">
-    <ul>
-      <li class="disabled"><a href="#">&laquo;</a></li>
-      <li class="active"><a href="#">1</a></li>
-      <li><a href="#">2</a></li>
-      <li><a href="#">3</a></li>
-      <li><a href="#">4</a></li>
-      <li><a href="#">5</a></li>
-      <li><a href="#">&raquo;</a></li>
-    </ul>
-  </div>
-  -->
-
-</div>


Mime
View raw message