decode ddoc from route. Fix issue with adding ddoc to collection on save, but not on preview regex fix fixed the regex for sniffing for design docs More encoding for Ddocs
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d33b7dfc Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d33b7dfc Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d33b7dfc Branch: refs/heads/1960-paginate-all_dbs Commit: d33b7dfc880523e7f3ad45bc47a3c8ae0abd5faf Parents: 8c33315 Author: suelockwood <[email protected]> Authored: Mon Dec 23 10:14:36 2013 -0500 Committer: suelockwood <[email protected]> Committed: Mon Dec 23 12:20:29 2013 -0500 ---------------------------------------------------------------------- src/fauxton/app/modules/databases/resources.js | 4 +++- src/fauxton/app/modules/documents/resources.js | 11 +++++++++-- src/fauxton/app/modules/documents/routes.js | 15 +++++++++------ src/fauxton/app/modules/documents/views.js | 12 ++++++++---- .../app/templates/documents/all_docs_item.html | 2 +- 5 files changed, 30 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/d33b7dfc/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 index 2e66176..a01c9ce 100644 --- a/src/fauxton/app/modules/databases/resources.js +++ b/src/fauxton/app/modules/databases/resources.js @@ -84,7 +84,9 @@ function(app, FauxtonAPI, Documents) { this.database = options.database; this.params = options.params; }, - + documentation: function(){ + return "changes"; + }, url: function () { var query = ""; if (this.params) { http://git-wip-us.apache.org/repos/asf/couchdb/blob/d33b7dfc/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 index a171cae..f833ded 100644 --- a/src/fauxton/app/modules/documents/resources.js +++ b/src/fauxton/app/modules/documents/resources.js @@ -26,6 +26,8 @@ function(app, FauxtonAPI) { url: function(context) { if (context === "app") { return this.getDatabase().url("app") + "/" + this.safeID(); + } else if (context === "web-index") { + return this.getDatabase().url("app") + "/" + app.mixins.safeURLName(this.id); } else { return app.host + "/" + this.getDatabase().safeID() + "/" + this.safeID(); } @@ -139,7 +141,12 @@ function(app, FauxtonAPI) { // treated separately. For instance, we could default into the // json editor for docs, or into a ddoc specific page. safeID: function() { - return app.mixins.safeURLName(this.id); + if (this.isDdoc()){ + var ddoc = this.id.replace(/^_design\//,""); + return "_design/"+app.mixins.safeURLName(ddoc); + }else{ + return app.mixins.safeURLName(this.id); + } }, destroy: function() { @@ -209,7 +216,7 @@ function(app, FauxtonAPI) { // treated separately. For instance, we could default into the // json editor for docs, or into a ddoc specific page. safeID: function() { - var ddoc = this.id.replace(/_design\//,""); + var ddoc = this.id.replace(/^_design\//,""); return "_design/"+app.mixins.safeURLName(ddoc); } http://git-wip-us.apache.org/repos/asf/couchdb/blob/d33b7dfc/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 index 4727cdc..56cdc1b 100644 --- a/src/fauxton/app/modules/documents/routes.js +++ b/src/fauxton/app/modules/documents/routes.js @@ -162,7 +162,7 @@ function(app, FauxtonAPI, Documents, Databases) { var docOptions = app.getParams(); docOptions.include_docs = true; - this.databaseName = app.mixins.safeURLName(options[0]); + this.databaseName = options[0]; this.data = { database: new Databases.Model({id:this.databaseName}) @@ -222,19 +222,22 @@ function(app, FauxtonAPI, Documents, Databases) { }, viewFn: function (databaseName, ddoc, view) { - var params = app.getParams(); + var params = app.getParams(), + decodeDdoc = decodeURIComponent(ddoc); view = view.replace(/\?.*$/,''); this.data.indexedDocs = new Documents.IndexCollection(null, { database: this.data.database, - design: ddoc, + design: decodeDdoc, view: view, params: params }); + + var ddocInfo = { - id: "_design/" + ddoc, + id: "_design/" + decodeDdoc, currView: view, designDocs: this.data.designDocs }; @@ -373,7 +376,7 @@ function(app, FauxtonAPI, Documents, Databases) { }, initialize: function (route, masterLayout, options) { - this.databaseName = app.mixins.safeURLName(options[0]); + this.databaseName = options[0]; this.database = new Databases.Model({id: this.databaseName}); var docOptions = app.getParams(); @@ -394,7 +397,7 @@ function(app, FauxtonAPI, Documents, Databases) { }, apiUrl: function() { - return [this.database.changes.url(), this.database.changes.documentation()]; + return [this.database.url(), this.database.documentation()]; } }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/d33b7dfc/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 index 94fe699..96314ad 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -238,10 +238,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum duplicate: function (event) { event.preventDefault(); - var newId = this.$('#dup-id').val(); + var newId = this.$('#dup-id').val(), + encodedID = app.mixins.safeURLName(newId); this.hideModal(); - FauxtonAPI.triggerRouteEvent('duplicateDoc', newId); + FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID); }, _showModal: function () { @@ -1161,6 +1162,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum }, newDesignDoc: function () { + return this.$('#ddoc').val() === 'new-doc'; }, @@ -1175,7 +1177,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum language: "javascript" }; var ddoc = new this.DocModel(doc, {database: this.database}); - this.collection.add(ddoc); + //this.collection.add(ddoc); return ddoc; } else if ( !this.newDesignDoc() ) { var ddocName = this.$('#ddoc').val(); @@ -1303,6 +1305,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum ddoc.setDdocView(viewName, mapVal, reduceVal); ddoc.save().then(function () { + that.ddocs.add(ddoc); + that.mapEditor.editSaved(); that.reduceEditor && that.reduceEditor.editSaved(); @@ -1714,7 +1718,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.collection.each(function(design) { if (design.has('doc')){ - var ddoc = design.id.replace(/_design\//,""); + var ddoc = design.id.replace(/^_design\//,""); if (design.get('doc').views){ this.buildIndexList(design.get('doc').views, "views", ddoc); } http://git-wip-us.apache.org/repos/asf/couchdb/blob/d33b7dfc/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 index c0e61cf..bfedaaa 100644 --- a/src/fauxton/app/templates/documents/all_docs_item.html +++ b/src/fauxton/app/templates/documents/all_docs_item.html @@ -18,7 +18,7 @@ the License. <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> + <a href="#<%= doc.url('web-index') %>" 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> <% } %>
