You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/01/22 15:48:43 UTC
[01/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Updated Branches:
refs/heads/api-options 57035883c -> bd721a537 (forced update)
Fix Makefile
Fix include_docs checked.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d13bff47
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d13bff47
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d13bff47
Branch: refs/heads/api-options
Commit: d13bff47c46d891a07e47c4f792d215a07bba9d8
Parents: e272cbe
Author: suelockwood <de...@apache.org>
Authored: Wed Jan 8 16:45:15 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Wed Jan 8 16:45:15 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 1 -
src/fauxton/app/modules/documents/views.js | 2 +-
src/fauxton/app/templates/databases/item.html | 2 +-
src/fauxton/app/templates/documents/sidebar.html | 2 +-
4 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d13bff47/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 378f82b..12c4fe3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -133,7 +133,6 @@ FAUXTON_FILES = \
fauxton/app/templates/databases/item.html \
fauxton/app/templates/databases/list.html \
fauxton/app/templates/databases/newdatabase.html \
- fauxton/app/templates/databases/sidebar.html \
fauxton/app/templates/documents/all_docs_item.html \
fauxton/app/templates/documents/all_docs_list.html \
fauxton/app/templates/documents/changes.html \
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d13bff47/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 0c75b81..1642f1f 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -1116,7 +1116,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
break;
case "include_docs":
- break;
+ break;
}
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d13bff47/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
index a3712d4..e2f8071 100644
--- a/src/fauxton/app/templates/databases/item.html
+++ b/src/fauxton/app/templates/databases/item.html
@@ -13,7 +13,7 @@ the License.
-->
<td>
- <a href="#/database/<%=encoded%>/_all_docs?limit=<%=docLimit%>&include_docs=false"><%= database.get("name") %></a>
+ <a href="#/database/<%=encoded%>/_all_docs?limit=<%=docLimit%>"><%= database.get("name") %></a>
</td>
<td><%= database.status.humanSize() %></td>
<td><%= database.status.numDocs() %></td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d13bff47/src/fauxton/app/templates/documents/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/sidebar.html b/src/fauxton/app/templates/documents/sidebar.html
index edf3f16..8a73ae9 100644
--- a/src/fauxton/app/templates/documents/sidebar.html
+++ b/src/fauxton/app/templates/documents/sidebar.html
@@ -55,7 +55,7 @@ the License.
<nav>
<ul class="nav nav-list">
- <li class="active"><a id="all-docs" href="#<%= database.url('index') %>?limit=<%= docLimit %>&include_docs=false" class="toggle-view"> All documents</a></li>
+ <li class="active"><a id="all-docs" href="#<%= database.url('index') %>?limit=<%= docLimit %>" class="toggle-view"> All documents</a></li>
<li><a id="design-docs" href='#<%= database.url("index") %>?limit=<%= docLimit %>&startkey="_design"&endkey="_e"' class="toggle-view"> All design docs</a></li>
</ul>
<ul class="nav nav-list views">
[29/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Update the makefile with the refactoring changes for moving documents and databases into addons.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/86ef9eea
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/86ef9eea
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/86ef9eea
Branch: refs/heads/api-options
Commit: 86ef9eea39a8006fd1dd875975b171164c09d5e0
Parents: ae03a97
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 15:15:49 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:15:49 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86ef9eea/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 78bbfac..6666751 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -133,10 +133,15 @@ FAUXTON_FILES = \
fauxton/app/addons/databases/templates/item.html \
fauxton/app/addons/databases/templates/list.html \
fauxton/app/addons/databases/templates/newdatabase.html \
+ fauxton/app/addons/databases/templates/sidebar.html \
+ fauxton/app/addons/documents/templates/advanced_options.html \
fauxton/app/addons/documents/templates/all_docs_item.html \
+ fauxton/app/addons/documents/templates/all_docs_layout.html \
fauxton/app/addons/documents/templates/all_docs_list.html \
+ fauxton/app/addons/documents/templates/all_docs_number.html \
fauxton/app/addons/documents/templates/changes.html \
fauxton/app/addons/documents/templates/ddoc_info.html \
+ fauxton/app/addons/documents/templates/design_doc_selector.html \
fauxton/app/addons/documents/templates/doc.html \
fauxton/app/addons/documents/templates/doc_field_editor.html \
fauxton/app/addons/documents/templates/doc_field_editor_tabs.html \
[50/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Get group_level working
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/bd721a53
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/bd721a53
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/bd721a53
Branch: refs/heads/api-options
Commit: bd721a5371b95aae6bf7d4a09b9e48c26d5a4693
Parents: ab41b1b
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Dec 18 15:45:40 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 22 16:46:43 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/documents/resources.js | 9 ++++++-
.../documents/templates/all_docs_list.html | 6 -----
src/fauxton/app/addons/documents/views.js | 26 ++++++++------------
.../documents/advanced_options_menu.html | 5 ++--
src/fauxton/assets/less/fauxton.less | 4 +++
5 files changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bd721a53/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 831d5e3..4f43243 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -470,8 +470,15 @@ function(app, FauxtonAPI) {
totalRows: function() {
if (this.params.reduce) { return "unknown_reduce";}
+ var total = "unknown";
- return this.viewMeta.total_rows || "unknown";
+ if (this.viewMeta.total_rows) {
+ total = this.viewMeta.total_rows;
+ } else if (this.length > 0) {
+ total = this.length;
+ }
+
+ return total;
},
updateSeq: function() {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bd721a53/src/fauxton/app/addons/documents/templates/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_list.html b/src/fauxton/app/addons/documents/templates/all_docs_list.html
index 335b040..1bad602 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_list.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_list.html
@@ -29,12 +29,6 @@ the License.
<p>
<div id="item-numbers"> </div>
-
- <% 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>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bd721a53/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index fa82076..67fcdd7 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -610,15 +610,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
},
serialize: function() {
- var requestDuration = false;
-
- if (this.collection.requestDurationInString) {
- requestDuration = this.collection.requestDurationInString();
- }
return {
viewList: this.viewList,
- requestDuration: requestDuration,
+ requestDuration: false,
expandDocs: this.expandDocs
};
},
@@ -1044,7 +1039,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
},
updateRows: function (event) {
- console.log('boom', event);
var $groupLevel = this.$('#group-level-label'),
params = {
include_docs: false,
@@ -1063,8 +1057,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
} else {
$groupLevel.hide();
}
-
- console.log(params);
this.eventer.trigger('options:param_update', params);
},
@@ -1072,7 +1064,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
if (params.reduce) {
var $reduce = this.$('#reduce');
$reduce.prop("checked", true);
- this.$('#group-level').show();
+ this.$('#group-level-label').show();
+ this.$('option[value="' + params.group_level + '"]').prop('selected', true);
} else if (params.include_docs) {
var $include_docs = this.$('#include-docs');
@@ -1112,9 +1105,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
this.showPreview = options.showPreview;
}
- if (this.eventer) {
- this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate);
- }
+ this.eventer && this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate);
},
events: {
@@ -1137,12 +1128,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
optionsParamsUpdate: function (params) {
var $form = this.$el.find("form.view-query-update");
+ if (!params.group_level) {
+ this.$("select[name='group_level']").attr('disabled', 'disabled');
+ }
+
if (params.reduce && params.group_level) {
$form.find("select[name='group_level']").val(params.group_level).removeAttr('disabled');
delete params.group_level;
- } else {
- $form.find("select[name='group_level']").attr('disabled');
- }
+ }
+
_.each(params, function(val, key) {
$form.find("input[name='"+key+"']").prop('checked', val);
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bd721a53/src/fauxton/app/templates/documents/advanced_options_menu.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/advanced_options_menu.html b/src/fauxton/app/templates/documents/advanced_options_menu.html
index 9763e4b..ff1783c 100644
--- a/src/fauxton/app/templates/documents/advanced_options_menu.html
+++ b/src/fauxton/app/templates/documents/advanced_options_menu.html
@@ -1,8 +1,9 @@
<div class="row-fluid custom-inputs">
<div class="controls controls-row">
<div class="checkbox inline">
- <input id="include-docs" type="checkbox" name="include_docs" value="true">
- <label for="include_docs">Include Docs</label>
+ <input id="include-docs" type="checkbox" name="include-docs" value="true">
+ <label for="include_docs">
+ Include Docs</label>
</div>
<% if (hasReduce) { %>
<div class="checkbox inline">
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bd721a53/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index e1cfa06..b020f67 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -1000,3 +1000,7 @@ div.spinner {
#delete-database {
float: right;
}
+
+#item-numbers {
+ float: right;
+}
[41/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix for view preview bug with _count
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a09318fa
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a09318fa
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a09318fa
Branch: refs/heads/api-options
Commit: a09318fa85365cf8e4d6718e3c3cb07aba76d990
Parents: c56e5a8
Author: suelockwood <de...@apache.org>
Authored: Thu Jan 16 09:48:42 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Jan 16 09:48:42 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 6 +++---
src/fauxton/app/addons/pouchdb/pouch.collate.js | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a09318fa/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 9902541..bde08f8 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1476,12 +1476,12 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
var promise = FauxtonAPI.Deferred();
- if (!this.database.allDocs) {
+ if (!this.database.allDocs || this.database.allDocs.params.include_docs !== true) {
this.database.buildAllDocs({limit: Databases.DocLimit.toString(), include_docs: true});
promise = this.database.allDocs.fetch();
- } else {
+ } else {
promise.resolve();
- }
+ }
promise.then(function () {
params.docs = that.database.allDocs.map(function (model) { return model.get('doc');});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a09318fa/src/fauxton/app/addons/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/pouch.collate.js b/src/fauxton/app/addons/pouchdb/pouch.collate.js
index 31e5650..8f15808 100644
--- a/src/fauxton/app/addons/pouchdb/pouch.collate.js
+++ b/src/fauxton/app/addons/pouchdb/pouch.collate.js
@@ -110,6 +110,6 @@ function(app, FauxtonAPI, Collate) {
return Pouch;
-}).call(this);
+});
[18/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Rename mixins to utils, add app.host to urls
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3465b04d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3465b04d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3465b04d
Branch: refs/heads/api-options
Commit: 3465b04d696c8d47f4a5ab9ef748bcc93f1c53d8
Parents: 89810cc
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Jan 13 11:09:19 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 13 11:09:19 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/auth/resources.js | 6 +-
.../app/addons/config/assets/less/config.less | 44 ++++
.../app/addons/config/templates/item.html | 2 +-
.../addons/databases/assets/less/databases.less | 247 +++++++++++++++++++
src/fauxton/app/addons/databases/base.js | 2 +-
src/fauxton/app/addons/databases/resources.js | 6 +-
src/fauxton/app/addons/databases/views.js | 8 +-
src/fauxton/app/addons/documents/resources.js | 14 +-
src/fauxton/app/addons/documents/routes.js | 4 +-
src/fauxton/app/addons/documents/views.js | 20 +-
.../app/addons/logs/assets/less/logs.less | 24 ++
src/fauxton/app/addons/permissions/resources.js | 2 +-
.../app/addons/verifyinstall/resources.js | 7 +-
src/fauxton/app/api.js | 2 +-
src/fauxton/app/app.js | 6 +-
src/fauxton/app/helpers.js | 3 +-
src/fauxton/app/mixins.js | 66 -----
src/fauxton/app/resizeColumns.js | 10 +-
src/fauxton/app/utils.js | 66 +++++
src/fauxton/assets/less/config.less | 46 ----
src/fauxton/assets/less/database.less | 245 ------------------
src/fauxton/assets/less/fauxton.less | 3 -
src/fauxton/assets/less/logs.less | 24 --
23 files changed, 425 insertions(+), 432 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
index b1d40cc..970d55b 100644
--- a/src/fauxton/app/addons/auth/resources.js
+++ b/src/fauxton/app/addons/auth/resources.js
@@ -47,7 +47,7 @@ function (app, FauxtonAPI) {
});
Auth.Session = FauxtonAPI.Session.extend({
- url: '/_session',
+ url: app.host + '/_session',
initialize: function (options) {
if (!options) { options = {}; }
@@ -155,7 +155,7 @@ function (app, FauxtonAPI) {
return $.ajax({
cache: false,
type: "POST",
- url: "/_session",
+ url: app.host + "/_session",
dataType: "json",
data: {name: username, password: password}
}).then(function () {
@@ -168,7 +168,7 @@ function (app, FauxtonAPI) {
return $.ajax({
type: "DELETE",
- url: "/_session",
+ url: app.host + "/_session",
dataType: "json",
username : "_",
password : "_"
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 86d9bf1..8495b69 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -1,3 +1,47 @@
+/* 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.
+ */
+
+.config-item {
+ height: 41px;
+
+ .edit-button {
+ float: right;
+ .btn;
+ .btn-mini;
+ display:none;
+ }
+
+ td:hover .edit-button {
+ display: block;
+ }
+
+ .value-input {
+ width: 98%;
+ }
+
+ #delete-value {
+ cursor: pointer;
+ }
+}
+
+.button-margin {
+ margin-bottom: 15px;
+}
+
+#add-section-modal {
+ width: 400px;
+}
+
table.config {
#config-trash {
width: 5%;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/config/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html
index 3e6e4ee..1c808b9 100644
--- a/src/fauxton/app/addons/config/templates/item.html
+++ b/src/fauxton/app/addons/config/templates/item.html
@@ -20,7 +20,7 @@ the License.
<td> <%= option.name %> </td>
<td>
<div id="show-value">
- <%= option.value %> <button class="edit-button"> Edit </button>
+ <%= option.value %> <button class="edit-button btn-mini btn"> Edit </button>
</div>
<div id="edit-value-form" style="display:none">
<input class="value-input" type="text" value="<%= option.value %>" />
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/databases/assets/less/databases.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/assets/less/databases.less b/src/fauxton/app/addons/databases/assets/less/databases.less
new file mode 100644
index 0000000..3d86d81
--- /dev/null
+++ b/src/fauxton/app/addons/databases/assets/less/databases.less
@@ -0,0 +1,247 @@
+/* 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.
+ */
+
+/* =database
+ ---------------------------------------------------------------------- */
+@import "../../../../../assets/less/bootstrap/variables.less";
+@import "../../../../../assets/less/bootstrap/mixins.less";
+#db-tools {
+ position: absolute;
+ top: -7px;
+ right: 0;
+ width: 390px;
+
+ .btn-group {
+ position: absolute;
+ left: 0;
+ top: 6px;
+ }
+
+ form {
+ position: absolute;
+ right: 0;
+ top: 0;
+ }
+}
+
+.tools .nav {
+ margin-bottom: 10px;
+}
+
+#sidenav {
+ padding-top: 10px;
+
+ h3 {
+ margin: 10px 0;
+ }
+
+ li a span.divider {
+ background: none;
+ color: #ccc;
+ padding: 0 2px;
+ }
+
+ li.nav-header a {
+ display: inline
+ }
+
+ div.btn-group {
+ display: inline-block;
+ }
+
+ li.nav-header, #sidenav li a {
+ padding-left: 4px;
+ }
+
+ li.active a {
+ background-color: #ddd;
+ color: #333;
+ text-shadow: none;
+ }
+}
+
+.edit {
+ display: none;
+
+ form {
+ margin-bottom: 0;
+ }
+
+ h3 {
+ border-bottom: 1px solid #ccc;
+ font-size: 100%;
+ line-height: 1;
+ margin-bottom: 18px;
+ }
+
+ textarea {
+ height: 100px;
+ width: 95%;
+ }
+
+ .btn-toolbar {
+ margin-bottom: 0;
+ }
+
+ .preview {
+ width: 100px;
+ }
+
+ .save {
+ }
+}
+
+#new-view-index {
+ .confirm {
+ display: none;
+ }
+
+ .confirm .progress {
+ display: none;
+ margin: 20px;
+ }
+
+ textarea {
+ height: 100px;
+ width: 95%;
+ }
+}
+
+.view {
+ display: none;
+
+ .result-tools {
+ float: left;
+ width: 100%;
+ margin-bottom: 10px;
+ }
+
+ table td div {
+ position: relative;
+ }
+
+ table td div div {
+ display: none;
+ line-height: 1;
+ position: absolute;
+ right: 4px;
+ top: 4px;
+ }
+
+ table td div:hover div a.edits {
+ padding-left: 16px;
+ padding-right: 16px;
+ }
+
+ table td div:hover div {
+ display: block;
+ }
+
+}
+.view.show {
+ display: block;
+}
+.view.show.hidden-by-params {
+ display: none;
+}
+#database .view table tr td {
+ padding: 0;
+}
+
+.loading {display: none;}
+
+.view-request-duration {
+ padding-right: 10px;
+ float: right;
+}
+
+table.active-tasks{
+ th {
+ cursor: pointer;
+ }
+}
+
+.well{
+ .row-fluid{
+ margin: 0;
+ }
+ .row-fluid .row-fluid:last-child .well-item {
+ border: none;
+ }
+ .well-item{
+ color: #666;
+ font-size: 12px;
+ border-bottom: 1px solid #e5e5e5;
+ padding: 8px 4px;
+ strong {
+ font-size: 16px;
+ }
+ }
+}
+
+
+#doc {
+ .dropdown-menu{
+ width: auto;
+ }
+}
+// #tabs {
+// height: 40px;
+// }
+
+.databases{
+ a.db-actions,
+ a.db-actions:visited{
+ color: @red;
+ border: 1px solid #e3e3e3;
+ padding: 5px 7px;
+ .border-radius(6px);
+ text-decoration: none;
+ font-size: 19px;
+ }
+}
+.btn-group{
+ ul.dropdown-menu li a:before{
+ margin-right: 10px;
+ }
+}
+
+.design-doc-group{
+ .span3 { margin: 0;}
+ #new-ddoc-section {
+ margin-top: 10px;
+ label{ width: 100px}
+ .controls{
+ margin-left: 100px;
+ }
+ }
+}
+table#changes-table {
+
+ #changes {
+ width: 50%;
+ }
+
+ #seq, #deleted {
+ width: 5%;
+ }
+
+}
+
+.doc-editor-buttons {
+ margin-bottom: 15px;
+ a.button.btn-large.gray {
+ padding: 9px 10px;
+ vertical-align: middle;
+ }
+}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/databases/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/base.js b/src/fauxton/app/addons/databases/base.js
index 1a3dc66..ea1719c 100644
--- a/src/fauxton/app/addons/databases/base.js
+++ b/src/fauxton/app/addons/databases/base.js
@@ -28,7 +28,7 @@ function(app, FauxtonAPI, Databases, Views) {
// Utility functions
Databases.databaseUrl = function(database) {
var name = _.isObject(database) ? database.id : database,
- dbname = app.mixins.safeURLName(name);
+ dbname = app.utils.safeURLName(name);
return ["/database/", dbname, "/_all_docs?limit=" + Databases.DocLimit].join('');
};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js
index b6d6536..3510154 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -67,10 +67,10 @@ function(app, FauxtonAPI, Documents) {
}
},
safeName: function(){
- return app.mixins.safeURLName(this.get("name"));
+ return app.utils.safeURLName(this.get("name"));
},
safeID: function() {
- return app.mixins.safeURLName(this.id);
+ return app.utils.safeURLName(this.id);
},
buildChanges: function (params) {
this.changes = new Databases.Changes({
@@ -182,7 +182,7 @@ function(app, FauxtonAPI, Documents) {
// TODO: pagination!
return _.map(resp, function(database) {
return {
- id: app.mixins.safeURLName(database),
+ id: app.utils.safeURLName(database),
name: database
};
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js
index 80d64ed..0068305 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -29,7 +29,7 @@ function(app, Components, FauxtonAPI, Databases) {
},
serialize: function() {
return {
- encoded: app.mixins.safeURLName(this.model.get("name")),
+ encoded: app.utils.safeURLName(this.model.get("name")),
database: this.model,
docLimit: Databases.DocLimit
};
@@ -77,11 +77,11 @@ function(app, Components, FauxtonAPI, Databases) {
dbname = selectedName;
}
- if (dbname && this.collection.where({"id":app.mixins.safeURLName(dbname)}).length > 0){
+ if (dbname && this.collection.where({"id":app.utils.safeURLName(dbname)}).length > 0){
// TODO: switch to using a model, or Databases.databaseUrl()
// Neither of which are in scope right now
// var db = new Database.Model({id: dbname});
- var url = ["/database/", app.mixins.safeURLName(dbname), "/_all_docs?limit=" + Databases.DocLimit].join('');
+ var url = ["/database/", app.utils.safeURLName(dbname), "/_all_docs?limit=" + Databases.DocLimit].join('');
FauxtonAPI.navigate(url);
} else {
FauxtonAPI.addNotification({
@@ -173,7 +173,7 @@ function(app, Components, FauxtonAPI, Databases) {
type: "success",
clear: true
});
- var route = "#/database/" + app.mixins.safeURLName(name) + "/_all_docs?limit=" + Databases.DocLimit;
+ var route = "#/database/" + app.utils.safeURLName(name) + "/_all_docs?limit=" + Databases.DocLimit;
app.router.navigate(route, { trigger: true });
}
).error(function(xhr) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 5254302..5e10ded 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -27,7 +27,7 @@ function(app, FauxtonAPI) {
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);
+ return this.getDatabase().url("app") + "/" + app.utils.safeURLName(this.id);
} else if (context === "apiurl"){
return window.location.origin + "/" + this.getDatabase().safeID() + "/" + this.safeID();
} else {
@@ -143,9 +143,9 @@ function(app, FauxtonAPI) {
safeID: function() {
if (this.isDdoc()){
var ddoc = this.id.replace(/^_design\//,"");
- return "_design/"+app.mixins.safeURLName(ddoc);
+ return "_design/"+app.utils.safeURLName(ddoc);
}else{
- return app.mixins.safeURLName(this.id);
+ return app.utils.safeURLName(this.id);
}
},
@@ -219,7 +219,7 @@ function(app, FauxtonAPI) {
// json editor for docs, or into a ddoc specific page.
safeID: function() {
var ddoc = this.id.replace(/^_design\//,"");
- return "_design/"+app.mixins.safeURLName(ddoc);
+ return "_design/"+app.utils.safeURLName(ddoc);
}
});
@@ -247,7 +247,7 @@ function(app, FauxtonAPI) {
return this.docType() != "reduction";
},
safeID: function() {
- return app.mixins.safeURLName(this.id);
+ return app.utils.safeURLName(this.id);
},
prettyJSON: function() {
@@ -423,8 +423,8 @@ function(app, FauxtonAPI) {
} else if (context === "apiurl"){
startOfUrl = window.location.origin;
}
- var design = app.mixins.safeURLName(this.design),
- view = app.mixins.safeURLName(this.view);
+ var design = app.utils.safeURLName(this.design),
+ view = app.utils.safeURLName(this.view);
var url = [startOfUrl, this.database.safeID(), "_design", design, this.idxType, view];
return url.join("/") + query;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js
index d120feb..6786edf 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -92,7 +92,7 @@ function(app, FauxtonAPI, Documents, Databases) {
doc.copy(newId).then(function () {
doc.set({_id: newId});
docView.forceRender();
- FauxtonAPI.navigate('/database/' + database.safeID() + '/' + app.mixins.safeURLName(newId), {trigger: true});
+ FauxtonAPI.navigate('/database/' + database.safeID() + '/' + app.utils.safeURLName(newId), {trigger: true});
FauxtonAPI.addNotification({
msg: "Document has been duplicated."
});
@@ -259,7 +259,7 @@ function(app, FauxtonAPI, Documents, Databases) {
ddocInfo: ddocInfo
}));
- this.sidebar.setSelectedTab(app.mixins.removeSpecialCharacters(ddoc) + '_' + app.mixins.removeSpecialCharacters(view));
+ this.sidebar.setSelectedTab(app.utils.removeSpecialCharacters(ddoc) + '_' + app.utils.removeSpecialCharacters(view));
this.crumbs = function () {
return [
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 97d58e3..80c0d87 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -241,7 +241,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
duplicate: function (event) {
event.preventDefault();
var newId = this.$('#dup-id').val(),
- encodedID = app.mixins.safeURLName(newId);
+ encodedID = app.utils.safeURLName(newId);
this.hideModal();
FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID);
@@ -423,11 +423,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
index: this.index,
ddoc: this.ddoc,
database: this.database,
- index_clean: app.mixins.removeSpecialCharacters(this.index),
- ddoc_clean: app.mixins.removeSpecialCharacters(this.ddoc),
- index_encoded: app.mixins.safeURLName(this.index),
- ddoc_encoded: app.mixins.safeURLName(this.ddoc),
- database_encoded: app.mixins.safeURLName(this.database),
+ index_clean: app.utils.removeSpecialCharacters(this.index),
+ ddoc_clean: app.utils.removeSpecialCharacters(this.ddoc),
+ index_encoded: app.utils.safeURLName(this.index),
+ ddoc_encoded: app.utils.safeURLName(this.ddoc),
+ database_encoded: app.utils.safeURLName(this.database),
selected: this.selected
};
},
@@ -470,7 +470,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
return {
- database: app.mixins.safeURLName(this.collection.database.id),
+ database: app.utils.safeURLName(this.collection.database.id),
updateSeq: updateSeq,
offset: recordStart,
totalRows: totalRows,
@@ -1365,7 +1365,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
if (that.newView) {
- var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.mixins.safeURLName(viewName);
+ var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.utils.safeURLName(viewName);
FauxtonAPI.navigate(fragment, {trigger: false});
that.newView = false;
@@ -1375,7 +1375,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
that.showIndex = true;
that.render();
FauxtonAPI.triggerRouteEvent('reloadDesignDocs', {
- selectedTab: app.mixins.removeSpecialCharacters(ddocName.replace(/_design\//,'')) + '_' + app.mixins.removeSpecialCharacters(viewName)
+ selectedTab: app.utils.removeSpecialCharacters(ddocName.replace(/_design\//,'')) + '_' + app.utils.removeSpecialCharacters(viewName)
});
}
@@ -1675,7 +1675,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
jumpToDoc: function (event) {
event.preventDefault();
var docId = this.$('#jump-to-doc-id').val().trim();
- FauxtonAPI.navigate('/database/' + app.mixins.safeURLName(this.database.id) +'/' + app.mixins.safeURLName(docId), {trigger: true});
+ FauxtonAPI.navigate('/database/' + app.utils.safeURLName(this.database.id) +'/' + app.utils.safeURLName(docId), {trigger: true});
},
afterRender: function () {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/logs/assets/less/logs.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/assets/less/logs.less b/src/fauxton/app/addons/logs/assets/less/logs.less
new file mode 100644
index 0000000..e50f903
--- /dev/null
+++ b/src/fauxton/app/addons/logs/assets/less/logs.less
@@ -0,0 +1,24 @@
+/* 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.
+ */
+
+#log-sidebar {
+
+ ul {
+ margin-left: 0px;
+ list-style: none;
+ }
+
+ .remove-filter {
+ opacity: 0.2;
+ }
+}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/permissions/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/resources.js b/src/fauxton/app/addons/permissions/resources.js
index 66eaffd..8acaddd 100644
--- a/src/fauxton/app/addons/permissions/resources.js
+++ b/src/fauxton/app/addons/permissions/resources.js
@@ -39,7 +39,7 @@ function (app, FauxtonAPI ) {
},
url: function () {
- return this.database.id + '/_security';
+ return app.host + this.database.id + '/_security';
},
addItem: function (value, type, section) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/addons/verifyinstall/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/resources.js b/src/fauxton/app/addons/verifyinstall/resources.js
index 8a98883..aa08997 100644
--- a/src/fauxton/app/addons/verifyinstall/resources.js
+++ b/src/fauxton/app/addons/verifyinstall/resources.js
@@ -130,7 +130,7 @@ function (app, FauxtonAPI, Databases, Documents) {
setupReplicate: function () {
return $.ajax({
- url: '/_replicate',
+ url: app.host + '/_replicate',
contentType: 'application/json',
type: 'POST',
dataType: 'json',
@@ -145,11 +145,6 @@ function (app, FauxtonAPI, Databases, Documents) {
testReplicate: function () {
var deferred = FauxtonAPI.Deferred();
- /*var dbReplicate = new Databases.Model({
- id: 'verifytestdb_replicate',
- name: 'verifytestdb_replicate'
- });*/
-
var promise = dbReplicate.fetch();
promise.then(function () {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index c9d08bf..f423ef5 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -132,7 +132,7 @@ function(app, Fauxton) {
});
FauxtonAPI.Session = Backbone.Model.extend({
- url: '/_session',
+ url: app.host + '/_session',
user: function () {
var userCtx = this.get('userCtx');
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 9ac5bc2..5325f77 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -21,7 +21,7 @@ define([
"bootstrap",
"helpers",
- "mixins",
+ "utils",
// Modules
"resizeColumns",
@@ -31,7 +31,7 @@ define([
],
-function(app, $, _, Backbone, Bootstrap, Helpers, Mixins, resizeColumns) {
+function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns) {
// Make sure we have a console.log
if (typeof console == "undefined") {
@@ -43,7 +43,7 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Mixins, resizeColumns) {
// Provide a global location to place configuration settings and module
// creation also mix in Backbone.Events
_.extend(app, Backbone.Events, {
- mixins: Mixins,
+ utils: Utils,
renderView: function(baseView, selector, view, options, callback) {
baseView.setView(selector, new view(options)).render().then(callback);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/helpers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
index 73a37ca..d4836b9 100644
--- a/src/fauxton/app/helpers.js
+++ b/src/fauxton/app/helpers.js
@@ -48,7 +48,8 @@ function() {
"_active_tasks": "http://docs.couchdb.org/en/latest/api/server/common.html?highlight=stats#active-tasks",
"log": "http://docs.couchdb.org/en/latest/api/server/common.html?highlight=stats#log",
"config": "http://docs.couchdb.org/en/latest/config/index.html",
- "views": "http://docs.couchdb.org/en/latest/intro/overview.html#views"
+ "views": "http://docs.couchdb.org/en/latest/intro/overview.html#views",
+ "changes": "http://docs.couchdb.org/en/latest/api/database/changes.html?highlight=changes#post--db-_changes"
};
Helpers.getDocUrl = function(docKey){
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/mixins.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/mixins.js b/src/fauxton/app/mixins.js
deleted file mode 100644
index 3679ec1..0000000
--- a/src/fauxton/app/mixins.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-
-define([
- "jquery",
- "lodash"
-],
-
-function($, _ ) {
-
- var mixins = {};
-
- var onWindowResize = {};
-
- mixins.addWindowResize = function(fun, key){
- onWindowResize[key]=fun;
- // You shouldn't need to call it here. Just define it at startup and each time it will loop
- // through all the functions in the hash.
- //app.initWindowResize();
- };
-
- mixins.removeWindowResize = function(key){
- delete onWindowResize[key];
- mixins.initWindowResize();
- };
-
- mixins.initWindowResize = function(){
- //when calling this it should be overriding what was called previously
- window.onresize = function(e) {
- // could do this instead of the above for loop
- _.each(onWindowResize, function (fn) {
- fn();
- });
- };
- };
-
- mixins.removeSpecialCharacters = function(name){
- return name.replace(/[^\w\s]/gi,"");
- };
-
- mixins.safeURLName = function(name){
- var testName = name || "";
- var checkforBad = testName.match(/[\$\-/_,+-]/g);
- return (checkforBad !== null)?encodeURIComponent(name):name;
- };
-
- return mixins;
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/resizeColumns.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/resizeColumns.js b/src/fauxton/app/resizeColumns.js
index 9cf7115..bb50767 100644
--- a/src/fauxton/app/resizeColumns.js
+++ b/src/fauxton/app/resizeColumns.js
@@ -18,10 +18,10 @@
// "purely functional" helper system.
define([
- "mixins"
+ "utils"
],
-function(mixins) {
+function(utils) {
var Resize = function(options){
this.options = options;
@@ -42,8 +42,8 @@ function(mixins) {
var that = this;
//add throttler :)
this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this);
- mixins.addWindowResize(this.lazyLayout,"animation");
- mixins.initWindowResize();
+ utils.addWindowResize(this.lazyLayout,"animation");
+ utils.initWindowResize();
this.onResizeHandler();
},
updateOptions:function(options){
@@ -52,7 +52,7 @@ function(mixins) {
this.options.selectorElements = options.selectorElements || ".window-resizeable";
},
turnOff:function(){
- mixins.removeWindowResize("animation");
+ utils.removeWindowResize("animation");
},
cleanupCallback: function(){
this.callback = null;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/app/utils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/utils.js b/src/fauxton/app/utils.js
new file mode 100644
index 0000000..ded7dac
--- /dev/null
+++ b/src/fauxton/app/utils.js
@@ -0,0 +1,66 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+// This file creates a set of helper functions that will be loaded for all html
+// templates. These functions should be self contained and not rely on any
+// external dependencies as they are loaded prior to the application. We may
+// want to change this later, but for now this should be thought of as a
+// "purely functional" helper system.
+
+
+define([
+ "jquery",
+ "lodash"
+],
+
+function($, _ ) {
+
+ var utils = {};
+
+ var onWindowResize = {};
+
+ utils.addWindowResize = function(fun, key){
+ onWindowResize[key]=fun;
+ // You shouldn't need to call it here. Just define it at startup and each time it will loop
+ // through all the functions in the hash.
+ //app.initWindowResize();
+ };
+
+ utils.removeWindowResize = function(key){
+ delete onWindowResize[key];
+ utils.initWindowResize();
+ };
+
+ utils.initWindowResize = function(){
+ //when calling this it should be overriding what was called previously
+ window.onresize = function(e) {
+ // could do this instead of the above for loop
+ _.each(onWindowResize, function (fn) {
+ fn();
+ });
+ };
+ };
+
+ utils.removeSpecialCharacters = function(name){
+ return name.replace(/[^\w\s]/gi,"");
+ };
+
+ utils.safeURLName = function(name){
+ var testName = name || "";
+ var checkforBad = testName.match(/[\$\-/_,+-]/g);
+ return (checkforBad !== null)?encodeURIComponent(name):name;
+ };
+
+ return utils;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/config.less b/src/fauxton/assets/less/config.less
deleted file mode 100644
index fe03796..0000000
--- a/src/fauxton/assets/less/config.less
+++ /dev/null
@@ -1,46 +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.
- */
-
-.config-item {
- height: 41px;
-
- .edit-button {
- float: right;
- .btn;
- .btn-mini;
- display:none;
- }
-
- td:hover .edit-button {
- display: block;
- }
-
- .value-input {
- width: 98%;
- }
-
- #delete-value {
- cursor: pointer;
- }
-}
-
-.button-margin {
- margin-bottom: 15px;
-}
-
-#add-section-modal {
- width: 400px;
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/assets/less/database.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/database.less b/src/fauxton/assets/less/database.less
deleted file mode 100644
index 377b136..0000000
--- a/src/fauxton/assets/less/database.less
+++ /dev/null
@@ -1,245 +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.
- */
-
-/* =database
- ---------------------------------------------------------------------- */
-#db-tools {
- position: absolute;
- top: -7px;
- right: 0;
- width: 390px;
-
- .btn-group {
- position: absolute;
- left: 0;
- top: 6px;
- }
-
- form {
- position: absolute;
- right: 0;
- top: 0;
- }
-}
-
-.tools .nav {
- margin-bottom: 10px;
-}
-
-#sidenav {
- padding-top: 10px;
-
- h3 {
- margin: 10px 0;
- }
-
- li a span.divider {
- background: none;
- color: #ccc;
- padding: 0 2px;
- }
-
- li.nav-header a {
- display: inline
- }
-
- div.btn-group {
- display: inline-block;
- }
-
- li.nav-header, #sidenav li a {
- padding-left: 4px;
- }
-
- li.active a {
- background-color: #ddd;
- color: #333;
- text-shadow: none;
- }
-}
-
-.edit {
- display: none;
-
- form {
- margin-bottom: 0;
- }
-
- h3 {
- border-bottom: 1px solid #ccc;
- font-size: 100%;
- line-height: 1;
- margin-bottom: 18px;
- }
-
- textarea {
- height: 100px;
- width: 95%;
- }
-
- .btn-toolbar {
- margin-bottom: 0;
- }
-
- .preview {
- width: 100px;
- }
-
- .save {
- }
-}
-
-#new-view-index {
- .confirm {
- display: none;
- }
-
- .confirm .progress {
- display: none;
- margin: 20px;
- }
-
- textarea {
- height: 100px;
- width: 95%;
- }
-}
-
-.view {
- display: none;
-
- .result-tools {
- float: left;
- width: 100%;
- margin-bottom: 10px;
- }
-
- table td div {
- position: relative;
- }
-
- table td div div {
- display: none;
- line-height: 1;
- position: absolute;
- right: 4px;
- top: 4px;
- }
-
- table td div:hover div a.edits {
- padding-left: 16px;
- padding-right: 16px;
- }
-
- table td div:hover div {
- display: block;
- }
-
-}
-.view.show {
- display: block;
-}
-.view.show.hidden-by-params {
- display: none;
-}
-#database .view table tr td {
- padding: 0;
-}
-
-.loading {display: none;}
-
-.view-request-duration {
- padding-right: 10px;
- float: right;
-}
-
-table.active-tasks{
- th {
- cursor: pointer;
- }
-}
-
-.well{
- .row-fluid{
- margin: 0;
- }
- .row-fluid .row-fluid:last-child .well-item {
- border: none;
- }
- .well-item{
- color: #666;
- font-size: 12px;
- border-bottom: 1px solid #e5e5e5;
- padding: 8px 4px;
- strong {
- font-size: 16px;
- }
- }
-}
-
-
-#doc {
- .dropdown-menu{
- width: auto;
- }
-}
-// #tabs {
-// height: 40px;
-// }
-
-.databases{
- a.db-actions,
- a.db-actions:visited{
- color: @red;
- border: 1px solid #e3e3e3;
- padding: 5px 7px;
- .border-radius(6px);
- text-decoration: none;
- font-size: 19px;
- }
-}
-.btn-group{
- ul.dropdown-menu li a:before{
- margin-right: 10px;
- }
-}
-
-.design-doc-group{
- .span3 { margin: 0;}
- #new-ddoc-section {
- margin-top: 10px;
- label{ width: 100px}
- .controls{
- margin-left: 100px;
- }
- }
-}
-table#changes-table {
-
- #changes {
- width: 50%;
- }
-
- #seq, #deleted {
- width: 5%;
- }
-
-}
-
-.doc-editor-buttons {
- margin-bottom: 15px;
- a.button.btn-large.gray {
- padding: 9px 10px;
- vertical-align: middle;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index 510c3c1..d41780a 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -19,10 +19,7 @@
@import "bootstrap/bootstrap.less";
@import "bootstrap/mixins.less";
@import "variables.less";
-@import "config.less";
-@import "logs.less";
@import "prettyprint.less";
-@import "database.less";
@import "icons.less";
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3465b04d/src/fauxton/assets/less/logs.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/logs.less b/src/fauxton/assets/less/logs.less
deleted file mode 100644
index e50f903..0000000
--- a/src/fauxton/assets/less/logs.less
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#log-sidebar {
-
- ul {
- margin-left: 0px;
- list-style: none;
- }
-
- .remove-filter {
- opacity: 0.2;
- }
-}
[36/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
made couchserver configurable via settings.json
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ad3edf81
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ad3edf81
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ad3edf81
Branch: refs/heads/api-options
Commit: ad3edf811182045b69d5e400be34b1f0133e3e3e
Parents: 42c4493
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Tue Jan 14 14:27:27 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 15 09:01:19 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ad3edf81/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 49b52a4..cf70440 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -112,6 +112,28 @@ module.exports = function(grunt) {
return settings.template || defaultSettings;
}();
+ var couchserver_config = function () {
+ // add a "couchserver" key to settings.json with JSON that matches the
+ // keys and values below (plus your customizations) to have Fauxton work
+ // against a remote CouchDB-compatible server.
+ var defaults = {
+ dist: './dist/debug/',
+ port: 8000,
+ proxy: {
+ target: {
+ host: 'localhost',
+ port: 5984,
+ https: false
+ },
+ // This sets the Host header in the proxy so that you can use external
+ // CouchDB instances and not have the Host set to 'localhost'
+ changeOrigin: true
+ }
+ };
+
+ return helper.readSettingsFile().couchserver || defaults;
+ }();
+
grunt.initConfig({
// The clean task ensures all files are removed from the dist/ directory so
@@ -223,20 +245,7 @@ module.exports = function(grunt) {
},
// Runs a proxy server for easier development, no need to keep deploying to couchdb
- couchserver: {
- dist: './dist/debug/',
- port: 8000,
- proxy: {
- target: {
- host: 'localhost',
- port: 5984,
- https: false
- },
- // This sets the Host header in the proxy so that you can use external
- // CouchDB instances and not have the Host set to 'localhost'
- changeOrigin: true
- }
- },
+ couchserver: couchserver_config,
watch: {
js: {
[30/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix so that you can edit view docs, but not delete them
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/61d06177
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/61d06177
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/61d06177
Branch: refs/heads/api-options
Commit: 61d061771adbfd8d3023e38a46225dea46701e3c
Parents: 86ef9ee
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 15:27:21 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:27:21 2014 -0500
----------------------------------------------------------------------
.../app/addons/documents/templates/index_row_docular.html | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/61d06177/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
index f1b2217..446a031 100644
--- a/src/fauxton/app/addons/documents/templates/index_row_docular.html
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -17,11 +17,13 @@ the License.
<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>
+ <% if (doc.isEditable()) { %>
+ <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
+ <% } %>
</div>
- <% } %>
+
</div>
</td>
[25/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Remove unused templates
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/bea8c6d1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/bea8c6d1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/bea8c6d1
Branch: refs/heads/api-options
Commit: bea8c6d16b753d89fd0452eecb7d2bb766a3a06e
Parents: b71c719
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 14:45:31 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 14:46:00 2014 -0500
----------------------------------------------------------------------
.../app/templates/layouts/one_pane_notabs.html | 27 --------------------
.../templates/layouts/with_right_sidebar.html | 26 -------------------
2 files changed, 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bea8c6d1/src/fauxton/app/templates/layouts/one_pane_notabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/one_pane_notabs.html b/src/fauxton/app/templates/layouts/one_pane_notabs.html
deleted file mode 100644
index f58661f..0000000
--- a/src/fauxton/app/templates/layouts/one_pane_notabs.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div id="primary-navbar"></div>
-<div id="dashboard" class="container-fluid one-pane">
- <div class="fixed-header">
- <div id="breadcrumbs"></div>
- <div id="api-navbar"></div>
- </div>
-
-
- <div class="row-fluid content-area">
- <div id="dashboard-content" class="window-resizeable"></div>
- </div>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bea8c6d1/src/fauxton/app/templates/layouts/with_right_sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/with_right_sidebar.html b/src/fauxton/app/templates/layouts/with_right_sidebar.html
deleted file mode 100644
index ade5b82..0000000
--- a/src/fauxton/app/templates/layouts/with_right_sidebar.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.
--->
-
-<div id="primary-navbar"></div>
-<div id="dashboard" class="container-fluid">
- <div class="fixed-header">
- <div id="breadcrumbs"></div>
- <div id="api-navbar"></div>
- </div>
- <div class="with-sidebar-right content-area">
- <div id="dashboard-content" class="list"></div>
- <div id="sidebar-content" class="sidebar pull-right window-resizeable"></div>
- </div>
-</div>
-
[08/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Removing debugging code
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3cd4bc5a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3cd4bc5a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3cd4bc5a
Branch: refs/heads/api-options
Commit: 3cd4bc5a0dbfad7ddfe1dc59c7757fdc32cb03bd
Parents: a749ecb
Author: suelockwood <de...@apache.org>
Authored: Fri Jan 10 09:56:45 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Fri Jan 10 09:57:09 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/modules/documents/views.js | 15 ---------------
1 file changed, 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3cd4bc5a/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 ec1b5d2..78cbbb8 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -1767,26 +1767,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}, this);
},
- addNewSidebarItem: function(key, selector, design){
- console.log(args, "sidebarupdate");
- // var selected = this.ddocID == "_design/"+design;
- // var view = this.insertView("ul.nav.views", new Views.IndexItem({
- // ddoc: design,
- // index: key,
- // database: this.collection.database.id,
- // selected: selected && key == this.currView
- // }));
- // if (render !== false) {
- // view.render();
- // }
- },
afterRender: function () {
if (this.selectedTab) {
this.setSelectedTab(this.selectedTab);
}
-
- this.listenTo(this.collection, "add", this.addNewSidebarItem);
},
setSelectedTab: function (selectedTab) {
[13/50] [abbrv] Fauxton: move modules to addons
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/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 1422241..0000000
--- a/src/fauxton/app/modules/fauxton/layout.js
+++ /dev/null
@@ -1,98 +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
- },
- afterRender: function(){
-
- }
- });
-
- 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/89810cce/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 ee323a7..0000000
--- a/src/fauxton/app/modules/pouchdb/base.js
+++ /dev/null
@@ -1,47 +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.
- */
-
-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/89810cce/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/89810cce/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/89810cce/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index e3a1636..7cf69ad 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -25,27 +25,14 @@ define([
"api",
// Modules
- "modules/fauxton/base",
+ "addons/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",
+ "addons/fauxton/layout",
"load_addons"
],
-function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents, Pouch, LoadAddons) {
-
- // TODO: auto generate this list if possible
- var modules = [Databases, Documents];
+function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, LoadAddons) {
var beforeUnloads = {};
@@ -106,11 +93,6 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents
},
setModuleRoutes: function() {
- _.each(modules, function(module) {
- if (module){
- _.each(module.RouteObjects, this.addModuleRouteObject, this);
- }
- }, this);
_.each(LoadAddons.addons, function(module) {
if (module){
module.initialize();
@@ -122,21 +104,6 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents
}, 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();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index ad7e6b5..cb09eb2 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -1,5 +1,8 @@
{
"deps": [
+ { "name": "databases" },
+ { "name": "documents" },
+ { "name": "pouchdb" },
{ "name": "activetasks" },
{ "name": "config" },
{ "name": "logs" },
[22/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Regex fix for creating (from duplicate) Design docs and deleting weirdly encoded docs what begin with _design
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/2e4d72bd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2e4d72bd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2e4d72bd
Branch: refs/heads/api-options
Commit: 2e4d72bd66a5c0bf2e1779178ce9855870a9ffd5
Parents: 86b6a14
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 12:05:24 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 12:05:24 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/resources.js | 2 +-
src/fauxton/app/addons/documents/views.js | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/2e4d72bd/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 5e10ded..0fd99f1 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -56,7 +56,7 @@ function(app, FauxtonAPI) {
},
docType: function() {
- return this.id.match(/^_design/) ? "design doc" : "doc";
+ return this.id && this.id.match(/^_design\//) ? "design doc" : "doc";
},
isEditable: function() {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/2e4d72bd/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 94332a2..2502b58 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -242,7 +242,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
duplicate: function (event) {
event.preventDefault();
var newId = this.$('#dup-id').val(),
- encodedID = app.utils.safeURLName(newId);
+ isDDoc = newId.match(/^_design\//),
+ removeDDocID = newId.replace(/^_design\//,""),
+ encodedID = isDDoc? "_design/"+ app.utils.safeURLName(removeDDocID):app.utils.safeURLName(newId);
this.hideModal();
FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID);
[32/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix for the link to edit docs on reductions
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e5cac792
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e5cac792
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e5cac792
Branch: refs/heads/api-options
Commit: e5cac79282b7a631b969b59f9647b3a3dd47c37b
Parents: afd66a9
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 16:19:29 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 16:19:29 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/resources.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e5cac792/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 0fd99f1..831d5e3 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -238,8 +238,6 @@ function(app, FauxtonAPI) {
return "docs";
},
url: function(context) {
- if (!this.isEditable()) return false;
-
return this.collection.database.url(context) + "/" + this.safeID();
},
@@ -247,7 +245,9 @@ function(app, FauxtonAPI) {
return this.docType() != "reduction";
},
safeID: function() {
- return app.utils.safeURLName(this.id);
+ var id = this.id || this.get("id");
+
+ return app.utils.safeURLName(id);
},
prettyJSON: function() {
[14/50] [abbrv] Fauxton: move modules to addons
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/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 435ed5e..0000000
--- a/src/fauxton/app/modules/documents/routes.js
+++ /dev/null
@@ -1,409 +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) {
-
- var DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "one_pane",
- disableLoader: true,
- selectedHeader: "Databases",
- initialize: function(route, masterLayout, options) {
- var databaseName = options[0];
- this.docID = options[1]||'new';
-
- this.database = this.database || new Databases.Model({id: databaseName});
- this.doc = new Documents.Doc({
- _id: this.docID
- }, {
- database: this.database
- });
-
- this.tabsView = this.setView("#tabs", new Documents.Views.FieldEditorTabs({
- disableLoader: true,
- selected: "code_editor",
- model: this.doc
- }));
-
- },
-
- routes: {
- // We are hiding the field_editor for this first release
- // "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": 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.safeID() + '/' + app.mixins.safeURLName(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("apiurl"), this.doc.documentation()];
- }
- });
-
- 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
- }));
-
- },
- crumbs: function() {
- return [
- {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
- {"name": "New", "link": "#"}
- ];
- },
- routes: {
- "database/:database/new": "code_editor"
- },
- selectedHeader: "Databases",
-
- });
-
- var DocumentsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_tabs_sidebar",
- selectedHeader: "Databases",
- 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",
- "route:paginate": "paginate"
- },
-
- 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
- }));
- },
-
- establish: function () {
- return this.data.designDocs.fetch();
- },
-
- allDocs: function(databaseName, options) {
- var docOptions = app.getParams(options);
-
- 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.toolsView = this.setView("#dashboard-upper-menu", new Documents.Views.JumpToDoc({
- database: this.data.database,
- collection: this.data.database.allDocs
- }));
-
- this.setView("#dashboard-upper-content", new Documents.Views.AllDocsLayout({
- database: this.data.database,
- collection: this.data.database.allDocs,
- params: docOptions
- }));
-
- this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- collection: this.data.database.allDocs
- }));
-
- this.crumbs = [
- {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
- ];
-
- this.apiUrl = [this.data.database.allDocs.url("apiurl"), this.data.database.allDocs.documentation() ];
- },
-
- viewFn: function (databaseName, ddoc, view) {
- var params = app.getParams(),
- decodeDdoc = decodeURIComponent(ddoc);
-
- view = view.replace(/\?.*$/,'');
-
- this.data.indexedDocs = new Documents.IndexCollection(null, {
- database: this.data.database,
- design: decodeDdoc,
- view: view,
- params: params
- });
-
- var ddocInfo = {
- id: "_design/" + decodeDdoc,
- 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
- }));
-
- if (this.toolsView) { this.toolsView.remove(); }
-
- 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(app.mixins.removeSpecialCharacters(ddoc) + '_' + app.mixins.removeSpecialCharacters(view));
-
- this.crumbs = function () {
- return [
- {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)},
- ];
- };
-
- this.apiUrl = [this.data.indexedDocs.url("apiurl"), "docs"];
- },
-
- newViewEditor: function () {
- var params = app.getParams();
-
- if (this.toolsView) {
- this.toolsView.remove();
- }
-
- 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');
- this.crumbs = function () {
- return [
- {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)},
- ];
- };
- },
-
- updateAllDocsFromView: function (event) {
- var view = event.view,
- docOptions = app.getParams(),
- ddoc = event.ddoc;
-
- this.documentsView && this.documentsView.remove();
-
- if (event.allDocs) {
- this.data.database.buildAllDocs(docOptions);
- this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- collection: this.data.database.allDocs
- }));
- return;
- }
-
- 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
- }));
- },
-
- paginate: function (direction) {
- _.extend(this.documentsView.collection.params, app.getParams());
- this.documentsView.forceRender();
- if (direction === 'next') {
- this.documentsView.collection.skipFirstItem = true;
- } else {
- this.documentsView.collection.skipFirstItem = false;
- }
- },
-
- reloadDesignDocs: function (event) {
- this.sidebar.forceRender();
-
- if (event && event.selectedTab) {
- this.sidebar.setSelectedTab(event.selectedTab);
- }
- }
-
- });
-
- var ChangesRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_tabs",
- selectedHeader: "Databases",
- crumbs: function () {
- return [
- {"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.url("apiurl"), this.database.documentation()];
- }
-
- });
-
- Documents.RouteObjects = [DocEditorRouteObject, NewDocEditorRouteObject, DocumentsRouteObject, ChangesRouteObject];
-
- return Documents;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/tests/resourcesSpec.js b/src/fauxton/app/modules/documents/tests/resourcesSpec.js
deleted file mode 100644
index e848221..0000000
--- a/src/fauxton/app/modules/documents/tests/resourcesSpec.js
+++ /dev/null
@@ -1,84 +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([
- 'modules/documents/resources',
- 'testUtils'
-], function (Models, testUtils) {
- var assert = testUtils.assert;
-
- describe('IndexCollection', function () {
- var collection;
- beforeEach(function () {
- collection = new Models.IndexCollection([{
- id:'myId1',
- doc: 'num1'
- },
- {
- id:'myId2',
- doc: 'num2'
- }], {
- database: {id: 'databaseId', safeID: function () { return this.id; }},
- design: '_design/myDoc'
- });
-
- });
-
- it('Should return urlNext', function () {
- var url = collection.urlNextPage(20);
-
- assert.equal(url, 'database/databaseId/_design/myDoc/_view/?limit=21&reduce=false&startkey_docid=myId2&startkey=');
-
- });
-
- it('Should return urlPrevious', function () {
- var url = collection.urlPreviousPage(20, {limit: 21, reduce: false, startkey_docid: "myId1",startkey:"myId1"} );
-
- assert.equal(url, 'database/databaseId/_design/myDoc/_view/?limit=20&reduce=false&startkey_docid=myId1&startkey=myId1');
-
- });
-
- });
-
- describe('AllDocs', function () {
- var collection;
- beforeEach(function () {
- collection = new Models.AllDocs([{
- _id:'myId1',
- doc: 'num1'
- },
- {
- _id:'myId2',
- doc: 'num2'
- }], {
- database: {id: 'databaseId', safeID: function () { return this.id; }},
- params: {limit: 20}
- });
-
- });
-
- it('Should return urlNext', function () {
- var url = collection.urlNextPage(20);
-
- assert.equal(url, 'database/databaseId/_all_docs?limit=21&startkey_docid=%22myId2%22&startkey=%22myId2%22');
-
- });
-
- it('Should return urlPrevious', function () {
- var url = collection.urlPreviousPage(20, {limit: 21, startkey_docid: "myId1",startkey:"myId1"} );
- assert.equal(url, 'database/databaseId/_all_docs?limit=20&startkey_docid=myId1&startkey=myId1');
- });
-
-
- });
-
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/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 59aba01..0000000
--- a/src/fauxton/app/modules/documents/views.js
+++ /dev/null
@@ -1,1855 +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/fauxton/components",
-
- "modules/documents/resources",
- "modules/databases/resources",
- "modules/pouchdb/base",
-
- // Libs
- "resizeColumns",
-
- // Plugins
- "plugins/prettify"
-
-],
-
-function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns) {
- 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=' + Databases.DocLimit,
- };
- },
-
- 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; }
- FauxtonAPI.addNotification({
- msg: "Deleting your database...",
- type: "error"
- });
- return this.database.destroy().done(function () {
- app.router.navigate('#/_all_dbs', {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",
-
- disableLoader: true,
-
- initialize: function (options) {
- _.bindAll(this);
- },
-
- events: {
- "click a#upload-btn": "uploadFile"
- },
-
- uploadFile: function (event) {
- event.preventDefault();
-
- var docRev = this.model.get('_rev'),
- that = this,
- $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 (resp) {
- console.log('ERR on upload', resp);
- return that.set_error_msg('Could not upload document: ' + JSON.parse(resp.responseText).reason);
- }
- });
- },
-
- 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();
- $('.modal-backdrop').remove();
- }, 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(),
- encodedID = app.mixins.safeURLName(newId);
-
- this.hideModal();
- FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID);
- },
-
- _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: {
- },
- 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",
- "dblclick pre.prettyprint": "edit"
- },
-
- attributes: function() {
- return {
- "data-id": this.model.id
- };
- },
-
- serialize: function() {
- return {
- doc: this.model
- };
- },
-
- establish: function() {
- return [this.model.fetch()];
- },
-
- edit: function(event) {
- event.preventDefault();
- FauxtonAPI.navigate("#" + this.model.url('app'));
- },
-
- 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(function () {
- that.remove();
- });
-
- that.model.collection.remove(that.model.id);
- if (!!that.model.id.match('_design')) {
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
- }
- }, 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",
-
- events: {
- "click button.delete": "destroy"
- },
-
- destroy: function (event) {
- event.preventDefault();
-
- window.alert('Cannot delete a document generated from a view.');
- },
-
- 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,
- index_clean: app.mixins.removeSpecialCharacters(this.index),
- ddoc_clean: app.mixins.removeSpecialCharacters(this.ddoc),
- index_encoded: app.mixins.safeURLName(this.index),
- ddoc_encoded: app.mixins.safeURLName(this.ddoc),
- database_encoded: app.mixins.safeURLName(this.database),
- selected: this.selected
- };
- },
-
- afterRender: function() {
- if (this.selected) {
- $("#sidenav ul.nav-list li").removeClass("active");
- this.$el.addClass("active");
- }
- }
- });
-
- Views.AllDocsNumber = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_number",
-
- initialize: function (options) {
- this.newView = options.newView || false;
- this.showNumbers = options.showNumbers;
- this.pagination = options.pagination;
-
- this.listenTo(this.collection, 'totalRows:decrement', this.render);
- },
-
- serialize: function () {
- var totalRows = 0,
- recordStart = 0,
- updateSeq = false,
- pageStart = 0,
- pageEnd = 20;
-
- if (!this.newView) {
- totalRows = this.collection.totalRows();
- updateSeq = this.collection.updateSeq();
- }
-
- recordStart = this.collection.recordStart();
- if (this.pagination) {
- pageStart = this.pagination.pageStart();
- pageEnd = this.pagination.pageEnd();
- }
-
- return {
- database: app.mixins.safeURLName(this.collection.database.id),
- updateSeq: updateSeq,
- offset: recordStart,
- totalRows: totalRows,
- showNumbers: this.showNumbers,
- numModels: this.collection.models.length + recordStart - 1,
- pageStart: pageStart,
- pageEnd: pageEnd
- };
- }
-
- });
-
- Views.AllDocsLayout = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_layout",
- className: "row",
-
- initialize: function (options) {
- this.database = options.database;
- this.params = options.params;
- },
-
- events: {
- 'click #toggle-query': "toggleQuery"
- },
-
- toggleQuery: function (event) {
- $('#dashboard-content').scrollTop(0);
- this.$('#query').toggle('fast');
- },
-
- beforeRender: function () {
- this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
- updateViewFn: this.updateAllDocs,
- previewFn: this.previewView,
- hasReduce: false,
- showPreview: false,
- database: this.database
- }));
-
- this.$('#query').hide();
- },
-
- afterRender: function () {
- if (this.params) {
- this.advancedOptions.updateFromParams(this.params);
- }
-
- },
-
- updateAllDocs: function (event, paramInfo) {
- event.preventDefault();
-
- var 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: ".advanced-options .errors-container"
- });
- });
- FauxtonAPI.addNotification({
- msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
- type: "warning",
- selector: ".advanced-options .errors-container"
- });
-
- return false;
- }
-
- var fragment = window.location.hash.replace(/\?.*$/, '');
- fragment = fragment + '?' + $.param(params);
- FauxtonAPI.navigate(fragment, {trigger: false});
-
- FauxtonAPI.triggerRouteEvent('updateAllDocs', {allDocs: true});
- },
-
- previewView: function (event) {
- event.preventDefault();
- }
-
- });
-
- // 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",
- "click #collapse": "collapse",
- "change .row-select":"toggleTrash"
- },
-
- toggleTrash: function () {
- if (this.$('.row-select:checked').length > 0) {
- this.$('.bulk-delete').removeClass('disabled');
- } else {
- this.$('.bulk-delete').addClass('disabled');
- }
- },
-
- 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;
- this.expandDocs = true;
- },
-
- establish: function() {
- if (this.newView) { return null; }
-
- return this.collection.fetch({reset: true}).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){
- $('.all-docs').find("input:checkbox").prop('checked', !$(evt.target).hasClass('active')).trigger('change');
- },
-
- serialize: function() {
- var requestDuration = false;
-
- if (this.collection.requestDurationInString) {
- requestDuration = this.collection.requestDurationInString();
- }
-
- return {
- viewList: this.viewList,
- requestDuration: requestDuration,
- expandDocs: this.expandDocs
- };
- },
-
- collapse: function (event) {
- event.preventDefault();
-
- if (this.expandDocs) {
- this.expandDocs = false;
- } else {
- this.expandDocs = true;
- }
-
- this.render();
- },
-
- /*
- * 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 (eles.length === 0 || !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(function () {
- $(this).remove();
- });
-
- model.collection.remove(model.id);
- if (!!model.id.match('_design')) {
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
- }
- that.$('.bulk-delete').addClass('disabled');
- }, function(resp) {
- FauxtonAPI.addNotification({
- msg: "Failed to destroy your doc!",
- type: "error"
- });
- });
- }, this);
- },
-
- addPagination: function () {
- var collection = this.collection;
- var perPage = function () {
- if (collection.params.limit && collection.skipFirstItem) {
- return parseInt(collection.params.limit, 10) - 1;
- } else if (collection.params.limit) {
- return parseInt(collection.params.limit, 10);
- }
-
- return 20;
- };
-
- this.pagination = new Components.IndexPagination({
- collection: this.collection,
- scrollToSelector: '#dashboard-content',
- previousUrlfn: function () {
- return collection.urlPreviousPage(perPage(), this.previousParams.pop());
- },
- canShowPreviousfn: function () {
- if (this.previousParams.length === 0) {
- return false;
- }
-
- return true;
- },
- canShowNextfn: function () {
- if (collection.length < (perPage() -1)) {
- return false;
- }
-
- return true;
- },
-
- nextUrlfn: function () {
- return collection.urlNextPage(perPage());
- }
- });
- },
-
- cleanup: function () {
- //if (!this.pagination) { return; }
- this.pagination.remove();
- //this.pagination = null;
- this.allDocsNumber.remove();
- _.each(this.rows, function (row) {row.remove();});
- },
-
- beforeRender: function() {
- var showNumbers = true;
-
- if (!this.pagination) {
- this.addPagination();
- }
-
- this.insertView('#documents-pagination', this.pagination);
-
- if (this.designDocs || this.collection.idxType === '_view' || this.collection.params.startkey === '"_design"') {
- showNumbers = false;
- }
-
- this.allDocsNumber = this.setView('#item-numbers', new Views.AllDocsNumber({
- collection: this.collection,
- newView: this.newView,
- showNumbers: showNumbers,
- pagination: this.pagination
- }));
-
- var docs = this.expandDocs ? this.collection : this.collection.simple();
-
- docs.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",
- "click button.delete": "destroy",
- "click button.duplicate": "duplicate",
- "click button.upload": "upload",
- "click button.cancel-button": "goback"
- },
- disableLoader: true,
- initialize: function (options) {
- this.database = options.database;
- _.bindAll(this);
- },
- goback: function(){
- FauxtonAPI.navigate(this.database.url("index") + "?limit=100");
- },
- destroy: function(event) {
- if (this.model.isNewDoc()) {
- FauxtonAPI.addNotification({
- msg: 'This document has not been saved yet.',
- type: 'warning'
- });
- return;
- }
-
- 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) {
- if (this.model.isNewDoc()) {
- FauxtonAPI.addNotification({
- msg: 'Please save the document before duplicating it.',
- type: 'warning'
- });
- return;
- }
- event.preventDefault();
- this.duplicateModal.showModal();
- },
-
- 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() {
- var promise = this.model.fetch(),
- databaseId = this.database.safeID(),
- deferred = $.Deferred(),
- that = this;
-
- promise.then(function () {
- deferred.resolve();
- }, function (xhr, reason, msg) {
- if (xhr.status === 404) {
- FauxtonAPI.addNotification({
- msg: 'The document does not exist',
- type: 'error',
- clear: true
- });
- that.goback();
- }
- deferred.reject();
- });
-
- return deferred;
- },
-
- saveDoc: function(event) {
- var json, notification,
- that = this,
- editor = this.editor,
- validDoc = this.getDocFromEditor();
-
- if (validDoc) {
- this.getDocFromEditor();
-
- notification = FauxtonAPI.addNotification({msg: "Saving document."});
-
- this.model.save().then(function () {
- editor.editSaved();
- FauxtonAPI.navigate('/database/' + that.database.safeID() + '/' + that.model.id);
- }).fail(function(xhr) {
-
- var responseText = JSON.parse(xhr.responseText).reason;
- notification = FauxtonAPI.addNotification({
- msg: "Save failed: " + responseText,
- type: "error",
- clear: true,
- selector: "#doc .errors-container"
- });
- });
- } else if(this.model.validationError && this.model.validationError === 'Cannot change a documents id.') {
- notification = FauxtonAPI.addNotification({
- msg: "Cannot save: " + 'Cannot change a documents _id, try Duplicate doc instead!',
- type: "error",
- selector: "#doc .errors-container"
- });
- delete this.model.validationError;
- } 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().set(json, {validate: true});
- if (this.model.validationError) {
- return false;
- }
-
- return this.model;
- },
-
- hasValidCode: function() {
- var errors = this.editor.getAnnotations();
- return errors.length === 0;
- },
-
- 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() {
- var saveDoc = this.saveDoc;
-
- this.editor = new Components.Editor({
- editorId: "editor-container",
- commands: [{
- name: 'save',
- bindKey: {win: 'Ctrl-S', mac: 'Ctrl-S'},
- exec: function(editor) {
- saveDoc();
- },
- readOnly: true // false if this command should not apply in readOnly mode
- }]
- });
- this.editor.render();
- this.model.on("sync", this.updateValues, this);
- },
-
- cleanup: function () {
- if (this.editor) this.editor.remove();
- }
- });
-
- Views.DocFieldEditor = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor",
- disableLoader: true,
- 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()];
- }
- });
-
- Views.AdvancedOptions = FauxtonAPI.View.extend({
- template: "templates/documents/advanced_options",
- className: "advanced-options well",
-
- initialize: function (options) {
- this.database = options.database;
- this.ddocName = options.ddocName;
- this.viewName = options.viewName;
- this.updateViewFn = options.updateViewFn;
- this.previewFn = options.previewFn;
- //this.hadReduce = options.hasReduce || true;
-
- if (typeof(options.hasReduce) === 'undefined') {
- this.hasReduce = true;
- } else {
- this.hasReduce = options.hasReduce;
- }
-
- if (typeof(options.showPreview) === 'undefined') {
- this.showPreview = true;
- } else {
- this.showPreview = options.showPreview;
- }
- },
-
- events: {
- "change form.view-query-update input": "updateFilters",
- "change form.view-query-update select": "updateFilters",
- "submit form.view-query-update": "updateView",
- "click button.preview": "previewView"
- },
-
- beforeRender: function () {
- if (this.viewName && this.ddocName) {
- var buttonViews = FauxtonAPI.getExtensions('advancedOptions:ViewButton');
- _.each(buttonViews, function (view) {
- this.insertView('#button-options', view);
- view.update(this.database, this.ddocName, this.viewName);
- }, this);
- }
- },
-
- renderOnUpdatehasReduce: function (hasReduce) {
- this.hasReduce = hasReduce;
- this.render();
- },
-
- queryParams: function () {
- var $form = this.$(".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};
- },
-
- 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;
- }
- },
-
- updateFromParams: function (params) {
- var $form = this.$el.find("form.view-query-update");
- _.each(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);
- },
-
- updateView: function (event) {
- this.updateViewFn(event, this.queryParams());
- },
-
- previewView: function (event) {
- this.previewFn(event, this.queryParams());
- },
-
- serialize: function () {
- return {
- hasReduce: this.hasReduce,
- showPreview: this.showPreview
- };
- }
- });
-
- Views.DesignDocSelector = FauxtonAPI.View.extend({
- template: "templates/documents/design_doc_selector",
-
- events: {
- "change select#ddoc": "updateDesignDoc"
- },
-
- initialize: function (options) {
- this.ddocName = options.ddocName;
- this.database = options.database;
- this.listenTo(this.collection, 'add', this.ddocAdded);
- this.DocModel = options.DocModel || Documents.Doc;
- },
-
- ddocAdded: function (ddoc) {
- this.ddocName = ddoc.id;
- this.render();
- },
-
- serialize: function () {
- return {
- ddocName: this.ddocName,
- ddocs: this.collection
- };
- },
-
- updateDesignDoc: function () {
- if (this.newDesignDoc()) {
- this.$('#new-ddoc-section').show();
- } else {
- this.$('#new-ddoc-section').hide();
- }
- },
-
- newDesignDoc: function () {
-
- return this.$('#ddoc').val() === 'new-doc';
- },
-
- newDocValidation: function(){
- return this.newDesignDoc() && this.$('#new-ddoc').val()==="";
- },
- getCurrentDesignDoc: function () {
- if (this.newDesignDoc()) {
- var doc = {
- _id: '_design/' + this.$('#new-ddoc').val(),
- views: {},
- language: "javascript"
- };
- var ddoc = new this.DocModel(doc, {database: this.database});
- //this.collection.add(ddoc);
- return ddoc;
- } else if ( !this.newDesignDoc() ) {
- var ddocName = this.$('#ddoc').val();
- return this.collection.find(function (ddoc) {
- return ddoc.id === ddocName;
- }).dDocModel();
- }
- }
- });
-
- Views.ViewEditor = FauxtonAPI.View.extend({
- template: "templates/documents/view_editor",
- builtinReduces: ['_sum', '_count', '_stats'],
-
- events: {
- "click button.save": "saveView",
- "click button.delete": "deleteView",
- "change select#reduce-function-selector": "updateReduce",
- "click button.preview": "previewView",
- "click #db-views-tabs-nav": 'toggleIndexNav'
- },
-
- 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});
- }
-
- this.showIndex = false;
- _.bindAll(this);
- },
-
- establish: function () {
- if (this.ddocInfo) {
- return this.ddocInfo.fetch();
- }
- },
-
- 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") {
- this.createReduceEditor();
- this.reduceEditor.setValue(this.langTemplates.javascript.reduce);
- $reduceContainer.show();
- } else {
- $reduceContainer.hide();
- }
- },
-
- 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.safeID() + '/_all_docs?limit=' + Databases.DocLimit);
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
- });
- },
-
- saveView: function(event) {
- var json, notification,
- that = this;
-
- if (event) { event.preventDefault();}
-
- $('#dashboard-content').scrollTop(0); //scroll up
-
- if (this.hasValidCode() && this.$('#new-ddoc:visible').val() !=="") {
- 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",
- clear: true
- });
-
- ddoc.setDdocView(viewName, mapVal, reduceVal);
-
- ddoc.save().then(function () {
- that.ddocs.add(ddoc);
-
- that.mapEditor.editSaved();
- that.reduceEditor && that.reduceEditor.editSaved();
-
- FauxtonAPI.addNotification({
- msg: "View has been saved.",
- type: "success",
- selector: "#define-view .errors-container",
- clear: true
- });
-
- if (that.newView) {
- var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.mixins.safeURLName(viewName);
-
- FauxtonAPI.navigate(fragment, {trigger: false});
- that.newView = false;
- that.ddocID = ddoc.safeID();
- that.viewName = viewName;
- that.ddocInfo = ddoc;
- that.showIndex = true;
- that.render();
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs', {
- selectedTab: app.mixins.removeSpecialCharacters(ddocName.replace(/_design\//,'')) + '_' + app.mixins.removeSpecialCharacters(viewName)
- });
- }
-
- if (that.reduceFunStr !== reduceVal) {
- that.reduceFunStr = reduceVal;
- that.advancedOptions.renderOnUpdatehasReduce(that.hasReduce());
- }
-
- 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 {
- var errormessage = (this.$('#new-ddoc:visible').val() ==="")?"Enter a design doc name":"Please fix the Javascript errors and try again.";
- notification = FauxtonAPI.addNotification({
- msg: errormessage,
- type: "error",
- selector: "#define-view .errors-container",
- clear: true
- });
- }
- },
-
- updateView: function(event, paramInfo) {
- event.preventDefault();
-
- if (this.newView) { return alert('Please save this new view before querying it.'); }
-
- var 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: ".advanced-options .errors-container",
- clear: true
- });
- });
- FauxtonAPI.addNotification({
- msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
- type: "warning",
- selector: ".advanced-options .errors-container",
- clear: true
- });
-
- 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});
- },
-
-
- previewView: function(event, paramsInfo) {
- event.preventDefault();
- var that = this,
- mapVal = this.mapVal(),
- reduceVal = this.reduceVal(),
- paramsArr = [];
-
- if (paramsInfo && paramsInfo.params) {
- paramsArr = paramsInfo.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: ".advanced-options .errors-container",
- fade: true
- });
-
- var promise = FauxtonAPI.Deferred();
-
- if (!this.database.allDocs) {
- this.database.buildAllDocs({limit: Databases.DocLimit.toString(), 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});
- });
- });
- },
-
- getCurrentDesignDoc: function () {
- return this.designDocSelector.getCurrentDesignDoc();
- },
-
- isCustomReduceEnabled: function() {
- return $("#reduce-function-selector").val() == "CUSTOM";
- },
-
- mapVal: function () {
- if (this.mapEditor) {
- return this.mapEditor.getValue();
- }
-
- return this.$('#map-function').text();
- },
-
- 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;
- }
- return editor.hadValidCode();
- }, this);
- },
-
- toggleIndexNav: function (event) {
- var $targetId = this.$(event.target).attr('id'),
- $previousTab = this.$(this.$('li.active a').attr('href')),
- $targetTab = this.$(this.$(event.target).attr('href'));
-
- if ($targetTab.attr('id') !== $previousTab.attr('id')) {
- $previousTab.removeAttr('style');
- }
-
- if ($targetId === 'index-nav') {
- if (this.newView) { return; }
- var that = this;
- $('#dashboard-content').scrollTop(0); //scroll up
- $targetTab.toggle('slow', function(){
- that.showEditors();
- });
- } else {
- $targetTab.toggle('slow');
- }
- },
-
- serialize: function() {
- return {
- ddocs: this.ddocs,
- ddoc: this.model,
- ddocName: this.model.id,
- viewName: this.viewName,
- reduceFunStr: this.reduceFunStr,
- isCustomReduce: this.hasCustomReduce(),
- newView: this.newView,
- langTemplates: this.langTemplates.javascript
- };
- },
-
- hasCustomReduce: function() {
- return this.reduceFunStr && ! _.contains(this.builtinReduces, this.reduceFunStr);
- },
-
- hasReduce: function () {
- return this.reduceFunStr || false;
- },
-
- createReduceEditor: function () {
- if (this.reduceEditor) {
- this.reduceEditor.remove();
- }
-
- this.reduceEditor = new Components.Editor({
- editorId: "reduce-function",
- mode: "javascript",
- couchJSHINT: true
- });
- this.reduceEditor.render();
- },
-
- 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 {
- var ddocDecode = decodeURIComponent(this.ddocID);
- this.model = this.ddocs.get(ddocDecode).dDocModel();
- this.reduceFunStr = this.model.viewHasReduce(this.viewName);
- this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
- }
-
- this.designDocSelector = this.setView('.design-doc-group', new Views.DesignDocSelector({
- collection: this.ddocs,
- ddocName: this.model.id,
- database: this.database
- }));
-
- this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
- updateViewFn: this.updateView,
- previewFn: this.previewView,
- database: this.database,
- viewName: this.viewName,
- ddocName: this.model.id,
- hasReduce: this.hasReduce()
- }));
- },
-
- afterRender: function() {
- if (this.params) {
- this.advancedOptions.updateFromParams(this.params);
- }
-
- this.designDocSelector.updateDesignDoc();
- if (this.newView || this.showIndex) {
- this.showEditors();
- this.showIndex = false;
- } else {
- this.$('#index').hide();
- this.$('#index-nav').parent().removeClass('active');
- }
- },
-
- showEditors: function () {
- this.mapEditor = new Components.Editor({
- editorId: "map-function",
- mode: "javascript",
- couchJSHINT: true
- });
- this.mapEditor.render();
-
- if (this.hasCustomReduce()) {
- this.createReduceEditor();
- } else {
- $(".control-group.reduce-function").hide();
- }
-
- if (this.newView) {
- this.mapEditor.setValue(this.langTemplates[this.defaultLang].map);
- //Use a built in view by default
- //this.reduceEditor.setValue(this.langTemplates[this.defaultLang].reduce);
- }
-
- this.mapEditor.editSaved();
- this.reduceEditor && this.reduceEditor.editSaved();
- },
-
- cleanup: function () {
- this.mapEditor && this.mapEditor.remove();
- this.reduceEditor && this.reduceEditor.remove();
- }
- });
-
- Views.JumpToDoc = FauxtonAPI.View.extend({
- template: "templates/documents/jumpdoc",
-
- initialize: function (options) {
- this.database = options.database;
- },
-
- events: {
- "submit #jump-to-doc": "jumpToDoc"
- },
-
- jumpToDoc: function (event) {
- event.preventDefault();
- var docId = this.$('#jump-to-doc-id').val().trim();
- FauxtonAPI.navigate('/database/' + app.mixins.safeURLName(this.database.id) +'/' + app.mixins.safeURLName(docId), {trigger: true});
- },
-
- afterRender: function () {
- this.typeAhead = new Components.DocSearchTypeahead({el: '#jump-to-doc-id', database: this.database});
- this.typeAhead.render();
- }
- });
-
- Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/documents/sidebar",
- events: {
- "click button#delete-database": "deleteDatabase"
- },
-
- initialize: function(options) {
- this.database = options.database;
- if (options.ddocInfo) {
- this.ddocID = options.ddocInfo.id;
- this.currView = options.ddocInfo.currView;
- }
- },
-
- deleteDatabase: function (event) {
- event.preventDefault();
-
- var result = confirm('Are you sure you want to delete this database?');
-
- if (!result) { return; }
- var databaseName = this.database.id;
- FauxtonAPI.addNotification({
- msg: "Deleting your database...",
- type: "error",
- clear: true
- });
-
- this.database.destroy().then(function () {
- FauxtonAPI.navigate('#/_all_dbs');
- FauxtonAPI.addNotification({
- msg: 'The database ' + databaseName + ' has been deleted.',
- clear: true
- });
- }).fail(function (rsp, error, msg) {
- FauxtonAPI.addNotification({
- msg: 'Could not delete the database, reason ' + msg + '.',
- type: 'error',
- clear: true
- });
- });
- },
-
- serialize: function() {
- var docLinks = FauxtonAPI.getExtensions('docLinks'),
- newLinks = FauxtonAPI.getExtensions('sidebar:newLinks'),
- addLinks = FauxtonAPI.getExtensions('sidebar:links'),
- extensionList = FauxtonAPI.getExtensions('sidebar:list');
- return {
- changes_url: '#' + this.database.url('changes'),
- permissions_url: '#' + this.database.url('app') + '/permissions',
- db_url: '#' + this.database.url('index') + '?limit=' + Databases.DocLimit,
- database: this.collection.database,
- database_url: '#' + this.database.url('app'),
- docLinks: docLinks,
- docLimit: Databases.DocLimit,
- addLinks: addLinks,
- newLinks: newLinks,
- extensionList: extensionList > 0
- };
- },
-
- 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) {
-
- var sidebarListViews = FauxtonAPI.getExtensions('sidebar:list');
- _.each(sidebarListViews, function (view) {
- var extension = this.insertView('#extension-navs', view);
- extension.update(this.database, this.collection, this.viewName);
- extension.render();
- }, this);
-
-
- this.collection.each(function(design) {
- if (design.has('doc')){
- var ddoc = design.id.replace(/^_design\//,"");
- 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/89810cce/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 cf6305c..0000000
--- a/src/fauxton/app/modules/fauxton/base.js
+++ /dev/null
@@ -1,275 +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",
- "resizeColumns"
-
-],
-
-function(app, Backbone, resizeColumns) {
-
- //resizeAnimation
- app.resizeColumns = new resizeColumns({});
- app.resizeColumns.onResizeHandler();
-
- 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({
- className:"navbar",
- template: "templates/fauxton/nav_bar",
- // TODO: can we generate this list from the router?
- navLinks: [
- {href:"#/_all_dbs", title:"Databases", icon: "fonticon-database", className: 'databases'}
- ],
-
- bottomNavLinks: [],
- footerNavLinks: [],
-
- serialize: function() {
- return {
- navLinks: this.navLinks,
- bottomNavLinks: this.bottomNavLinks,
- footerNavLinks: this.footerNavLinks
- };
- },
-
- addLink: function(link) {
- // link.top means it gets pushed to the top of the array,
- // link.bottomNav means it goes to the additional bottom nav
- // link.footerNav means goes to the footer nav
- if (link.top && !link.bottomNav){
- this.navLinks.unshift(link);
- } else if (link.top && link.bottomNav){
- this.bottomNavLinks.unshift(link);
- } else if (link.bottomNav) {
- this.bottomNavLinks.push(link);
- } else if (link.footerNav) {
- this.footerNavLinks.push(link);
- } else {
- this.navLinks.push(link);
- }
-
- //this.trigger("link:add");
-
- //this.render();
- },
-
- removeLink: function (removeLink) {
- var links = this.navlinks;
-
- if (removeLink.bottomNav) {
- links = this.bottomNavLinks;
- } else if (removeLink.footerNav) {
- links = this.footerNavLinks;
- }
-
- var foundIndex = -1;
-
- _.each(links, function (link, index) {
- if (link.title === removeLink.title) {
- foundIndex = index;
- }
- });
-
- if (foundIndex === -1) {return;}
- links.splice(foundIndex, 1);
- this.render();
- },
-
- afterRender: function(){
-
- $('#primary-navbar li[data-nav-name="' + app.selectedHeader + '"]').addClass('active');
-
- var menuOpen = true;
- var $selectorList = $('body');
- $('.brand').off();
- $('.brand').on({
- click: function(e){
- if(!$(e.target).is('a')){
- toggleMenu();
- }
- }
- });
-
- function toggleMenu(){
- $selectorList.toggleClass('closeMenu');
- menuOpen = $selectorList.hasClass('closeMenu');
- app.resizeColumns.onResizeHandler();
- }
-
- $('#primary-navbar').on("click", ".nav a", function(){
- if (!($selectorList.hasClass('closeMenu'))){
- setTimeout(
- function(){
- $selectorList.addClass('closeMenu');
- app.resizeColumns.onResizeHandler();
- },3000);
-
- }
- });
-
- app.resizeColumns.initialize();
- },
-
- beforeRender: function () {
- this.addLinkViews();
- },
-
- addLinkViews: function () {
- var that = this;
-
- _.each(_.union(this.navLinks, this.bottomNavLinks), function (link) {
- if (!link.view) { return; }
-
- //TODO check if establish is a function
- var establish = link.establish || [];
- $.when.apply(null, establish).then( function () {
- var selector = link.bottomNav ? '#bottom-nav-links' : '#nav-links';
- that.insertView(selector, link.view).render();
- });
- }, this);
- }
-
- // TODO: ADD ACTIVE CLASS
- });
-
- Fauxton.ApiBar = Backbone.View.extend({
- template: "templates/fauxton/api_bar",
- endpoint: '_all_docs',
-
- documentation: 'docs',
-
- events: {
- "click .api-url-btn" : "toggleAPIbar"
- },
-
- toggleAPIbar: function(e){
- var $currentTarget = $(e.currentTarget).find('span');
- if ($currentTarget.hasClass("fonticon-plus")){
- $currentTarget.removeClass("fonticon-plus").addClass("fonticon-minus");
- }else{
- $currentTarget.removeClass("fonticon-minus").addClass("fonticon-plus");
- }
-
- $('.api-navbar').toggle();
-
- },
-
- serialize: function() {
- return {
- endpoint: this.endpoint,
- documentation: this.documentation
- };
- },
-
- hide: function(){
- this.$el.addClass('hide');
- },
- show: function(){
- this.$el.removeClass('hide');
- },
- update: function(endpoint) {
- this.show();
- this.endpoint = endpoint[0];
- this.documentation = endpoint[1];
- 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().$el.appendTo(selector);
- this.delayedFade();
- return this;
- }
- });
-
-
- return Fauxton;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/components.js b/src/fauxton/app/modules/fauxton/components.js
deleted file mode 100644
index a9f45ad..0000000
--- a/src/fauxton/app/modules/fauxton/components.js
+++ /dev/null
@@ -1,337 +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('ace_configuration', ["app", "ace/ace"], function (app, ace) {
- var path = app.host + app.root + 'js/ace';
- var config = require("ace/config");
- config.set("packaged", true);
- config.set("workerPath",path);
- config.set("modePath",path);
- config.set("themePath", path);
- return ace;
-});
-
-define([
- "app",
- // Libs
- "api",
- "ace_configuration",
-],
-
-function(app, FauxtonAPI, ace) {
- var Components = app.module();
-
- Components.Pagination = FauxtonAPI.View.extend({
- template: "templates/fauxton/pagination",
-
- initialize: function(options) {
- this.page = parseInt(options.page, 10);
- 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
- };
- }
- });
-
- Components.IndexPagination = FauxtonAPI.View.extend({
- template: "templates/fauxton/index_pagination",
- events: {
- "click a": 'scrollTo',
- "click a#next": 'nextClicked',
- "click a#previous": 'previousClicked'
- },
-
- scrollTo: function () {
- if (!this.scrollToSelector) { return; }
- $(this.scrollToSelector).animate({ scrollTop: 0 }, 'slow');
- },
-
- initialize: function (options) {
- this.previousUrlfn = options.previousUrlfn;
- this.nextUrlfn = options.nextUrlfn;
- this.canShowPreviousfn = options.canShowPreviousfn;
- this.canShowNextfn = options.canShowNextfn;
- this.scrollToSelector = options.scrollToSelector;
- _.bindAll(this);
- this.previousParams = [];
- },
-
- previousClicked: function (event) {
- event.preventDefault();
- event.stopPropagation();
- if (!this.canShowPreviousfn()) { return; }
- FauxtonAPI.navigate(this.previousUrlfn(), {trigger: false});
- FauxtonAPI.triggerRouteEvent('paginate', 'previous');
- },
-
- nextClicked: function (event) {
- event.preventDefault();
- event.stopPropagation();
- if (!this.canShowNextfn()) { return; }
-
- var params = _.clone(this.collection.params);
-
- if (params) {
- this.previousParams.push(params);
- }
-
- FauxtonAPI.navigate(this.nextUrlfn(), {trigger: false});
- FauxtonAPI.triggerRouteEvent('paginate', 'next');
- },
-
- serialize: function () {
- return {
- canShowNextfn: this.canShowNextfn,
- canShowPreviousfn: this.canShowPreviousfn,
- };
- },
-
- pageLimit: function () {
- var limit = 20;
-
- if (this.collection.params.limit && this.collection.skipFirstItem) {
- limit = parseInt(this.collection.params.limit, 10) - 1;
- } else if (this.collection.params.limit) {
- limit = parseInt(this.collection.params.limit, 10);
- }
-
- return limit;
- },
-
- pageStart: function () {
- return (this.previousParams.length * this.pageLimit()) + 1;
-
- },
-
- pageEnd: function () {
- return (this.previousParams.length * this.pageLimit()) + this.pageLimit();
- }
-
- });
-
- //TODO allow more of the typeahead options.
- //Current this just does what we need but we
- //need to support the other typeahead options.
- Components.Typeahead = FauxtonAPI.View.extend({
-
- initialize: function (options) {
- this.source = options.source;
- _.bindAll(this);
- },
-
- afterRender: function () {
- var onUpdate = this.onUpdate;
-
- this.$el.typeahead({
- source: this.source,
- updater: function (item) {
- if (onUpdate) {
- onUpdate(item);
- }
-
- return item;
- }
- });
- }
-
- });
-
-
- Components.DbSearchTypeahead = Components.Typeahead.extend({
- initialize: function (options) {
- this.dbLimit = options.dbLimit || 30;
- this.onUpdate = options.onUpdate;
- _.bindAll(this);
- },
- source: function(query, process) {
- var url = [
- app.host,
- "/_all_dbs?startkey=%22",
- query,
- "%22&endkey=%22",
- query,
- "\u9999",
- "%22&limit=",
- this.dbLimit
- ].join('');
-
- if (this.ajaxReq) { this.ajaxReq.abort(); }
-
- this.ajaxReq = $.ajax({
- cache: false,
- url: url,
- dataType: 'json',
- success: function(data) {
- process(data);
- }
- });
- }
- });
-
- Components.DocSearchTypeahead = Components.Typeahead.extend({
- initialize: function (options) {
- this.docLimit = options.docLimit || 30;
- this.database = options.database;
- _.bindAll(this);
- },
- source: function(query, process) {
- var url = [
- app.host,
- "/",
- this.database.id,
- "/_all_docs?startkey=%22",
- query,
- "%22&endkey=%22",
- query,
- "\u9999",
- "%22&limit=",
- this.docLimit
- ].join('');
-
- if (this.ajaxReq) { this.ajaxReq.abort(); }
-
- this.ajaxReq = $.ajax({
- cache: false,
- url: url,
- dataType: 'json',
- success: function(data) {
- var ids = _.map(data.rows, function (row) {
- return row.id;
- });
- process(ids);
- }
- });
- }
- });
-
- Components.Editor = FauxtonAPI.View.extend({
- initialize: function (options) {
- this.editorId = options.editorId;
- this.mode = options.mode || "json";
- this.commands = options.commands;
- this.theme = options.theme || 'crimson_editor';
- this.couchJSHINT = options.couchJSHINT;
- this.edited = false;
- },
-
- afterRender: function () {
- this.editor = ace.edit(this.editorId);
- this.setHeightToLineCount();
- this.editor.setTheme("ace/theme/" + this.theme);
- this.editor.getSession().setMode("ace/mode/" + this.mode);
- this.editor.getSession().setUseWrapMode(true);
- this.editor.setShowPrintMargin(false);
- this.editor.gotoLine(2);
- this.addCommands();
-
- if (this.couchJSHINT) {
- this.removeIncorrectAnnotations();
- }
-
- var that = this;
- this.editor.getSession().on('change', function () {
- that.setHeightToLineCount();
- that.edited = true;
- });
-
- $(window).on('beforeunload.editor', function() {
- if (that.edited) {
- return 'Your changes have not been saved. Click cancel to return to the document.';
- }
- });
-
- FauxtonAPI.beforeUnload("editor", function (deferred) {
- if (that.edited) {
- return 'Your changes have not been saved. Click cancel to return to the document.';
- }
- });
- },
-
- cleanup: function () {
- $(window).off('beforeunload.editor');
- FauxtonAPI.removeBeforeUnload("editor");
- },
-
- setHeightToLineCount: function () {
- var lines = this.editor.getSession().getDocument().getLength();
- this.editor.setOptions({
- maxLines: lines
- });
-
- this.editor.resize();
- },
-
- addCommands: function () {
- _.each(this.commands, function (command) {
- this.editor.commands.addCommand(command);
- }, this);
- },
-
- removeIncorrectAnnotations: function () {
- var editor = this.editor;
-
- this.editor.getSession().on("changeAnnotation", function(){
- var annotations = editor.getSession().getAnnotations();
-
- var newAnnotations = _.reduce(annotations, function (annotations, error) {
- if (!FauxtonAPI.isIgnorableError(error.raw)) {
- annotations.push(error);
- }
- return annotations;
- }, []);
-
- if (annotations.length !== newAnnotations.length) {
- editor.getSession().setAnnotations(newAnnotations);
- }
- });
- },
-
- editSaved: function () {
- this.edited = false;
- },
-
- setValue: function (data, lineNumber) {
- lineNumber = lineNumber ? lineNumber : -1;
- this.editor.setValue(data, lineNumber);
- },
-
- getValue: function () {
- return this.editor.getValue();
- },
-
- getAnnotations: function () {
- return this.editor.getSession().getAnnotations();
- },
-
- hadValidCode: function () {
- var errors = this.getAnnotations();
- // By default CouchDB view functions don't pass lint
- return _.every(errors, function(error) {
- return FauxtonAPI.isIgnorableError(error.raw);
- },this);
- }
-
- });
-
- return Components;
-});
-
[05/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix sidebar for new views that have odd characters
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/65c1b999
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/65c1b999
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/65c1b999
Branch: refs/heads/api-options
Commit: 65c1b9993c0108e09e3b32303dc3b9bf69573ff6
Parents: b9a87c8
Author: suelockwood <de...@apache.org>
Authored: Thu Jan 9 10:15:33 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Jan 9 10:15:33 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/modules/documents/views.js | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/65c1b999/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 05c86f8..c3f96b7 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -1535,7 +1535,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
this.ddocID = this.model.id;
} else {
- this.model = this.ddocs.get(this.ddocID).dDocModel();
+ var ddocDecode = decodeURIComponent(this.ddocID);
+ this.model = this.ddocs.get(ddocDecode).dDocModel();
this.reduceFunStr = this.model.viewHasReduce(this.viewName);
this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
}
@@ -1717,10 +1718,26 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}, this);
},
+ addNewSidebarItem: function(key, selector, design){
+ console.log(args, "sidebarupdate");
+ // var selected = this.ddocID == "_design/"+design;
+ // var view = this.insertView("ul.nav.views", new Views.IndexItem({
+ // ddoc: design,
+ // index: key,
+ // database: this.collection.database.id,
+ // selected: selected && key == this.currView
+ // }));
+ // if (render !== false) {
+ // view.render();
+ // }
+ },
+
afterRender: function () {
if (this.selectedTab) {
this.setSelectedTab(this.selectedTab);
}
+
+ this.listenTo(this.collection, "add", this.addNewSidebarItem);
},
setSelectedTab: function (selectedTab) {
[37/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: update api bar with view query updates
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/678d034a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/678d034a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/678d034a
Branch: refs/heads/api-options
Commit: 678d034a8ebe144c961467b8d25018a897e3494b
Parents: ad3edf8
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Jan 15 17:32:52 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 15 17:32:52 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/documents/routes.js | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/678d034a/src/fauxton/app/addons/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js
index 6786edf..1510485 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -304,6 +304,7 @@ function(app, FauxtonAPI, Documents, Databases) {
this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
collection: this.data.database.allDocs
}));
+ //this.apiUrl = [this.data.database.allDocs.url("apiurl"), this.data.database.allDocs.documentation() ];
return;
}
@@ -320,6 +321,8 @@ function(app, FauxtonAPI, Documents, Databases) {
nestedView: Documents.Views.Row,
viewList: true
}));
+
+ this.apiUrl = [this.data.indexedDocs.url("apiurl"), "docs"];
},
updateAllDocsFromPreview: function (event) {
[09/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Don't toggle query option checkboxes when clicking ALL button on all docs page.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0fa5c32d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0fa5c32d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0fa5c32d
Branch: refs/heads/api-options
Commit: 0fa5c32d043846913cf1026a677ed1a9df25c98d
Parents: 3cd4bc5
Author: suelockwood <de...@apache.org>
Authored: Fri Jan 10 12:18:13 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Fri Jan 10 12:18:13 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/modules/documents/views.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0fa5c32d/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 78cbbb8..29ff199 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -601,7 +601,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
},
selectAll: function(evt){
- $("input:checkbox").prop('checked', !$(evt.target).hasClass('active')).trigger('change');
+ $('.all-docs').find("input:checkbox").prop('checked', !$(evt.target).hasClass('active')).trigger('change');
},
serialize: function() {
[49/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Updated the CSS
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ab41b1b9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ab41b1b9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ab41b1b9
Branch: refs/heads/api-options
Commit: ab41b1b98dc28f8016f98b0d61be84105ed6f034
Parents: b7e7775
Author: suelockwood <de...@apache.org>
Authored: Tue Dec 17 12:34:18 2013 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 22 16:39:22 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/databases/assets/less/databases.less | 8 ++++++++
src/fauxton/app/addons/documents/views.js | 2 ++
.../app/templates/documents/advanced_options_menu.html | 9 ++++-----
3 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ab41b1b9/src/fauxton/app/addons/databases/assets/less/databases.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/assets/less/databases.less b/src/fauxton/app/addons/databases/assets/less/databases.less
index 3d86d81..a47a039 100644
--- a/src/fauxton/app/addons/databases/assets/less/databases.less
+++ b/src/fauxton/app/addons/databases/assets/less/databases.less
@@ -243,5 +243,13 @@ table#changes-table {
a.button.btn-large.gray {
padding: 9px 10px;
vertical-align: middle;
+ }
+}
+
+.advanced-options-menu {
+ a {
+ padding-left: 20px;
+ text-decoration: underline;
}
}
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ab41b1b9/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index ac02993..fa82076 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1026,6 +1026,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
Views.AdvancedOptionsMenu = FauxtonAPI.View.extend({
template: 'templates/documents/advanced_options_menu',
+ tagName: "div",
+ className: "controls-group advanced-options-menu",
events: {
"click input": "updateRows",
'change #group-level': 'updateRows',
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ab41b1b9/src/fauxton/app/templates/documents/advanced_options_menu.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/advanced_options_menu.html b/src/fauxton/app/templates/documents/advanced_options_menu.html
index 0bb501d..9763e4b 100644
--- a/src/fauxton/app/templates/documents/advanced_options_menu.html
+++ b/src/fauxton/app/templates/documents/advanced_options_menu.html
@@ -1,14 +1,13 @@
-<div class="controls-group">
- <div class="row-fluid">
+ <div class="row-fluid custom-inputs">
<div class="controls controls-row">
<div class="checkbox inline">
<input id="include-docs" type="checkbox" name="include_docs" value="true">
- <label name="include_docs" for="check1">Include Docs</label>
+ <label for="include_docs">Include Docs</label>
</div>
<% if (hasReduce) { %>
<div class="checkbox inline">
<input id="reduce" name="reduce" type="checkbox" value="true">
- <label for="check2">Reduce</label>
+ <label for="reduce">Reduce</label>
<label id="group-level-label" style="display:none" class="drop-down inline">
Group Level:
<select id="group-level" name="group_level" class="input-small">
@@ -30,5 +29,5 @@
<a data-bypass="true" id="query-nav" class="" href="#query" data-toggle="tab">More query options</a></li>
</div>
</div>
-</div>
+
[06/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Changes View fix
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f5db0bee
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f5db0bee
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f5db0bee
Branch: refs/heads/api-options
Commit: f5db0beec2a232bba8a9985f0e4f20d697049066
Parents: 65c1b99
Author: suelockwood <de...@apache.org>
Authored: Thu Jan 9 10:49:00 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Jan 9 10:49:00 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/modules/documents/views.js | 49 +++++++++++++++++++++++++
1 file changed, 49 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f5db0bee/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 c3f96b7..ec1b5d2 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -30,6 +30,55 @@ define([
function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns) {
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=' + Databases.DocLimit,
+ };
+ },
+
+ 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; }
+ FauxtonAPI.addNotification({
+ msg: "Deleting your database...",
+ type: "error"
+ });
+ return this.database.destroy().done(function () {
+ app.router.navigate('#/_all_dbs', {trigger: true});
+ });
+ }
+ });
Views.SearchBox = FauxtonAPI.View.extend({
template: "templates/documents/search",
[26/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Remove with_right_sidebar from makefile
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a37a3eb4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a37a3eb4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a37a3eb4
Branch: refs/heads/api-options
Commit: a37a3eb4e3d52eba60d3c13b7d3e8b5a35fb7b41
Parents: bea8c6d
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 14:58:43 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 14:58:43 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a37a3eb4/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 4302048..78bbfac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,7 +160,6 @@ FAUXTON_FILES = \
fauxton/app/addons/fauxton/templates/pagination.html \
fauxton/app/templates/layouts/one_pane.html \
fauxton/app/templates/layouts/two_pane.html \
- fauxton/app/templates/layouts/with_right_sidebar.html \
fauxton/app/templates/layouts/with_sidebar.html \
fauxton/app/templates/layouts/with_tabs.html \
fauxton/app/templates/layouts/with_tabs_sidebar.html \
[34/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Clean up active xhr
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/392f7b3e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/392f7b3e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/392f7b3e
Branch: refs/heads/api-options
Commit: 392f7b3ec78bcd6eca2e9661afabbd4ec39c5337
Parents: b9d30b1
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Dec 19 15:52:22 2013 +0200
Committer: suelockwood <de...@apache.org>
Committed: Tue Jan 14 10:45:55 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/api.js | 41 ++++++++++++++++++++++++++++++++++++++---
src/fauxton/app/router.js | 2 +-
2 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/392f7b3e/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index f423ef5..6d450de 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -290,6 +290,7 @@ function(app, Fauxton) {
establish: function() {},
route: function() {},
roles: [],
+ _promises: [],
initialize: function() {}
}, {
@@ -319,7 +320,9 @@ function(app, Fauxton) {
}
triggerBroadcast('beforeEstablish');
- FauxtonAPI.when(this.establish()).then(function(resp) {
+ var establishPromise = this.establish();
+ this.addPromise(establishPromise);
+ FauxtonAPI.when(establishPromise).then(function(resp) {
triggerBroadcast('afterEstablish');
_.each(routeObject.getViews(), function(view, selector) {
if(view.hasRendered) {
@@ -328,6 +331,8 @@ function(app, Fauxton) {
}
triggerBroadcast('beforeRender', view, selector);
+ var viewPromise = view.establish();
+ routeObject.addPromise(viewPromise);
FauxtonAPI.when(view.establish()).then(function(resp) {
masterLayout.setView(selector, view);
@@ -339,7 +344,7 @@ function(app, Fauxton) {
reason: resp
};
- if (resp) {
+ if (resp && resp.responseText) {
var errorText = JSON.parse(resp.responseText).reason;
FauxtonAPI.addNotification({
msg: 'An Error occurred: ' + errorText,
@@ -353,7 +358,7 @@ function(app, Fauxton) {
});
}.bind(this), function (resp) {
- if (!resp) { return; }
+ if (!resp || !resp.responseText) { return; }
FauxtonAPI.addNotification({
msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
type: 'error',
@@ -422,6 +427,36 @@ function(app, Fauxton) {
}, this);
},
+ addPromise: function (promise) {
+ if (_.isEmpty(promise)) { return; }
+
+ if (_.isArray(promise)) {
+ return _.each(promise, function (p) {
+ this._promises.push(p);
+ }, this);
+ }
+
+ this._promises.push(promise);
+ },
+
+ cleanup: function () {
+ this.removeViews();
+ this.rejectPromises();
+ },
+
+ rejectPromises: function () {
+ _.each(this._promises, function (promise) {
+ if (promise.state() === "resolved") { return; }
+ if (promise.abort) {
+ return promise.abort("Route change");
+ }
+
+ promise.reject();
+ }, this);
+
+ this._promises = [];
+ },
+
getRouteUrls: function () {
return _.keys(this.get('routes'));
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/392f7b3e/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index 7cf69ad..89c60cf 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -76,7 +76,7 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, LoadAddons) {
authPromise.then(function () {
if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
if (that.activeRouteObject) {
- that.activeRouteObject.removeViews();
+ that.activeRouteObject.cleanup();
}
that.activeRouteObject = new RouteObject(route, masterLayout, args);
}
[39/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
use POSIX tar to support files length > 99
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f04485f0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f04485f0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f04485f0
Branch: refs/heads/api-options
Commit: f04485f04e2f02e86ca6316a0b19ce9a8d3cc5fd
Parents: 0b9bb15
Author: Benoit Chesneau <be...@apache.org>
Authored: Sun Jan 5 10:22:05 2014 +0100
Committer: Alexander Shorin <kx...@apache.org>
Committed: Thu Jan 16 01:41:58 2014 +0400
----------------------------------------------------------------------
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f04485f0/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 6c5ef5b..57a4268 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([src/snappy/google-snappy/config.h])
-AM_INIT_AUTOMAKE([1.6.3 foreign])
+AM_INIT_AUTOMAKE([1.6.3 foreign tar-ustar])
AC_USE_SYSTEM_EXTENSIONS
AC_ENABLE_SHARED
[48/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
We use the AdvancedOptions View in a couple spots where the eventer isn't passed. Added logic so it will only bind the listener if it is
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b7e7775f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b7e7775f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b7e7775f
Branch: refs/heads/api-options
Commit: b7e7775ff43e16ed68f8a54f277e6354d787d47b
Parents: 3a39844
Author: suelockwood <de...@apache.org>
Authored: Tue Dec 17 12:11:30 2013 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 22 16:22:50 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b7e7775f/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 288e10c..ac02993 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1110,7 +1110,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
this.showPreview = options.showPreview;
}
- this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate);
+ if (this.eventer) {
+ this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate);
+ }
},
events: {
[07/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Export missing function - couch_httpd:send_error/2
Signed-off-by: Peter Lemenkov <le...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a749ecb2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a749ecb2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a749ecb2
Branch: refs/heads/api-options
Commit: a749ecb25ee4b79777dfb022a40984d30f56c132
Parents: f5db0be
Author: Peter Lemenkov <le...@gmail.com>
Authored: Fri Jan 10 15:30:54 2014 +0400
Committer: Peter Lemenkov <le...@gmail.com>
Committed: Fri Jan 10 15:30:54 2014 +0400
----------------------------------------------------------------------
src/couchdb/couch_httpd.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a749ecb2/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 28932ba..465bc7a 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -27,7 +27,7 @@
-export([start_chunked_response/3,send_chunk/2,log_request/2]).
-export([start_response_length/4, start_response/3, send/2]).
-export([start_json_response/2, start_json_response/3, end_json_response/1]).
--export([send_response/4,send_method_not_allowed/2,send_error/4, send_redirect/2,send_chunked_error/2]).
+-export([send_response/4,send_method_not_allowed/2,send_error/2,send_error/4, send_redirect/2,send_chunked_error/2]).
-export([send_json/2,send_json/3,send_json/4,last_chunk/1,parse_multipart_request/3]).
-export([accepted_encodings/1,handle_request_int/5,validate_referer/1,validate_ctype/2]).
-export([http_1_0_keep_alive/2]).
[45/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton addon Verifyinstall missing from makefile
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/eabece10
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/eabece10
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/eabece10
Branch: refs/heads/api-options
Commit: eabece10a40618875e9e43cbc3f9231f80adecb7
Parents: 424e25a
Author: suelockwood <de...@apache.org>
Authored: Fri Jan 17 11:20:35 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Fri Jan 17 11:20:35 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/eabece10/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 6666751..73e48b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -105,6 +105,12 @@ FAUXTON_FILES = \
fauxton/app/addons/stats/templates/stats.html \
fauxton/app/addons/stats/templates/statselect.html \
fauxton/app/addons/stats/views.js \
+ fauxton/app/addons/verifyinstall/views.js \
+ fauxton/app/addons/verifyinstall/resources.js \
+ fauxton/app/addons/verifyinstall/base.js \
+ fauxton/app/addons/verifyinstall/routes.js \
+ fauxton/app/addons/verifyinstall/templates/main.html \
+ fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less \
fauxton/app/api.js \
fauxton/app/app.js \
fauxton/app/config.js \
[10/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
View editor fix on save, notification clearing
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4396ea3d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4396ea3d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4396ea3d
Branch: refs/heads/api-options
Commit: 4396ea3d7a48108a70a5ffe8de93892d402417c9
Parents: 0fa5c32
Author: suelockwood <de...@apache.org>
Authored: Fri Jan 10 13:17:32 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Fri Jan 10 13:17:32 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/modules/documents/views.js | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/4396ea3d/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 29ff199..59aba01 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -497,6 +497,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
},
toggleQuery: function (event) {
+ $('#dashboard-content').scrollTop(0);
this.$('#query').toggle('fast');
},
@@ -881,6 +882,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
editor.editSaved();
FauxtonAPI.navigate('/database/' + that.database.safeID() + '/' + that.model.id);
}).fail(function(xhr) {
+
var responseText = JSON.parse(xhr.responseText).reason;
notification = FauxtonAPI.addNotification({
msg: "Save failed: " + responseText,
@@ -1330,6 +1332,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
if (event) { event.preventDefault();}
+ $('#dashboard-content').scrollTop(0); //scroll up
+
if (this.hasValidCode() && this.$('#new-ddoc:visible').val() !=="") {
var mapVal = this.mapEditor.getValue(),
reduceVal = this.reduceVal(),
@@ -1341,7 +1345,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
notification = FauxtonAPI.addNotification({
msg: "Saving document.",
- selector: "#define-view .errors-container"
+ selector: "#define-view .errors-container",
+ clear: true
});
ddoc.setDdocView(viewName, mapVal, reduceVal);
@@ -1355,7 +1360,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
FauxtonAPI.addNotification({
msg: "View has been saved.",
type: "success",
- selector: "#define-view .errors-container"
+ selector: "#define-view .errors-container",
+ clear: true
});
if (that.newView) {
@@ -1393,7 +1399,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
notification = FauxtonAPI.addNotification({
msg: errormessage,
type: "error",
- selector: "#define-view .errors-container"
+ selector: "#define-view .errors-container",
+ clear: true
});
}
},
@@ -1415,13 +1422,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
return FauxtonAPI.addNotification({
msg: "JSON Parse Error on field: "+param.name,
type: "error",
- selector: ".advanced-options .errors-container"
+ selector: ".advanced-options .errors-container",
+ clear: true
});
});
FauxtonAPI.addNotification({
msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
type: "warning",
- selector: ".advanced-options .errors-container"
+ selector: ".advanced-options .errors-container",
+ clear: true
});
return false;
@@ -1531,6 +1540,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
if ($targetId === 'index-nav') {
if (this.newView) { return; }
var that = this;
+ $('#dashboard-content').scrollTop(0); //scroll up
$targetTab.toggle('slow', function(){
that.showEditors();
});
[43/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Set default reduce to none not _sum
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0fd6a7ed
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0fd6a7ed
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0fd6a7ed
Branch: refs/heads/api-options
Commit: 0fd6a7ed63836bad36c75c3935e27804be30773c
Parents: 32bb6ce
Author: suelockwood <de...@apache.org>
Authored: Thu Jan 16 14:12:51 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Jan 16 14:13:09 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0fd6a7ed/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index bde08f8..ba7e7d7 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1593,7 +1593,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
beforeRender: function () {
if (this.newView) {
- this.reduceFunStr = '_sum';
+ this.reduceFunStr = '';
if (this.ddocs.length === 0) {
this.model = new Documents.Doc(null, {database: this.database});
} else {
[46/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: Fix rename view shows in sidebar
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/15f4fff0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/15f4fff0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/15f4fff0
Branch: refs/heads/api-options
Commit: 15f4fff02882bdfe879ddbbeba447677d1b18fc1
Parents: eabece1
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 21 15:30:46 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Jan 21 15:30:46 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/compaction/views.js | 1 -
src/fauxton/app/addons/documents/views.js | 13 ++++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/15f4fff0/src/fauxton/app/addons/compaction/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/views.js b/src/fauxton/app/addons/compaction/views.js
index 06a1300..f5469cf 100644
--- a/src/fauxton/app/addons/compaction/views.js
+++ b/src/fauxton/app/addons/compaction/views.js
@@ -52,7 +52,6 @@ function (app, FauxtonAPI, Compaction) {
msg: 'Database compaction has started. Visit <a href="#activetasks">Active Tasks</a> to view the compaction progress.',
});
}, function (xhr, error, reason) {
- console.log(arguments);
FauxtonAPI.addNotification({
type: 'error',
msg: 'Error: ' + JSON.parse(xhr.responseText).reason
http://git-wip-us.apache.org/repos/asf/couchdb/blob/15f4fff0/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index ba7e7d7..d5319f3 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1344,9 +1344,14 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
reduceVal = this.reduceVal(),
viewName = this.$('#index-name').val(),
ddoc = this.getCurrentDesignDoc(),
- ddocName = ddoc.id;
+ ddocName = ddoc.id,
+ viewNameChange = false;
- this.viewName = viewName;
+ if (this.viewName !== viewName) {
+ ddoc.removeDdocView(this.viewName);
+ this.viewName = viewName;
+ viewNameChange = true;
+ }
notification = FauxtonAPI.addNotification({
msg: "Saving document.",
@@ -1369,7 +1374,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
clear: true
});
- if (that.newView) {
+ if (that.newView || viewNameChange) {
var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.utils.safeURLName(viewName);
FauxtonAPI.navigate(fragment, {trigger: false});
@@ -1485,8 +1490,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
promise.then(function () {
params.docs = that.database.allDocs.map(function (model) { return model.get('doc');});
-
- console.log('p', params, paramsInfo);
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});
[21/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton fix build
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/86b6a144
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/86b6a144
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/86b6a144
Branch: refs/heads/api-options
Commit: 86b6a1448aec8e18b090c17ec08823dd414545c8
Parents: 4b69ff3
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Jan 13 14:42:40 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 13 14:42:40 2014 +0200
----------------------------------------------------------------------
license.skip | 9 ++++++---
src/Makefile.am | 6 +++---
.../app/addons/documents/assets/less/documents.less | 11 +++++++++++
src/fauxton/app/addons/documents/views.js | 7 +++++--
src/fauxton/app/addons/pouchdb/base.js | 11 +++++++++++
.../app/templates/documents/duplicate_doc_modal.html | 2 +-
src/fauxton/test/core/layoutSpec.js | 2 +-
src/fauxton/test/core/navbarSpec.js | 2 +-
src/fauxton/test/core/paginateSpec.js | 4 ++--
9 files changed, 41 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index 0895cf8..984d869 100644
--- a/license.skip
+++ b/license.skip
@@ -124,9 +124,6 @@
^src/ejson/.*
^src/etap/.*
^src/fauxton/app/addons/config/assets/less/config.less
-^src/fauxton/app/modules/pouchdb/base.js
-^src/fauxton/app/modules/pouchdb/pouch.collate.js
-^src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
^src/fauxton/assets/css/codemirror.css
^src/fauxton/assets/css/nv.d3.css
^src/fauxton/assets/img/.*
@@ -152,6 +149,8 @@
^src/fauxton/test/mocha/sinon-chai.js
^src/fauxton/tasks/addon/rename.json
^src/fauxton/assets/lib/ace/.*
+^src/fauxton/app/addons/pouchdb/pouch.collate.js
+^src/fauxton/app/addons/pouchdb/pouchdb.mapreduce.js
^src/ibrowse/.*
^src/mochiweb/.*
^src/my-first-couchdb-plugin/priv/*/*
@@ -184,3 +183,7 @@
^var/Makefile
^var/Makefile.in
^Vagrantfile
+^share/www/fauxton/Makefile
+^share/www/fauxton/Makefile.in
+^share/www/Makefile
+^share/www/Makefile.in
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index cb37384..4302048 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -273,12 +273,12 @@ FAUXTON_FILES = \
fauxton/assets/less/bootstrap/utilities.less \
fauxton/assets/less/bootstrap/variables.less \
fauxton/assets/less/bootstrap/wells.less \
- fauxton/addons/config/assets/less/config.less \
+ fauxton/app/addons/config/assets/less/config.less \
fauxton/assets/less/couchdb.less \
- fauxton/addons/databases/assets/less/databases.less \
+ fauxton/app/addons/databases/assets/less/databases.less \
fauxton/assets/less/fauxton.less \
fauxton/assets/less/icons.less \
- fauxton/addons/logs/assets/less/logs.less \
+ fauxton/app/addons/logs/assets/less/logs.less \
fauxton/assets/less/prettyprint.less \
fauxton/assets/less/variables.less \
fauxton/bin/grunt \
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/app/addons/documents/assets/less/documents.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/assets/less/documents.less b/src/fauxton/app/addons/documents/assets/less/documents.less
index ff9e88c..38fd792 100644
--- a/src/fauxton/app/addons/documents/assets/less/documents.less
+++ b/src/fauxton/app/addons/documents/assets/less/documents.less
@@ -1,3 +1,14 @@
+// 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.
/*ALL DOCS TABLE*/
tr.all-docs-item{
border: none;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 80c0d87..94332a2 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -234,7 +234,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
},
events: {
- "click #duplicate-btn":"duplicate"
+ "click #duplicate-btn":"duplicate",
+ "submit #doc-duplicate": "duplicate"
},
@@ -1481,6 +1482,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
promise.then(function () {
params.docs = that.database.allDocs.map(function (model) { return model.get('doc');});
+ console.log('p', params, paramsInfo);
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});
@@ -1507,8 +1509,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
reduceVal: function() {
var reduceOption = this.$('#reduce-function-selector :selected').val(),
reduceVal = "";
-
+
if (reduceOption === 'CUSTOM') {
+ if (!this.reduceEditor) { this.createReduceEditor(); }
reduceVal = this.reduceEditor.getValue();
} else if ( reduceOption !== 'NONE') {
reduceVal = reduceOption;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/app/addons/pouchdb/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/base.js b/src/fauxton/app/addons/pouchdb/base.js
index df6c726..69962bb 100644
--- a/src/fauxton/app/addons/pouchdb/base.js
+++ b/src/fauxton/app/addons/pouchdb/base.js
@@ -1,3 +1,14 @@
+// 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
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/app/templates/documents/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/duplicate_doc_modal.html b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
index 3f374b6..dbb25bc 100644
--- a/src/fauxton/app/templates/documents/duplicate_doc_modal.html
+++ b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
@@ -19,7 +19,7 @@ the License.
</div>
<div class="modal-body">
<div id="modal-error" class="hide alert alert-error"/>
- <form id="file-upload" class="form" method="post">
+ <form id="doc-duplicate" class="form" method="post">
<p class="help-block">
Set new documents ID:
</p>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/test/core/layoutSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/layoutSpec.js b/src/fauxton/test/core/layoutSpec.js
index 3876b70..4167100 100644
--- a/src/fauxton/test/core/layoutSpec.js
+++ b/src/fauxton/test/core/layoutSpec.js
@@ -10,7 +10,7 @@
// License for the specific language governing permissions and limitations under
// the License.
define([
- 'modules/fauxton/layout',
+ 'addons/fauxton/layout',
'testUtils'
], function (Layout, testUtils) {
var assert = testUtils.assert;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/test/core/navbarSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/navbarSpec.js b/src/fauxton/test/core/navbarSpec.js
index ec3e71f..3eca6f6 100644
--- a/src/fauxton/test/core/navbarSpec.js
+++ b/src/fauxton/test/core/navbarSpec.js
@@ -10,7 +10,7 @@
// License for the specific language governing permissions and limitations under
// the License.
define([
- 'modules/fauxton/base',
+ 'addons/fauxton/base',
'testUtils'
], function (Fauxton, testUtils) {
var assert = testUtils.assert,
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86b6a144/src/fauxton/test/core/paginateSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/paginateSpec.js b/src/fauxton/test/core/paginateSpec.js
index 114c434..d05b322 100644
--- a/src/fauxton/test/core/paginateSpec.js
+++ b/src/fauxton/test/core/paginateSpec.js
@@ -11,8 +11,8 @@
// the License.
define([
'api',
- 'modules/fauxton/components',
- 'modules/documents/resources',
+ 'addons/fauxton/components',
+ 'addons/documents/resources',
'testUtils',
'app'
], function (FauxtonAPI, Views, Models, testUtils, app) {
[33/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: Bug fixes
* Fix failing tests
* Fix pagination not showing correct number when docs less than limit
* Fix create new view failing with new design doc
* Add Fauxton logo for grunt couchserver
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b9d30b14
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b9d30b14
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b9d30b14
Branch: refs/heads/api-options
Commit: b9d30b1483f731358b8ace6dc052a2641132f16a
Parents: e5cac79
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 14 14:34:20 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Jan 14 14:34:20 2014 +0200
----------------------------------------------------------------------
.../documents/templates/index_row_docular.html | 2 +-
src/fauxton/app/addons/documents/views.js | 3 ++-
src/fauxton/app/addons/fauxton/components.js | 4 ++++
.../app/addons/permissions/tests/viewsSpec.js | 2 +-
src/fauxton/tasks/couchserver.js | 18 +++++++++++++++++-
5 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
index 446a031..e8973ad 100644
--- a/src/fauxton/app/addons/documents/templates/index_row_docular.html
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -19,7 +19,7 @@ the License.
<pre class="prettyprint"><%- doc.prettyJSON() %></pre>
<div class="btn-group">
- <a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
+ <a href="#<%= url %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
<% if (doc.isEditable()) { %>
<button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
<% } %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 0139eca..9902541 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -405,7 +405,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
serialize: function() {
return {
- doc: this.model
+ doc: this.model,
+ url: this.model.url('app')
};
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
index a9f45ad..cda61c5 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -123,6 +123,10 @@ function(app, FauxtonAPI, ace) {
},
pageEnd: function () {
+ if (this.collection.length < this.pageLimit()) {
+ return this.collection.length;
+ }
+
return (this.previousParams.length * this.pageLimit()) + this.pageLimit();
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/permissions/tests/viewsSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/tests/viewsSpec.js b/src/fauxton/app/addons/permissions/tests/viewsSpec.js
index e5330c0..27abca4 100644
--- a/src/fauxton/app/addons/permissions/tests/viewsSpec.js
+++ b/src/fauxton/app/addons/permissions/tests/viewsSpec.js
@@ -25,7 +25,7 @@ define([
'names': ['_user'],
'roles': []
}
- }, {database: 'fakedb'});
+ }, {database: {id: 'fakedb', safeID: function () { return this.id; }}});
section = new Views.Permissions({
database: 'fakedb',
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
index b9ff3ef..5ccbfe1 100644
--- a/src/fauxton/tasks/couchserver.js
+++ b/src/fauxton/tasks/couchserver.js
@@ -19,7 +19,8 @@ module.exports = function (grunt) {
http = require("http"),
httpProxy = require('http-proxy'),
send = require('send'),
- options = grunt.config('couchserver');
+ options = grunt.config('couchserver'),
+ _ = grunt.util._;
// Options
var dist_dir = options.dist || './dist/debug/',
@@ -98,6 +99,21 @@ module.exports = function (grunt) {
watch.stdout.pipe(process.stdout);
watch.stderr.pipe(process.stderr);
+ var logo = [
+ [""],
+ [" ______ _ "],
+ ["| ____| | | "],
+ ["| |__ __ _ _ _ __ __ | |_ ___ _ __ "],
+ ["| __| / _` | | | | | \\ \\/ / | __| / _ \\ | '_ \\ "],
+ ["| | | (_| | | |_| | > < | |_ | (_) | | | | |"],
+ ["|_| \\__,_| \\__,_| /_/\\_\\ \\__| \\___/ |_| |_|"],
+ [""]
+ ];
+
+ _.each(logo, function (line) {
+ console.log(line.toString());
+ });
+
log.writeln('Listening on ' + port);
});
[12/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
docs: fix highlighting of artwork.jpg
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e7b0a9a1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e7b0a9a1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e7b0a9a1
Branch: refs/heads/api-options
Commit: e7b0a9a1ea0bee39776be23b5999727ef37bead0
Parents: 4396ea3
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Sun Jan 12 01:45:22 2014 +0100
Committer: Andy Wenk <an...@apache.org>
Committed: Sun Jan 12 11:20:20 2014 +0100
----------------------------------------------------------------------
share/doc/src/intro/api.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e7b0a9a1/share/doc/src/intro/api.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/intro/api.rst b/share/doc/src/intro/api.rst
index 3fb413a..9525bee 100644
--- a/share/doc/src/intro/api.rst
+++ b/share/doc/src/intro/api.rst
@@ -567,7 +567,7 @@ documents, music, or movie files. Let's make one.
Attachments get their own URL where you can upload data. Say we want to add
the album artwork to the ``6e1295ed6c29495e54cc05947f18c8af`` document
(*"There is Nothing Left to Lose"*), and let's also say the artwork is in a file
-artwork `.jpg` in the current directory::
+`artwork.jpg` in the current directory::
curl -vX PUT http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689 \
--data-binary @artwork.jpg -H "Content-Type:image/jpg"
[38/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix for running preview on indexes (I think this got accidentally commented out?)
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0b9bb156
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0b9bb156
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0b9bb156
Branch: refs/heads/api-options
Commit: 0b9bb15688821b5657ff81445ff1b88d6ffac7a6
Parents: 678d034
Author: suelockwood <de...@apache.org>
Authored: Wed Jan 15 16:22:52 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Wed Jan 15 16:22:52 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/pouchdb/pouch.collate.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0b9bb156/src/fauxton/app/addons/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/pouch.collate.js b/src/fauxton/app/addons/pouchdb/pouch.collate.js
index 6c64410..31e5650 100644
--- a/src/fauxton/app/addons/pouchdb/pouch.collate.js
+++ b/src/fauxton/app/addons/pouchdb/pouch.collate.js
@@ -110,6 +110,6 @@ function(app, FauxtonAPI, Collate) {
return Pouch;
-//}).call(this);
+}).call(this);
+
-});
[31/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix Permissions model url
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/afd66a9c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/afd66a9c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/afd66a9c
Branch: refs/heads/api-options
Commit: afd66a9ceed5af91b2db48f80b3fcf9e7fc04f3e
Parents: 61d0617
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 15:58:35 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:58:35 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/permissions/resources.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/afd66a9c/src/fauxton/app/addons/permissions/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/resources.js b/src/fauxton/app/addons/permissions/resources.js
index 8acaddd..4ddd3ae 100644
--- a/src/fauxton/app/addons/permissions/resources.js
+++ b/src/fauxton/app/addons/permissions/resources.js
@@ -39,7 +39,7 @@ function (app, FauxtonAPI ) {
},
url: function () {
- return app.host + this.database.id + '/_security';
+ return window.location.origin +"/"+ this.database.safeID() + '/_security';
},
addItem: function (value, type, section) {
[47/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Working menu change
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3a398445
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3a398445
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3a398445
Branch: refs/heads/api-options
Commit: 3a398445695589c5706461da50de738a79a4a0fb
Parents: 15f4fff
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Dec 17 18:07:41 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 22 16:22:49 2014 +0200
----------------------------------------------------------------------
.../addons/documents/templates/view_editor.html | 3 +-
src/fauxton/app/addons/documents/views.js | 97 +++++++++++++++++++-
.../documents/advanced_options_menu.html | 34 +++++++
3 files changed, 129 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3a398445/src/fauxton/app/addons/documents/templates/view_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/view_editor.html b/src/fauxton/app/addons/documents/templates/view_editor.html
index ddb5a0c..26b010f 100644
--- a/src/fauxton/app/addons/documents/templates/view_editor.html
+++ b/src/fauxton/app/addons/documents/templates/view_editor.html
@@ -15,12 +15,13 @@ the License.
<ul class="nav nav-tabs" id="db-views-tabs-nav">
<li class="active"> <a data-bypass="true" id="index-nav" class="fonticon-wrench fonticon" data-toggle="tab" href="#index"><% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
<% if (!newView) { %>
- <li><a data-bypass="true" id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
+ <!--<li><a data-bypass="true" id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>-->
<li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
<% } %>
</ul>
<div class="all-docs-list errors-container"></div>
<div class="tab-content">
+ <div id="query-options-wrapper"></div>
<div class="tab-pane active" id="index">
<div id="define-view" class="ddoc-alert well">
<div class="errors-container"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3a398445/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index d5319f3..288e10c 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1024,6 +1024,68 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
});
+ Views.AdvancedOptionsMenu = FauxtonAPI.View.extend({
+ template: 'templates/documents/advanced_options_menu',
+ events: {
+ "click input": "updateRows",
+ 'change #group-level': 'updateRows',
+ 'click #query-nav': 'toggleMenu'
+ },
+
+ initialize: function (options) {
+ this.hasReduce = options.hasReduce;
+ this.eventer = options.eventer;
+ },
+
+ toggleMenu: function (event) {
+ this.$('.checkbox').toggle();
+ },
+
+ updateRows: function (event) {
+ console.log('boom', event);
+ var $groupLevel = this.$('#group-level-label'),
+ params = {
+ include_docs: false,
+ reduce: false,
+ group_level: 0
+ };
+
+ if (this.$('#include-docs').prop('checked')) {
+ params.include_docs = true;
+ }
+
+ if (this.hasReduce && this.$('#reduce').prop('checked')) {
+ params.reduce = true;
+ params.group_level = this.$('#group-level option:selected').val();
+ $groupLevel.show();
+ } else {
+ $groupLevel.hide();
+ }
+
+ console.log(params);
+ this.eventer.trigger('options:param_update', params);
+ },
+
+ updateFromParams: function (params) {
+ if (params.reduce) {
+ var $reduce = this.$('#reduce');
+ $reduce.prop("checked", true);
+ this.$('#group-level').show();
+
+ } else if (params.include_docs) {
+ var $include_docs = this.$('#include-docs');
+ $include_docs.prop("checked", true);
+ }
+ },
+
+ serialize: function () {
+ return {
+ hasReduce: this.hasReduce
+ };
+ }
+
+ });
+
Views.AdvancedOptions = FauxtonAPI.View.extend({
template: "addons/documents/templates/advanced_options",
className: "advanced-options well",
@@ -1034,7 +1096,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
this.viewName = options.viewName;
this.updateViewFn = options.updateViewFn;
this.previewFn = options.previewFn;
- //this.hadReduce = options.hasReduce || true;
+ this.eventer = options.eventer;
if (typeof(options.hasReduce) === 'undefined') {
this.hasReduce = true;
@@ -1047,6 +1109,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
} else {
this.showPreview = options.showPreview;
}
+
+ this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate);
},
events: {
@@ -1066,6 +1130,21 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
},
+ optionsParamsUpdate: function (params) {
+ var $form = this.$el.find("form.view-query-update");
+
+ if (params.reduce && params.group_level) {
+ $form.find("select[name='group_level']").val(params.group_level).removeAttr('disabled');
+ delete params.group_level;
+ } else {
+ $form.find("select[name='group_level']").attr('disabled');
+ }
+ _.each(params, function(val, key) {
+ $form.find("input[name='"+key+"']").prop('checked', val);
+ });
+ this.$('form.view-query-update').submit();
+ },
+
renderOnUpdatehasReduce: function (hasReduce) {
this.hasReduce = hasReduce;
this.render();
@@ -1137,7 +1216,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
var $ele;
switch (key) {
case "limit":
- case "group_level":
+ case "group_level":
$form.find("select[name='"+key+"']").val(val);
break;
case "include_docs":
@@ -1246,7 +1325,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
"click button.delete": "deleteView",
"change select#reduce-function-selector": "updateReduce",
"click button.preview": "previewView",
- "click #db-views-tabs-nav": 'toggleIndexNav'
+ "click #db-views-tabs-nav": 'toggleIndexNav',
+ "click #query-options-wrapper": 'toggleIndexNav'
},
langTemplates: {
@@ -1615,6 +1695,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
ddocName: this.model.id,
database: this.database
}));
+
+ this.eventer = _.extend({}, Backbone.Events);
this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
updateViewFn: this.updateView,
@@ -1622,13 +1704,20 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
database: this.database,
viewName: this.viewName,
ddocName: this.model.id,
- hasReduce: this.hasReduce()
+ hasReduce: this.hasReduce(),
+ eventer: this.eventer
+ }));
+
+ this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
+ hasReduce: this.hasReduce(),
+ eventer: this.eventer
}));
},
afterRender: function() {
if (this.params) {
this.advancedOptions.updateFromParams(this.params);
+ this.advancedOptionsMenu.updateFromParams(this.params);
}
this.designDocSelector.updateDesignDoc();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3a398445/src/fauxton/app/templates/documents/advanced_options_menu.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/advanced_options_menu.html b/src/fauxton/app/templates/documents/advanced_options_menu.html
new file mode 100644
index 0000000..0bb501d
--- /dev/null
+++ b/src/fauxton/app/templates/documents/advanced_options_menu.html
@@ -0,0 +1,34 @@
+<div class="controls-group">
+ <div class="row-fluid">
+ <div class="controls controls-row">
+ <div class="checkbox inline">
+ <input id="include-docs" type="checkbox" name="include_docs" value="true">
+ <label name="include_docs" for="check1">Include Docs</label>
+ </div>
+ <% if (hasReduce) { %>
+ <div class="checkbox inline">
+ <input id="reduce" name="reduce" type="checkbox" value="true">
+ <label for="check2">Reduce</label>
+ <label id="group-level-label" style="display:none" class="drop-down inline">
+ Group Level:
+ <select id="group-level" name="group_level" class="input-small">
+ <option value="0">None</option>
+ <option value="1">1</option>
+ <option value="2">2</option>
+ <option value="3">3</option>
+ <option value="4">4</option>
+ <option value="5">5</option>
+ <option value="6">6</option>
+ <option value="7">7</option>
+ <option value="8">8</option>
+ <option value="9">9</option>
+ <option value="999" selected="selected">exact</option>
+ </select>
+ </label>
+ </div>
+ <% } %>
+ <a data-bypass="true" id="query-nav" class="" href="#query" data-toggle="tab">More query options</a></li>
+ </div>
+ </div>
+</div>
+
[02/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: Update Backbone to v1.1.0
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b058aefb
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b058aefb
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b058aefb
Branch: refs/heads/api-options
Commit: b058aefbaacff25f33175ce41133948249aef379
Parents: d13bff4
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Jan 9 16:02:24 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 9 16:02:24 2014 +0200
----------------------------------------------------------------------
src/fauxton/assets/js/libs/backbone.js | 272 +++++++++++++++-------------
1 file changed, 142 insertions(+), 130 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b058aefb/src/fauxton/assets/js/libs/backbone.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/backbone.js b/src/fauxton/assets/js/libs/backbone.js
index 3512d42..58ec2ab 100644
--- a/src/fauxton/assets/js/libs/backbone.js
+++ b/src/fauxton/assets/js/libs/backbone.js
@@ -1,6 +1,7 @@
-// Backbone.js 1.0.0
+// Backbone.js 1.1.0
-// (c) 2010-2013 Jeremy Ashkenas, DocumentCloud Inc.
+// (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc.
+// (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
@@ -34,7 +35,7 @@
}
// Current version of the library. Keep in sync with `package.json`.
- Backbone.VERSION = '1.0.0';
+ Backbone.VERSION = '1.1.0';
// Require Underscore, if we're on the server, and it's not already present.
var _ = root._;
@@ -52,7 +53,7 @@
};
// Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
- // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and
+ // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and
// set a `X-Http-Method-Override` header.
Backbone.emulateHTTP = false;
@@ -111,7 +112,6 @@
this._events = {};
return this;
}
-
names = name ? [name] : _.keys(this._events);
for (i = 0, l = names.length; i < l; i++) {
name = names[i];
@@ -151,14 +151,15 @@
// Tell this object to stop listening to either specific events ... or
// to every object it's currently listening to.
stopListening: function(obj, name, callback) {
- var listeners = this._listeners;
- if (!listeners) return this;
- var deleteListener = !name && !callback;
- if (typeof name === 'object') callback = this;
- if (obj) (listeners = {})[obj._listenerId] = obj;
- for (var id in listeners) {
- listeners[id].off(name, callback, this);
- if (deleteListener) delete this._listeners[id];
+ var listeningTo = this._listeningTo;
+ if (!listeningTo) return this;
+ var remove = !name && !callback;
+ if (!callback && typeof name === 'object') callback = this;
+ if (obj) (listeningTo = {})[obj._listenId] = obj;
+ for (var id in listeningTo) {
+ obj = listeningTo[id];
+ obj.off(name, callback, this);
+ if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];
}
return this;
}
@@ -215,10 +216,10 @@
// listening to.
_.each(listenMethods, function(implementation, method) {
Events[method] = function(obj, name, callback) {
- var listeners = this._listeners || (this._listeners = {});
- var id = obj._listenerId || (obj._listenerId = _.uniqueId('l'));
- listeners[id] = obj;
- if (typeof name === 'object') callback = this;
+ var listeningTo = this._listeningTo || (this._listeningTo = {});
+ var id = obj._listenId || (obj._listenId = _.uniqueId('l'));
+ listeningTo[id] = obj;
+ if (!callback && typeof name === 'object') callback = this;
obj[implementation](name, callback, this);
return this;
};
@@ -243,24 +244,18 @@
// Create a new model with the specified attributes. A client id (`cid`)
// is automatically generated and assigned for you.
var Model = Backbone.Model = function(attributes, options) {
- var defaults;
var attrs = attributes || {};
options || (options = {});
this.cid = _.uniqueId('c');
this.attributes = {};
- _.extend(this, _.pick(options, modelOptions));
+ if (options.collection) this.collection = options.collection;
if (options.parse) attrs = this.parse(attrs, options) || {};
- if (defaults = _.result(this, 'defaults')) {
- attrs = _.defaults({}, attrs, defaults);
- }
+ attrs = _.defaults({}, attrs, _.result(this, 'defaults'));
this.set(attrs, options);
this.changed = {};
this.initialize.apply(this, arguments);
};
- // A list of options to be attached directly to the model, if provided.
- var modelOptions = ['url', 'urlRoot', 'collection'];
-
// Attach all inheritable methods to the Model prototype.
_.extend(Model.prototype, Events, {
@@ -456,13 +451,16 @@
(attrs = {})[key] = val;
}
- // If we're not waiting and attributes exist, save acts as `set(attr).save(null, opts)`.
- if (attrs && (!options || !options.wait) && !this.set(attrs, options)) return false;
-
options = _.extend({validate: true}, options);
- // Do not persist invalid models.
- if (!this._validate(attrs, options)) return false;
+ // If we're not waiting and attributes exist, save acts as
+ // `set(attr).save(null, opts)` with validation. Otherwise, check if
+ // the model will be valid when the attributes, if any, are set.
+ if (attrs && !options.wait) {
+ if (!this.set(attrs, options)) return false;
+ } else {
+ if (!this._validate(attrs, options)) return false;
+ }
// Set temporary attributes if `{wait: true}`.
if (attrs && options.wait) {
@@ -563,7 +561,7 @@
attrs = _.extend({}, this.attributes, attrs);
var error = this.validationError = this.validate(attrs, options) || null;
if (!error) return true;
- this.trigger('invalid', this, error, _.extend(options || {}, {validationError: error}));
+ this.trigger('invalid', this, error, _.extend(options, {validationError: error}));
return false;
}
@@ -596,7 +594,6 @@
// its models in sort order, as they're added and removed.
var Collection = Backbone.Collection = function(models, options) {
options || (options = {});
- if (options.url) this.url = options.url;
if (options.model) this.model = options.model;
if (options.comparator !== void 0) this.comparator = options.comparator;
this._reset();
@@ -606,7 +603,7 @@
// Default options for `Collection#set`.
var setOptions = {add: true, remove: true, merge: true};
- var addOptions = {add: true, merge: false, remove: false};
+ var addOptions = {add: true, remove: false};
// Define the Collection's inheritable methods.
_.extend(Collection.prototype, Events, {
@@ -632,16 +629,17 @@
// Add a model, or list of models to the set.
add: function(models, options) {
- return this.set(models, _.defaults(options || {}, addOptions));
+ return this.set(models, _.extend({merge: false}, options, addOptions));
},
// Remove a model, or a list of models from the set.
remove: function(models, options) {
- models = _.isArray(models) ? models.slice() : [models];
+ var singular = !_.isArray(models);
+ models = singular ? [models] : _.clone(models);
options || (options = {});
var i, l, index, model;
for (i = 0, l = models.length; i < l; i++) {
- model = this.get(models[i]);
+ model = models[i] = this.get(models[i]);
if (!model) continue;
delete this._byId[model.id];
delete this._byId[model.cid];
@@ -654,7 +652,7 @@
}
this._removeReference(model);
}
- return this;
+ return singular ? models[0] : models;
},
// Update a collection by `set`-ing a new list of models, adding new ones,
@@ -662,31 +660,45 @@
// already exist in the collection, as necessary. Similar to **Model#set**,
// the core operation for updating the data contained by the collection.
set: function(models, options) {
- options = _.defaults(options || {}, setOptions);
+ options = _.defaults({}, options, setOptions);
if (options.parse) models = this.parse(models, options);
- if (!_.isArray(models)) models = models ? [models] : [];
- var i, l, model, attrs, existing, sort;
+ var singular = !_.isArray(models);
+ models = singular ? (models ? [models] : []) : _.clone(models);
+ var i, l, id, model, attrs, existing, sort;
var at = options.at;
+ var targetModel = this.model;
var sortable = this.comparator && (at == null) && options.sort !== false;
var sortAttr = _.isString(this.comparator) ? this.comparator : null;
var toAdd = [], toRemove = [], modelMap = {};
+ var add = options.add, merge = options.merge, remove = options.remove;
+ var order = !sortable && add && remove ? [] : false;
// Turn bare objects into model references, and prevent invalid models
// from being added.
for (i = 0, l = models.length; i < l; i++) {
- if (!(model = this._prepareModel(models[i], options))) continue;
+ attrs = models[i];
+ if (attrs instanceof Model) {
+ id = model = attrs;
+ } else {
+ id = attrs[targetModel.prototype.idAttribute];
+ }
// If a duplicate is found, prevent it from being added and
// optionally merge it into the existing model.
- if (existing = this.get(model)) {
- if (options.remove) modelMap[existing.cid] = true;
- if (options.merge) {
- existing.set(model.attributes, options);
+ if (existing = this.get(id)) {
+ if (remove) modelMap[existing.cid] = true;
+ if (merge) {
+ attrs = attrs === model ? model.attributes : attrs;
+ if (options.parse) attrs = existing.parse(attrs, options);
+ existing.set(attrs, options);
if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true;
}
+ models[i] = existing;
- // This is a new model, push it to the `toAdd` list.
- } else if (options.add) {
+ // If this is a new, valid model, push it to the `toAdd` list.
+ } else if (add) {
+ model = models[i] = this._prepareModel(attrs, options);
+ if (!model) continue;
toAdd.push(model);
// Listen to added models' events, and index models for lookup by
@@ -695,10 +707,11 @@
this._byId[model.cid] = model;
if (model.id != null) this._byId[model.id] = model;
}
+ if (order) order.push(existing || model);
}
// Remove nonexistent models if appropriate.
- if (options.remove) {
+ if (remove) {
for (i = 0, l = this.length; i < l; ++i) {
if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model);
}
@@ -706,29 +719,35 @@
}
// See if sorting is needed, update `length` and splice in new models.
- if (toAdd.length) {
+ if (toAdd.length || (order && order.length)) {
if (sortable) sort = true;
this.length += toAdd.length;
if (at != null) {
- splice.apply(this.models, [at, 0].concat(toAdd));
+ for (i = 0, l = toAdd.length; i < l; i++) {
+ this.models.splice(at + i, 0, toAdd[i]);
+ }
} else {
- push.apply(this.models, toAdd);
+ if (order) this.models.length = 0;
+ var orderedModels = order || toAdd;
+ for (i = 0, l = orderedModels.length; i < l; i++) {
+ this.models.push(orderedModels[i]);
+ }
}
}
// Silently sort the collection if appropriate.
if (sort) this.sort({silent: true});
- if (options.silent) return this;
-
- // Trigger `add` events.
- for (i = 0, l = toAdd.length; i < l; i++) {
- (model = toAdd[i]).trigger('add', model, this, options);
+ // Unless silenced, it's time to fire all appropriate add/sort events.
+ if (!options.silent) {
+ for (i = 0, l = toAdd.length; i < l; i++) {
+ (model = toAdd[i]).trigger('add', model, this, options);
+ }
+ if (sort || (order && order.length)) this.trigger('sort', this, options);
}
-
- // Trigger `sort` if the collection was sorted.
- if (sort) this.trigger('sort', this, options);
- return this;
+
+ // Return the added (or merged) model (or models).
+ return singular ? models[0] : models;
},
// When you have more items than you want to add or remove individually,
@@ -742,16 +761,14 @@
}
options.previousModels = this.models;
this._reset();
- this.add(models, _.extend({silent: true}, options));
+ models = this.add(models, _.extend({silent: true}, options));
if (!options.silent) this.trigger('reset', this, options);
- return this;
+ return models;
},
// Add a model to the end of the collection.
push: function(model, options) {
- model = this._prepareModel(model, options);
- this.add(model, _.extend({at: this.length}, options));
- return model;
+ return this.add(model, _.extend({at: this.length}, options));
},
// Remove a model from the end of the collection.
@@ -763,9 +780,7 @@
// Add a model to the beginning of the collection.
unshift: function(model, options) {
- model = this._prepareModel(model, options);
- this.add(model, _.extend({at: 0}, options));
- return model;
+ return this.add(model, _.extend({at: 0}, options));
},
// Remove a model from the beginning of the collection.
@@ -776,14 +791,14 @@
},
// Slice out a sub-array of models from the collection.
- slice: function(begin, end) {
- return this.models.slice(begin, end);
+ slice: function() {
+ return slice.apply(this.models, arguments);
},
// Get a model from the set by id.
get: function(obj) {
if (obj == null) return void 0;
- return this._byId[obj.id != null ? obj.id : obj.cid || obj];
+ return this._byId[obj.id] || this._byId[obj.cid] || this._byId[obj];
},
// Get the model at the given index.
@@ -827,16 +842,6 @@
return this;
},
- // Figure out the smallest index at which a model should be inserted so as
- // to maintain order.
- sortedIndex: function(model, value, context) {
- value || (value = this.comparator);
- var iterator = _.isFunction(value) ? value : function(model) {
- return model.get(value);
- };
- return _.sortedIndex(this.models, model, iterator, context);
- },
-
// Pluck an attribute from each model in the collection.
pluck: function(attr) {
return _.invoke(this.models, 'get', attr);
@@ -869,7 +874,7 @@
if (!options.wait) this.add(model, options);
var collection = this;
var success = options.success;
- options.success = function(resp) {
+ options.success = function(model, resp, options) {
if (options.wait) collection.add(model, options);
if (success) success(model, resp, options);
};
@@ -903,14 +908,12 @@
if (!attrs.collection) attrs.collection = this;
return attrs;
}
- options || (options = {});
+ options = options ? _.clone(options) : {};
options.collection = this;
var model = new this.model(attrs, options);
- if (!model._validate(attrs, options)) {
- this.trigger('invalid', this, attrs, options);
- return false;
- }
- return model;
+ if (!model.validationError) return model;
+ this.trigger('invalid', this, model.validationError, options);
+ return false;
},
// Internal method to sever a model's ties to a collection.
@@ -942,8 +945,8 @@
'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
- 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
- 'isEmpty', 'chain'];
+ 'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle',
+ 'lastIndexOf', 'isEmpty', 'chain'];
// Mix in each Underscore method as a proxy to `Collection#models`.
_.each(methods, function(method) {
@@ -982,7 +985,8 @@
// if an existing element is not provided...
var View = Backbone.View = function(options) {
this.cid = _.uniqueId('view');
- this._configure(options || {});
+ options || (options = {});
+ _.extend(this, _.pick(options, viewOptions));
this._ensureElement();
this.initialize.apply(this, arguments);
this.delegateEvents();
@@ -1001,7 +1005,7 @@
tagName: 'div',
// jQuery delegate for element lookup, scoped to DOM elements within the
- // current view. This should be prefered to global lookups where possible.
+ // current view. This should be preferred to global lookups where possible.
$: function(selector) {
return this.$el.find(selector);
},
@@ -1041,7 +1045,7 @@
//
// {
// 'mousedown .title': 'edit',
- // 'click .button': 'save'
+ // 'click .button': 'save',
// 'click .open': function(e) { ... }
// }
//
@@ -1079,16 +1083,6 @@
return this;
},
- // Performs the initial configuration of a View with a set of options.
- // Keys with special meaning *(e.g. model, collection, id, className)* are
- // attached directly to the view. See `viewOptions` for an exhaustive
- // list.
- _configure: function(options) {
- if (this.options) options = _.extend({}, _.result(this, 'options'), options);
- _.extend(this, _.pick(options, viewOptions));
- this.options = options;
- },
-
// Ensure that the View has a DOM element to render into.
// If `this.el` is a string, pass it through `$()`, take the first
// matching element, and re-assign it to `el`. Otherwise, create
@@ -1174,8 +1168,7 @@
// If we're sending a `PATCH` request, and we're in an old Internet Explorer
// that still has ActiveX enabled by default, override jQuery to use that
// for XHR instead. Remove this line when jQuery supports `PATCH` on IE8.
- if (params.type === 'PATCH' && window.ActiveXObject &&
- !(window.external && window.external.msActiveXFilteringEnabled)) {
+ if (params.type === 'PATCH' && noXhrPatch) {
params.xhr = function() {
return new ActiveXObject("Microsoft.XMLHTTP");
};
@@ -1187,6 +1180,8 @@
return xhr;
};
+ var noXhrPatch = typeof window !== 'undefined' && !!window.ActiveXObject && !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
+
// Map from CRUD to HTTP for our default `Backbone.sync` implementation.
var methodMap = {
'create': 'POST',
@@ -1275,7 +1270,7 @@
_routeToRegExp: function(route) {
route = route.replace(escapeRegExp, '\\$&')
.replace(optionalParam, '(?:$1)?')
- .replace(namedParam, function(match, optional){
+ .replace(namedParam, function(match, optional) {
return optional ? match : '([^\/]+)';
})
.replace(splatParam, '(.*?)');
@@ -1325,6 +1320,9 @@
// Cached regex for removing a trailing slash.
var trailingSlash = /\/$/;
+ // Cached regex for stripping urls of hash and query.
+ var pathStripper = /[?#].*$/;
+
// Has the history handling already been started?
History.started = false;
@@ -1349,7 +1347,7 @@
if (this._hasPushState || !this._wantsHashChange || forcePushState) {
fragment = this.location.pathname;
var root = this.root.replace(trailingSlash, '');
- if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);
+ if (!fragment.indexOf(root)) fragment = fragment.slice(root.length);
} else {
fragment = this.getHash();
}
@@ -1365,7 +1363,7 @@
// Figure out the initial configuration. Do we need an iframe?
// Is pushState desired ... is it available?
- this.options = _.extend({}, {root: '/'}, this.options, options);
+ this.options = _.extend({root: '/'}, this.options, options);
this.root = this.options.root;
this._wantsHashChange = this.options.hashChange !== false;
this._wantsPushState = !!this.options.pushState;
@@ -1398,19 +1396,25 @@
var loc = this.location;
var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;
- // If we've started off with a route from a `pushState`-enabled browser,
- // but we're currently in a browser that doesn't support it...
- if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) {
- this.fragment = this.getFragment(null, true);
- this.location.replace(this.root + this.location.search + '#' + this.fragment);
- // Return immediately as browser will do redirect to new url
- return true;
+ // Transition from hashChange to pushState or vice versa if both are
+ // requested.
+ if (this._wantsHashChange && this._wantsPushState) {
+
+ // If we've started off with a route from a `pushState`-enabled
+ // browser, but we're currently in a browser that doesn't support it...
+ if (!this._hasPushState && !atRoot) {
+ this.fragment = this.getFragment(null, true);
+ this.location.replace(this.root + this.location.search + '#' + this.fragment);
+ // Return immediately as browser will do redirect to new url
+ return true;
+
+ // Or if we've started out with a hash-based route, but we're currently
+ // in a browser where it could be `pushState`-based instead...
+ } else if (this._hasPushState && atRoot && loc.hash) {
+ this.fragment = this.getHash().replace(routeStripper, '');
+ this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
+ }
- // Or if we've started out with a hash-based route, but we're currently
- // in a browser where it could be `pushState`-based instead...
- } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
- this.fragment = this.getHash().replace(routeStripper, '');
- this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
}
if (!this.options.silent) return this.loadUrl();
@@ -1439,21 +1443,20 @@
}
if (current === this.fragment) return false;
if (this.iframe) this.navigate(current);
- this.loadUrl() || this.loadUrl(this.getHash());
+ this.loadUrl();
},
// Attempt to load the current URL fragment. If a route succeeds with a
// match, returns `true`. If no defined routes matches the fragment,
// returns `false`.
- loadUrl: function(fragmentOverride) {
- var fragment = this.fragment = this.getFragment(fragmentOverride);
- var matched = _.any(this.handlers, function(handler) {
+ loadUrl: function(fragment) {
+ fragment = this.fragment = this.getFragment(fragment);
+ return _.any(this.handlers, function(handler) {
if (handler.route.test(fragment)) {
handler.callback(fragment);
return true;
}
});
- return matched;
},
// Save a fragment into the hash history, or replace the URL state if the
@@ -1465,11 +1468,20 @@
// you wish to modify the current URL without adding an entry to the history.
navigate: function(fragment, options) {
if (!History.started) return false;
- if (!options || options === true) options = {trigger: options};
- fragment = this.getFragment(fragment || '');
+ if (!options || options === true) options = {trigger: !!options};
+
+ var url = this.root + (fragment = this.getFragment(fragment || ''));
+
+ // GARREN -this line doesn't make any sense and removes query code. New release of Backbone
+ // Should fix this
+ // Strip the fragment of the query and hash for matching.
+ //fragment = fragment.replace(pathStripper, '');
+
if (this.fragment === fragment) return;
this.fragment = fragment;
- var url = this.root + fragment;
+
+ // Don't include a trailing slash on the root.
+ if (fragment === '' && url !== '/') url = url.slice(0, -1);
// If pushState is available, we use it to set the fragment as a real URL.
if (this._hasPushState) {
@@ -1492,7 +1504,7 @@
} else {
return this.location.assign(url);
}
- if (options.trigger) this.loadUrl(fragment);
+ if (options.trigger) return this.loadUrl(fragment);
},
// Update the hash location, either replacing the current entry, or adding
@@ -1560,7 +1572,7 @@
};
// Wrap an optional error callback with a fallback error event.
- var wrapError = function (model, options) {
+ var wrapError = function(model, options) {
var error = options.error;
options.error = function(resp) {
if (error) error(model, resp, options);
[15/50] [abbrv] Fauxton: move modules to addons
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
new file mode 100644
index 0000000..a9f45ad
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -0,0 +1,337 @@
+// 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('ace_configuration', ["app", "ace/ace"], function (app, ace) {
+ var path = app.host + app.root + 'js/ace';
+ var config = require("ace/config");
+ config.set("packaged", true);
+ config.set("workerPath",path);
+ config.set("modePath",path);
+ config.set("themePath", path);
+ return ace;
+});
+
+define([
+ "app",
+ // Libs
+ "api",
+ "ace_configuration",
+],
+
+function(app, FauxtonAPI, ace) {
+ var Components = app.module();
+
+ Components.Pagination = FauxtonAPI.View.extend({
+ template: "templates/fauxton/pagination",
+
+ initialize: function(options) {
+ this.page = parseInt(options.page, 10);
+ 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
+ };
+ }
+ });
+
+ Components.IndexPagination = FauxtonAPI.View.extend({
+ template: "templates/fauxton/index_pagination",
+ events: {
+ "click a": 'scrollTo',
+ "click a#next": 'nextClicked',
+ "click a#previous": 'previousClicked'
+ },
+
+ scrollTo: function () {
+ if (!this.scrollToSelector) { return; }
+ $(this.scrollToSelector).animate({ scrollTop: 0 }, 'slow');
+ },
+
+ initialize: function (options) {
+ this.previousUrlfn = options.previousUrlfn;
+ this.nextUrlfn = options.nextUrlfn;
+ this.canShowPreviousfn = options.canShowPreviousfn;
+ this.canShowNextfn = options.canShowNextfn;
+ this.scrollToSelector = options.scrollToSelector;
+ _.bindAll(this);
+ this.previousParams = [];
+ },
+
+ previousClicked: function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!this.canShowPreviousfn()) { return; }
+ FauxtonAPI.navigate(this.previousUrlfn(), {trigger: false});
+ FauxtonAPI.triggerRouteEvent('paginate', 'previous');
+ },
+
+ nextClicked: function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!this.canShowNextfn()) { return; }
+
+ var params = _.clone(this.collection.params);
+
+ if (params) {
+ this.previousParams.push(params);
+ }
+
+ FauxtonAPI.navigate(this.nextUrlfn(), {trigger: false});
+ FauxtonAPI.triggerRouteEvent('paginate', 'next');
+ },
+
+ serialize: function () {
+ return {
+ canShowNextfn: this.canShowNextfn,
+ canShowPreviousfn: this.canShowPreviousfn,
+ };
+ },
+
+ pageLimit: function () {
+ var limit = 20;
+
+ if (this.collection.params.limit && this.collection.skipFirstItem) {
+ limit = parseInt(this.collection.params.limit, 10) - 1;
+ } else if (this.collection.params.limit) {
+ limit = parseInt(this.collection.params.limit, 10);
+ }
+
+ return limit;
+ },
+
+ pageStart: function () {
+ return (this.previousParams.length * this.pageLimit()) + 1;
+
+ },
+
+ pageEnd: function () {
+ return (this.previousParams.length * this.pageLimit()) + this.pageLimit();
+ }
+
+ });
+
+ //TODO allow more of the typeahead options.
+ //Current this just does what we need but we
+ //need to support the other typeahead options.
+ Components.Typeahead = FauxtonAPI.View.extend({
+
+ initialize: function (options) {
+ this.source = options.source;
+ _.bindAll(this);
+ },
+
+ afterRender: function () {
+ var onUpdate = this.onUpdate;
+
+ this.$el.typeahead({
+ source: this.source,
+ updater: function (item) {
+ if (onUpdate) {
+ onUpdate(item);
+ }
+
+ return item;
+ }
+ });
+ }
+
+ });
+
+
+ Components.DbSearchTypeahead = Components.Typeahead.extend({
+ initialize: function (options) {
+ this.dbLimit = options.dbLimit || 30;
+ this.onUpdate = options.onUpdate;
+ _.bindAll(this);
+ },
+ source: function(query, process) {
+ var url = [
+ app.host,
+ "/_all_dbs?startkey=%22",
+ query,
+ "%22&endkey=%22",
+ query,
+ "\u9999",
+ "%22&limit=",
+ this.dbLimit
+ ].join('');
+
+ if (this.ajaxReq) { this.ajaxReq.abort(); }
+
+ this.ajaxReq = $.ajax({
+ cache: false,
+ url: url,
+ dataType: 'json',
+ success: function(data) {
+ process(data);
+ }
+ });
+ }
+ });
+
+ Components.DocSearchTypeahead = Components.Typeahead.extend({
+ initialize: function (options) {
+ this.docLimit = options.docLimit || 30;
+ this.database = options.database;
+ _.bindAll(this);
+ },
+ source: function(query, process) {
+ var url = [
+ app.host,
+ "/",
+ this.database.id,
+ "/_all_docs?startkey=%22",
+ query,
+ "%22&endkey=%22",
+ query,
+ "\u9999",
+ "%22&limit=",
+ this.docLimit
+ ].join('');
+
+ if (this.ajaxReq) { this.ajaxReq.abort(); }
+
+ this.ajaxReq = $.ajax({
+ cache: false,
+ url: url,
+ dataType: 'json',
+ success: function(data) {
+ var ids = _.map(data.rows, function (row) {
+ return row.id;
+ });
+ process(ids);
+ }
+ });
+ }
+ });
+
+ Components.Editor = FauxtonAPI.View.extend({
+ initialize: function (options) {
+ this.editorId = options.editorId;
+ this.mode = options.mode || "json";
+ this.commands = options.commands;
+ this.theme = options.theme || 'crimson_editor';
+ this.couchJSHINT = options.couchJSHINT;
+ this.edited = false;
+ },
+
+ afterRender: function () {
+ this.editor = ace.edit(this.editorId);
+ this.setHeightToLineCount();
+ this.editor.setTheme("ace/theme/" + this.theme);
+ this.editor.getSession().setMode("ace/mode/" + this.mode);
+ this.editor.getSession().setUseWrapMode(true);
+ this.editor.setShowPrintMargin(false);
+ this.editor.gotoLine(2);
+ this.addCommands();
+
+ if (this.couchJSHINT) {
+ this.removeIncorrectAnnotations();
+ }
+
+ var that = this;
+ this.editor.getSession().on('change', function () {
+ that.setHeightToLineCount();
+ that.edited = true;
+ });
+
+ $(window).on('beforeunload.editor', function() {
+ if (that.edited) {
+ return 'Your changes have not been saved. Click cancel to return to the document.';
+ }
+ });
+
+ FauxtonAPI.beforeUnload("editor", function (deferred) {
+ if (that.edited) {
+ return 'Your changes have not been saved. Click cancel to return to the document.';
+ }
+ });
+ },
+
+ cleanup: function () {
+ $(window).off('beforeunload.editor');
+ FauxtonAPI.removeBeforeUnload("editor");
+ },
+
+ setHeightToLineCount: function () {
+ var lines = this.editor.getSession().getDocument().getLength();
+ this.editor.setOptions({
+ maxLines: lines
+ });
+
+ this.editor.resize();
+ },
+
+ addCommands: function () {
+ _.each(this.commands, function (command) {
+ this.editor.commands.addCommand(command);
+ }, this);
+ },
+
+ removeIncorrectAnnotations: function () {
+ var editor = this.editor;
+
+ this.editor.getSession().on("changeAnnotation", function(){
+ var annotations = editor.getSession().getAnnotations();
+
+ var newAnnotations = _.reduce(annotations, function (annotations, error) {
+ if (!FauxtonAPI.isIgnorableError(error.raw)) {
+ annotations.push(error);
+ }
+ return annotations;
+ }, []);
+
+ if (annotations.length !== newAnnotations.length) {
+ editor.getSession().setAnnotations(newAnnotations);
+ }
+ });
+ },
+
+ editSaved: function () {
+ this.edited = false;
+ },
+
+ setValue: function (data, lineNumber) {
+ lineNumber = lineNumber ? lineNumber : -1;
+ this.editor.setValue(data, lineNumber);
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ getAnnotations: function () {
+ return this.editor.getSession().getAnnotations();
+ },
+
+ hadValidCode: function () {
+ var errors = this.getAnnotations();
+ // By default CouchDB view functions don't pass lint
+ return _.every(errors, function(error) {
+ return FauxtonAPI.isIgnorableError(error.raw);
+ },this);
+ }
+
+ });
+
+ return Components;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/layout.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/layout.js b/src/fauxton/app/addons/fauxton/layout.js
new file mode 100644
index 0000000..1422241
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/layout.js
@@ -0,0 +1,98 @@
+// 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
+ },
+ afterRender: function(){
+
+ }
+ });
+
+ 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/89810cce/src/fauxton/app/addons/fauxton/templates/api_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/api_bar.html b/src/fauxton/app/addons/fauxton/templates/api_bar.html
new file mode 100644
index 0000000..1f03a2c
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/api_bar.html
@@ -0,0 +1,30 @@
+<!--
+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.
+-->
+
+<button class="button api-url-btn">
+ API URL
+ <span class="fonticon-plus icon"></span>
+</button>
+<div class="api-navbar" style="display: none">
+ <div class="input-prepend input-append">
+ <span class="add-on">
+ API reference
+ <a href="<%=getDocUrl(documentation)%>" target="_blank">
+ <i class="icon-question-sign"></i>
+ </a>
+ </span>
+ <input type="text" class="input-xxlarge" value="<%= endpoint %>">
+ <a href="<%= endpoint %>" target="_blank" class="btn">Show me</a>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/templates/breadcrumbs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/breadcrumbs.html b/src/fauxton/app/addons/fauxton/templates/breadcrumbs.html
new file mode 100644
index 0000000..026db89
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/breadcrumbs.html
@@ -0,0 +1,24 @@
+<!--
+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.
+-->
+
+<ul class="breadcrumb">
+ <% _.each(_.initial(crumbs), function(crumb) { %>
+ <li>
+ <a href="#<%= crumb.link %>"><%= crumb.name %></a>
+ <span class="divider fonticon fonticon-carrot"> </span>
+ </li>
+ <% }); %>
+ <% var last = _.last(crumbs) || {name: ''} %>
+ <li class="active"><%= last.name %></li>
+</ul>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/templates/footer.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/footer.html b/src/fauxton/app/addons/fauxton/templates/footer.html
new file mode 100644
index 0000000..593c11f
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/footer.html
@@ -0,0 +1,15 @@
+<!--
+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.
+-->
+
+<p>Fauxton on <a href="http://couchdb.apache.org/">Apache CouchDB</a> <%=version%></p>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/templates/index_pagination.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/index_pagination.html b/src/fauxton/app/addons/fauxton/templates/index_pagination.html
new file mode 100644
index 0000000..f445377
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/index_pagination.html
@@ -0,0 +1,24 @@
+<!--
+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="pagination pagination-centered">
+ <ul>
+ <li <% if (!canShowPreviousfn()) {%> class="disabled" <% } %>>
+ <a id="previous" href="#"> Previous </a>
+ </li>
+ <li <% if (!canShowNextfn()) {%> class="disabled" <% } %>>
+ <a id="next" href="#"> Next </a></li>
+ </ul>
+</div>
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/templates/nav_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/nav_bar.html b/src/fauxton/app/addons/fauxton/templates/nav_bar.html
new file mode 100644
index 0000000..da030d6
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/nav_bar.html
@@ -0,0 +1,75 @@
+<!--
+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="brand">
+ <div class="burger">
+ <div><!-- * --></div>
+ <div><!-- * --></div>
+ <div><!-- * --></div>
+ </div>
+ <div class="icon">Apache Fauxton</div>
+</div>
+
+<nav id="main_navigation">
+ <ul id="nav-links" class="nav pull-right">
+ <% _.each(navLinks, function(link) { %>
+ <% if (link.view) {return;} %>
+ <li data-nav-name= "<%= link.title %>" >
+ <a href="<%= link.href %>">
+ <span class="<%= link.icon %> fonticon"></span>
+ <%= link.title %>
+ </a>
+ </li>
+ <% }); %>
+ </ul>
+
+ <div id="footer-links">
+
+ <ul id="bottom-nav-links" class="nav">
+ <li data-nav-name= "Documentation">
+ <a href="<%=getDocUrl('docs')%>" target="_blank">
+ <span class="fonticon-bookmark fonticon"></span>
+ Documentation
+ </a>
+ </li>
+
+
+ <% _.each(bottomNavLinks, function(link) { %>
+ <% if (link.view) {return;} %>
+ <li data-nav-name= "<%= link.title %>">
+ <a href="<%= link.href %>">
+ <span class="<%= link.icon %> fonticon"></span>
+ <%= link.title %>
+ </a>
+ </li>
+ <% }); %>
+ </ul>
+
+ <ul id="footer-nav-links" class="nav">
+ <% _.each(footerNavLinks, function(link) { %>
+ <% if (link.view) {return;} %>
+ <li data-nav-name= "<%= link.title %>">
+ <a href="<%= link.href %>">
+ <span class="<%= link.icon %> fonticon"></span>
+ <%= link.title %>
+ </a>
+ </li>
+ <% }); %>
+ </ul>
+
+ </div>
+</nav>
+
+
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/templates/notification.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/notification.html b/src/fauxton/app/addons/fauxton/templates/notification.html
new file mode 100644
index 0000000..ca8a903
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/notification.html
@@ -0,0 +1,18 @@
+<!--
+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="alert alert-<%= type %>">
+ <button type="button" class="close" data-dismiss="alert">×</button>
+ <%= msg %>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/fauxton/templates/pagination.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/pagination.html b/src/fauxton/app/addons/fauxton/templates/pagination.html
new file mode 100644
index 0000000..19dfc8c
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/pagination.html
@@ -0,0 +1,31 @@
+<!--
+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="pagination pagination-centered">
+ <ul>
+ <% if (page > 1) { %>
+ <li> <a href="<%= urlFun(page-1) %>">«</a></li>
+ <% } else { %>
+ <li class="disabled"> <a href="<%= urlFun(page) %>">«</a></li>
+ <% } %>
+ <% _.each(_.range(1, totalPages+1), function(i) { %>
+ <li <% if (page == i) { %>class="active"<% } %>> <a href="<%= urlFun(i) %>"><%= i %></a></li>
+ <% }) %>
+ <% if (page < totalPages) { %>
+ <li><a href="<%= urlFun(page+1) %>">»</a></li>
+ <% } else { %>
+ <li class="disabled"> <a href="<%= urlFun(page) %>">»</a></li>
+ <% } %>
+ </ul>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/permissions/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/routes.js b/src/fauxton/app/addons/permissions/routes.js
index 89c2bd7..0e9fa52 100644
--- a/src/fauxton/app/addons/permissions/routes.js
+++ b/src/fauxton/app/addons/permissions/routes.js
@@ -13,7 +13,7 @@
define([
"app",
"api",
- "modules/databases/base",
+ "addons/databases/base",
"addons/permissions/views"
],
function (app, FauxtonAPI, Databases, Permissions) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/pouchdb/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/base.js b/src/fauxton/app/addons/pouchdb/base.js
new file mode 100644
index 0000000..df6c726
--- /dev/null
+++ b/src/fauxton/app/addons/pouchdb/base.js
@@ -0,0 +1,47 @@
+/*
+ * 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
+ "addons/pouchdb/pouchdb.mapreduce.js"
+],
+
+function(app, FauxtonAPI, MapReduce) {
+ var Pouch = FauxtonAPI.addon();
+ 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/89810cce/src/fauxton/app/addons/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/pouch.collate.js b/src/fauxton/app/addons/pouchdb/pouch.collate.js
new file mode 100644
index 0000000..6c64410
--- /dev/null
+++ b/src/fauxton/app/addons/pouchdb/pouch.collate.js
@@ -0,0 +1,115 @@
+/*
+ * 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
+ "addons/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/89810cce/src/fauxton/app/addons/pouchdb/pouchdb.mapreduce.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/pouchdb.mapreduce.js b/src/fauxton/app/addons/pouchdb/pouchdb.mapreduce.js
new file mode 100644
index 0000000..224a6f6
--- /dev/null
+++ b/src/fauxton/app/addons/pouchdb/pouchdb.mapreduce.js
@@ -0,0 +1,324 @@
+/*
+ * 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
+ "addons/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/89810cce/src/fauxton/app/addons/replication/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/views.js b/src/fauxton/app/addons/replication/views.js
index f4b96fd..1b31a9d 100644
--- a/src/fauxton/app/addons/replication/views.js
+++ b/src/fauxton/app/addons/replication/views.js
@@ -13,7 +13,7 @@
define([
"app",
"api",
- "modules/fauxton/components",
+ "addons/fauxton/components",
"addons/replication/resources"
],
function(app, FauxtonAPI, Components, replication) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/stats/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/resources.js b/src/fauxton/app/addons/stats/resources.js
index a761e6b..b3c4ce1 100644
--- a/src/fauxton/app/addons/stats/resources.js
+++ b/src/fauxton/app/addons/stats/resources.js
@@ -15,7 +15,7 @@ define([
"api",
"backbone",
"lodash",
- "modules/fauxton/base"
+ "addons/fauxton/base"
],
function (app, FauxtonAPI, backbone, _, Fauxton) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/verifyinstall/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/resources.js b/src/fauxton/app/addons/verifyinstall/resources.js
index 5d83f9a..8a98883 100644
--- a/src/fauxton/app/addons/verifyinstall/resources.js
+++ b/src/fauxton/app/addons/verifyinstall/resources.js
@@ -13,8 +13,8 @@
define([
"app",
"api",
- "modules/databases/resources",
- "modules/documents/resources"
+ "addons/databases/resources",
+ "addons/documents/resources"
],
function (app, FauxtonAPI, Databases, Documents) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 5ad032a..c9d08bf 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -14,7 +14,7 @@ define([
"app",
// Modules
- "modules/fauxton/base",
+ "addons/fauxton/base",
"spin"
],
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 0a51410..9ac5bc2 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -22,6 +22,8 @@ define([
"helpers",
"mixins",
+ // Modules
+ "resizeColumns",
// Plugins.
"plugins/backbone.layoutmanager",
@@ -29,7 +31,7 @@ define([
],
-function(app, $, _, Backbone, Bootstrap, Helpers, Mixins) {
+function(app, $, _, Backbone, Bootstrap, Helpers, Mixins, resizeColumns) {
// Make sure we have a console.log
if (typeof console == "undefined") {
@@ -81,6 +83,10 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Mixins) {
}
});
+ //resizeAnimation
+ app.resizeColumns = new resizeColumns({});
+ app.resizeColumns.onResizeHandler();
+
// Localize or create a new JavaScript Template object.
var JST = window.JST = window.JST || {};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/databases/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/base.js b/src/fauxton/app/modules/databases/base.js
deleted file mode 100644
index 6ff12c6..0000000
--- a/src/fauxton/app/modules/databases/base.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/databases/routes",
- // Views
- "modules/databases/views"
-
-],
-
-function(app, FauxtonAPI, Databases, Views) {
- Databases.Views = Views;
-
- // Utility functions
- Databases.databaseUrl = function(database) {
- var name = _.isObject(database) ? database.id : database,
- dbname = app.mixins.safeURLName(name);
-
- return ["/database/", dbname, "/_all_docs?limit=" + Databases.DocLimit].join('');
- };
-
- return Databases;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js
deleted file mode 100644
index f3bde80..0000000
--- a/src/fauxton/app/modules/databases/resources.js
+++ /dev/null
@@ -1,193 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/documents/resources"
-],
-
-function(app, FauxtonAPI, Documents) {
- var Databases = FauxtonAPI.module();
-
- Databases.DocLimit = 20;
-
- Databases.Model = Backbone.Model.extend({
- initialize: function(options) {
- this.status = new Databases.Status({
- database: this
- });
- },
-
- documentation: function(){
- return "all_dbs";
- },
-
- buildAllDocs: function(params) {
- this.allDocs = new Documents.AllDocs(null, {
- database: this,
- params: params
- });
-
- return this.allDocs;
- },
-
- isNew: function(){
- // Databases are never new, to make Backbone do a PUT
- return false;
- },
-
- url: function(context) {
- if (context === "index") {
- return "/database/" + this.safeID() + "/_all_docs";
- } else if (context === "web-index") {
- return "#/database/"+ this.safeID() + "/_all_docs?limit=" + Databases.DocLimit;
- } else if (context === "apiurl") {
- return window.location.origin + "/database/" + this.safeID() + "/_all_docs";
- } else if (context === "changes") {
- return "/database/" + this.safeID() + "/_changes?descending=true&limit=100&include_docs=true";
- } else if (context === "changes-apiurl") {
- return window.location.origin + "/database/" + this.safeID() + "/_changes?descending=true&limit=100&include_docs=true";
- } else if (context === "app") {
- return "/database/" + this.safeID();
- } else {
- return app.host + "/" + this.safeID();
- }
- },
- safeName: function(){
- return app.mixins.safeURLName(this.get("name"));
- },
- safeID: function() {
- return app.mixins.safeURLName(this.id);
- },
- buildChanges: function (params) {
- this.changes = new Databases.Changes({
- database: this,
- params: params
- });
-
- return this.changes;
- }
- });
-
- Databases.Changes = Backbone.Collection.extend({
-
- initialize: function(options) {
- this.database = options.database;
- this.params = options.params;
- },
- documentation: function(){
- return "changes";
- },
- url: function (context) {
- var query = "";
- if (this.params) {
- query = "?" + $.param(this.params);
- }
- if (context === "apiurl") {
- return window.location.origin + '/' + this.database.safeID() + '/_changes' + query;
- } else {
-
- return app.host + '/' + this.database.safeID() + '/_changes' + query;
- }
- },
-
- parse: function (resp) {
- this.last_seq = resp.last_seq;
- return resp.results;
- }
- });
-
- Databases.Status = Backbone.Model.extend({
- url: function() {
- return app.host + "/" + this.database.safeID();
- },
-
- initialize: function(options) {
- this.database = options.database;
- },
-
- numDocs: function() {
- return this.get("doc_count");
- },
-
- updateSeq: function(full) {
- var updateSeq = this.get("update_seq");
- if (full || (typeof(updateSeq) === 'number')) {
- return updateSeq;
- } else if (updateSeq) {
- return updateSeq.split('-')[0];
- } else {
- return 0;
- }
- },
-
- humanSize: function() {
- // cribbed from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable
- var i = -1;
- var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
- var fileSizeInBytes = this.dataSize();
-
- if (!fileSizeInBytes) {
- return 0;
- }
-
- do {
- fileSizeInBytes = fileSizeInBytes / 1024;
- i++;
- } while (fileSizeInBytes > 1024);
-
- return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
- },
- diskSize: function () {
- return this.get("disk_size");
- },
-
- dataSize: function () {
- if (this.get("other")){
- return this.get("other").data_size;
- }else{
- return 0;
- }
- }
- });
-
- // TODO: shared databases - read from the user doc
- Databases.List = Backbone.Collection.extend({
- model: Databases.Model,
- documentation: function(){
- return "all_dbs";
- },
- url: function(context) {
- if (context === "apiurl") {
- return window.location.origin + "/_all_dbs";
- } else {
- return app.host + "/_all_dbs";
- }
- },
-
- parse: function(resp) {
- // TODO: pagination!
- return _.map(resp, function(database) {
- return {
- id: app.mixins.safeURLName(database),
- name: database
- };
- });
- }
- });
-
- return Databases;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js
deleted file mode 100644
index ca3d640..0000000
--- a/src/fauxton/app/modules/databases/routes.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/databases/resources",
- // TODO:: fix the include flow modules so we don't have to require views here
- "modules/databases/views"
-],
-
-function(app, FauxtonAPI, Databases, Views) {
-
- var AllDbsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "one_pane",
-
- crumbs: [
- {"name": "Databases", "link": "/_all_dbs"}
- ],
-
- routes: {
- "": "allDatabases",
- "index.html": "allDatabases",
- "_all_dbs(:params)": "allDatabases"
- },
-
- apiUrl: function() {
- return [this.databases.url("apiurl"), this.databases.documentation()];
- },
-
- selectedHeader: "Databases",
-
- initialize: function() {
- this.databases = new Databases.List();
- this.deferred = FauxtonAPI.Deferred();
- },
-
- allDatabases: function() {
- var params = app.getParams(),
- dbPage = params.page;
-
- this.databasesView = this.setView("#dashboard-content", new Views.List({
- collection: this.databases
- }));
-
- this.databasesView.setPage(dbPage);
- },
-
- establish: function() {
- return [this.databases.fetch()];
- }
- });
-
- Databases.RouteObjects = [AllDbsRouteObject];
-
- return Databases;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/views.js b/src/fauxton/app/modules/databases/views.js
deleted file mode 100644
index dbeb475..0000000
--- a/src/fauxton/app/modules/databases/views.js
+++ /dev/null
@@ -1,255 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- "modules/fauxton/components",
- "api",
- "modules/databases/resources"
-],
-
-function(app, Components, FauxtonAPI, Databases) {
- var Views = {};
-
- Views.Item = FauxtonAPI.View.extend({
- template: "templates/databases/item",
- tagName: "tr",
- establish: function(){
- return [this.model.fetch()];
- },
- serialize: function() {
- return {
- encoded: app.mixins.safeURLName(this.model.get("name")),
- database: this.model,
- docLimit: Databases.DocLimit
- };
- }
- });
-
- Views.List = FauxtonAPI.View.extend({
- dbLimit: 20,
- perPage: 20,
- template: "templates/databases/list",
- events: {
- "click button.all": "selectAll",
- "submit form#jump-to-db": "switchDatabase"
- },
-
- initialize: function(options) {
- var params = app.getParams();
- this.page = params.page ? parseInt(params.page, 10) : 1;
- },
-
- serialize: function() {
- return {
- databases: this.collection
- };
- },
- establish: function(){
- var currentDBs = this.paginated();
- var deferred = FauxtonAPI.Deferred();
-
- FauxtonAPI.when(currentDBs.map(function(database) {
- return database.status.fetch();
- })).always(function(resp) {
- //make this always so that even if a user is not allowed access to a database
- //they will still see a list of all databases
- deferred.resolve();
- });
- return [deferred];
- },
- switchDatabase: function(event, selectedName) {
- event && event.preventDefault();
-
- var dbname = this.$el.find("[name='search-query']").val().trim();
-
- if (selectedName) {
- dbname = selectedName;
- }
-
- if (dbname && this.collection.where({"id":app.mixins.safeURLName(dbname)}).length > 0){
- // TODO: switch to using a model, or Databases.databaseUrl()
- // Neither of which are in scope right now
- // var db = new Database.Model({id: dbname});
- var url = ["/database/", app.mixins.safeURLName(dbname), "/_all_docs?limit=" + Databases.DocLimit].join('');
- FauxtonAPI.navigate(url);
- } else {
- FauxtonAPI.addNotification({
- msg: 'Database does not exist.',
- type: 'error'
- });
- }
- },
-
- paginated: function() {
- var start = (this.page - 1) * this.perPage;
- var end = this.page * this.perPage;
- return this.collection.slice(start, end);
- },
-
- beforeRender: function() {
-
- this.insertView("#newButton", new Views.NewDatabaseButton({
- collection: this.collection
- }));
-
- _.each(this.paginated(), function(database) {
- this.insertView("table.databases tbody", new Views.Item({
- model: database
- }));
- }, this);
-
- this.insertView("#database-pagination", new Components.Pagination({
- page: this.page,
- perPage: this.perPage,
- total: this.collection.length,
- urlFun: function(page) {
- return "#/_all_dbs?page=" + page;
- }
- }));
- },
-
- setPage: function(page) {
- this.page = page || 1;
- },
-
- afterRender: function() {
- var that = this;
- this.dbSearchTypeahead = new Components.DbSearchTypeahead({
- dbLimit: this.dbLimit,
- el: "input.search-autocomplete",
- onUpdate: function (item) {
- that.switchDatabase(null, item);
- }
- });
-
- this.dbSearchTypeahead.render();
- },
-
- selectAll: function(evt){
- $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
- }
- });
-
-
- Views.NewDatabaseButton = FauxtonAPI.View.extend({
- template: "templates/databases/newdatabase",
- events: {
- "click a#new": "newDatabase"
- },
- newDatabase: function() {
- var notification;
- var db;
- // TODO: use a modal here instead of the prompt
- var name = prompt('Name of database', 'newdatabase');
- if (name === null) {
- return;
- } else if (name.length === 0) {
- notification = FauxtonAPI.addNotification({
- msg: "Please enter a valid database name",
- type: "error",
- clear: true
- });
- return;
- }
- db = new this.collection.model({
- id: name,
- name: name
- });
- notification = FauxtonAPI.addNotification({msg: "Creating database."});
- db.save().done(function() {
- notification = FauxtonAPI.addNotification({
- msg: "Database created successfully",
- type: "success",
- clear: true
- });
- var route = "#/database/" + app.mixins.safeURLName(name) + "/_all_docs?limit=" + Databases.DocLimit;
- app.router.navigate(route, { trigger: true });
- }
- ).error(function(xhr) {
- var responseText = JSON.parse(xhr.responseText).reason;
- notification = FauxtonAPI.addNotification({
- msg: "Create database failed: " + responseText,
- type: "error",
- clear: true
- });
- }
- );
- }
- });
-
- Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/databases/sidebar",
- events: {
- "click a#new": "newDatabase",
- "click a#owned": "showMine",
- "click a#shared": "showShared"
- },
-
- newDatabase: function() {
- var notification;
- var db;
- // TODO: use a modal here instead of the prompt
- var name = prompt('Name of database', 'newdatabase');
- if (name === null) {
- return;
- } else if (name.length === 0) {
- notification = FauxtonAPI.addNotification({
- msg: "Please enter a valid database name",
- type: "error",
- clear: true
- });
- return;
- }
- db = new this.collection.model({
- id: encodeURIComponent(name),
- name: name
- });
- notification = FauxtonAPI.addNotification({msg: "Creating database."});
- db.save().done(function() {
- notification = FauxtonAPI.addNotification({
- msg: "Database created successfully",
- type: "success",
- clear: true
- });
- var route = "#/database/" + name + "/_all_docs?limit=" + Databases.DocLimit;
- app.router.navigate(route, { trigger: true });
- }
- ).error(function(xhr) {
- var responseText = JSON.parse(xhr.responseText).reason;
- notification = FauxtonAPI.addNotification({
- msg: "Create database failed: " + responseText,
- type: "error",
- clear: true
- });
- }
- );
- },
-
- showMine: function(){
- $.contribute(
- 'Show unshared databases',
- 'app/addons/databases/views.js'
- );
- },
-
- showShared: function(){
- $.contribute(
- 'Show shared databases (e.g. continuous replications to/from the database)',
- 'app/addons/databases/views.js'
- );
- }
- });
-
- return Views;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/documents/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/base.js b/src/fauxton/app/modules/documents/base.js
deleted file mode 100644
index 96e4ada..0000000
--- a/src/fauxton/app/modules/documents/base.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/documents/routes"
-],
-
-function(app, FauxtonAPI, Documents) {
- return Documents;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
deleted file mode 100644
index 43bb0fd..0000000
--- a/src/fauxton/app/modules/documents/resources.js
+++ /dev/null
@@ -1,646 +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"
-],
-
-function(app, FauxtonAPI) {
- var Documents = app.module();
-
- Documents.Doc = Backbone.Model.extend({
- idAttribute: "_id",
- documentation: function(){
- return "docs";
- },
- 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 if (context === "apiurl"){
- return window.location.origin + "/" + this.getDatabase().safeID() + "/" + this.safeID();
- } else {
- return app.host + "/" + this.getDatabase().safeID() + "/" + this.safeID();
- }
- },
-
- initialize: function(_attrs, options) {
- if (this.collection && this.collection.database) {
- this.database = this.collection.database;
- } else if (options.database) {
- this.database = options.database;
- }
- },
-
- // HACK: the doc needs to know about the database, but it may be
- // set directly or indirectly in all docs
- getDatabase: function() {
- return this.database ? this.database : this.collection.database;
- },
-
- validate: function(attrs, options) {
- if (this.id && this.id !== attrs._id && this.get('_rev') ) {
- return "Cannot change a documents id.";
- }
- },
-
- docType: function() {
- return this.id.match(/^_design/) ? "design doc" : "doc";
- },
-
- isEditable: function() {
- return this.docType() != "reduction";
- },
-
- isDdoc: function() {
- return this.docType() === "design doc";
- },
-
- hasViews: function() {
- if (!this.isDdoc()) return false;
- var doc = this.get('doc');
- if (doc) {
- return doc && doc.views && _.keys(doc.views).length > 0;
- }
-
- var views = this.get('views');
- return views && _.keys(views).length > 0;
- },
-
- hasAttachments: function () {
- return !!this.get('_attachments');
- },
-
- getDdocView: function(view) {
- if (!this.isDdoc() || !this.hasViews()) return false;
-
- var doc = this.get('doc');
- if (doc) {
- return doc.views[view];
- }
-
- return this.get('views')[view];
- },
-
- setDdocView: function (view, map, reduce) {
- if (!this.isDdoc()) return false;
- var views = this.get('views');
- tempView = views[view] || {};
-
- if (reduce) {
- tempView.reduce=reduce;
- } else {
- delete tempView.reduce;
- }
- tempView.map= map;
-
- views[view] = tempView;
- this.set({views: views});
-
- return true;
- },
-
- removeDdocView: function (viewName) {
- if (!this.isDdoc()) return false;
- var views = this.get('views');
-
- delete views[viewName];
- this.set({views: views});
- },
-
- dDocModel: function () {
- if (!this.isDdoc()) return false;
- var doc = this.get('doc');
-
- if (doc) {
- return new Documents.Doc(doc, {database: this.database});
- }
-
- return this;
- },
-
- viewHasReduce: function(viewName) {
- var view = this.getDdocView(viewName);
-
- return view && view.reduce;
- },
-
- // Need this to work around backbone router thinking _design/foo
- // is a separate route. Alternatively, maybe these should be
- // treated separately. For instance, we could default into the
- // json editor for docs, or into a ddoc specific page.
- safeID: function() {
- if (this.isDdoc()){
- var ddoc = this.id.replace(/^_design\//,"");
- return "_design/"+app.mixins.safeURLName(ddoc);
- }else{
- return app.mixins.safeURLName(this.id);
- }
- },
-
- destroy: function() {
- var url = this.url() + "?rev=" + this.get('_rev');
- return $.ajax({
- url: url,
- dataType: 'json',
- type: 'DELETE'
- });
- },
-
- parse: function(resp) {
- if (resp.rev) {
- resp._rev = resp.rev;
- delete resp.rev;
- }
- if (resp.id) {
- if (typeof(this.id) === "undefined") {
- resp._id = resp.id;
- }
- delete resp.id;
- }
- if (resp.ok) {
- delete resp.ok;
- }
- return resp;
- },
-
- prettyJSON: function() {
- var data = this.get("doc") ? this.get("doc") : this;
-
- return JSON.stringify(data, null, " ");
- },
-
- copy: function (copyId) {
- return $.ajax({
- type: 'COPY',
- url: '/' + this.database.safeID() + '/' + this.safeID(),
- headers: {Destination: copyId}
- });
- },
-
- isNewDoc: function () {
- return this.get('_rev') ? false : true;
- }
- });
-
- Documents.DdocInfo = Backbone.Model.extend({
- idAttribute: "_id",
- documentation: function(){
- return "docs";
- },
- initialize: function (_attrs, options) {
- this.database = options.database;
- },
-
- url: function(context) {
- if (context === "app") {
- return this.database.url("app") + "/" + this.safeID() + '/_info';
- } else if (context === "apiurl"){
- return window.location.origin + "/" + this.database.safeID() + "/" + this.safeID() + '/_info';
- } else {
- return app.host + "/" + this.database.safeID() + "/" + this.safeID() + '/_info';
- }
- },
-
- // Need this to work around backbone router thinking _design/foo
- // is a separate route. Alternatively, maybe these should be
- // treated separately. For instance, we could default into the
- // json editor for docs, or into a ddoc specific page.
- safeID: function() {
- var ddoc = this.id.replace(/^_design\//,"");
- return "_design/"+app.mixins.safeURLName(ddoc);
- }
-
- });
-
- Documents.ViewRow = Backbone.Model.extend({
- // this is a hack so that backbone.collections doesn't group
- // these by id and reduce the number of items returned.
- idAttribute: "_id",
-
- docType: function() {
- if (!this.id) return "reduction";
-
- return this.id.match(/^_design/) ? "design doc" : "doc";
- },
- documentation: function(){
- return "docs";
- },
- url: function(context) {
- if (!this.isEditable()) return false;
-
- return this.collection.database.url(context) + "/" + this.safeID();
- },
-
- isEditable: function() {
- return this.docType() != "reduction";
- },
- safeID: function() {
- return app.mixins.safeURLName(this.id);
- },
-
- prettyJSON: function() {
- //var data = this.get("doc") ? this.get("doc") : this;
- return JSON.stringify(this, null, " ");
- }
- });
-
- Documents.NewDoc = Documents.Doc.extend({
- fetch: function() {
- var uuid = new FauxtonAPI.UUID();
- var deferred = this.deferred = $.Deferred();
- var that = this;
-
- uuid.fetch().done(function() {
- that.set("_id", uuid.next());
- deferred.resolve();
- });
-
- return deferred.promise();
- }
-
- });
-
- Documents.AllDocs = Backbone.Collection.extend({
- model: Documents.Doc,
- documentation: function(){
- return "docs";
- },
- initialize: function(_models, options) {
- this.database = options.database;
- this.params = options.params;
- this.skipFirstItem = false;
-
- this.on("remove",this.decrementTotalRows , this);
- },
-
- url: function(context) {
- var query = "";
- if (this.params) {
- query = "?" + $.param(this.params);
- }
-
- if (context === 'app') {
- return 'database/' + this.database.safeID() + "/_all_docs" + query;
- } else if (context === "apiurl"){
- return window.location.origin + "/" + this.database.safeID() + "/_all_docs" + query;
- } else {
- return app.host + "/" + this.database.safeID() + "/_all_docs" + query;
- }
- },
-
- simple: function () {
- var docs = this.map(function (item) {
- return {
- _id: item.id,
- _rev: item.get('_rev'),
- };
- });
-
- return new Documents.AllDocs(docs, {
- database: this.database,
- params: this.params
- });
- },
-
- urlNextPage: function (num, lastId) {
- if (!lastId) {
- var doc = this.last();
-
- if (doc) {
- lastId = doc.id;
- } else {
- lastId = '';
- }
- }
-
- this.params.startkey_docid = '"' + lastId + '"';
- this.params.startkey = '"' + lastId + '"';
- // when paginating forward, fetch 21 and don't show
- // the first item as it was the last item in the previous list
- this.params.limit = num + 1;
- return this.url('app');
- },
-
- urlPreviousPage: function (num, params) {
- if (params) {
- this.params = params;
- } else {
- this.params = {reduce: false};
- }
-
- this.params.limit = num;
- return this.url('app');
- },
-
- totalRows: function() {
- return this.viewMeta.total_rows || "unknown";
- },
-
- decrementTotalRows: function () {
- if (this.viewMeta.total_rows) {
- this.viewMeta.total_rows = this.viewMeta.total_rows -1;
- this.trigger('totalRows:decrement');
- }
- },
-
- updateSeq: function() {
- return this.viewMeta.update_seq || false;
- },
-
- recordStart: function () {
- if (this.viewMeta.offset === 0) {
- return 1;
- }
-
- if (this.skipFirstItem) {
- return this.viewMeta.offset + 2;
- }
-
- return this.viewMeta.offset + 1;
- },
-
- parse: function(resp) {
- var rows = resp.rows;
-
- this.viewMeta = {
- total_rows: resp.total_rows,
- offset: resp.offset,
- update_seq: resp.update_seq
- };
-
- //Paginating, don't show first item as it was the last
- //item in the previous page
- if (this.skipFirstItem) {
- rows = rows.splice(1);
- }
- return _.map(rows, function(row) {
- return {
- _id: row.id,
- _rev: row.value.rev,
- value: row.value,
- key: row.key,
- doc: row.doc || undefined
- };
- });
- }
- });
-
- Documents.IndexCollection = Backbone.Collection.extend({
- model: Documents.ViewRow,
- documentation: function(){
- return "docs";
- },
- initialize: function(_models, options) {
- this.database = options.database;
- this.params = _.extend({limit: 20, reduce: false}, options.params);
- this.idxType = "_view";
- this.view = options.view;
- this.design = options.design.replace('_design/','');
- this.skipFirstItem = false;
- },
-
- url: function(context) {
- var query = "";
- if (this.params) {
- query = "?" + $.param(this.params);
- }
-
- var startOfUrl = app.host;
- if (context === 'app') {
- startOfUrl = 'database';
- } else if (context === "apiurl"){
- startOfUrl = window.location.origin;
- }
- var design = app.mixins.safeURLName(this.design),
- view = app.mixins.safeURLName(this.view);
-
- var url = [startOfUrl, this.database.safeID(), "_design", design, this.idxType, view];
- return url.join("/") + query;
- },
-
- urlNextPage: function (num, lastId) {
- if (!lastId) {
- lastDoc = this.last();
- }
-
- var id = lastDoc.get("id");
- if (id) {
- this.params.startkey_docid = id;
- }
-
- this.params.startkey = JSON.stringify(lastDoc.get('key'));
- this.params.limit = num + 1;
- return this.url('app');
- },
-
- urlPreviousPage: function (num, params) {
- if (params) {
- this.params = params;
- } else {
- this.params = {reduce: false};
- }
-
- this.params.limit = num;
- return this.url('app');
- },
-
- recordStart: function () {
- if (this.viewMeta.offset === 0) {
- return 1;
- }
-
- if (this.skipFirstItem) {
- return this.viewMeta.offset + 2;
- }
-
- return this.viewMeta.offset + 1;
- },
-
- totalRows: function() {
- if (this.params.reduce) { return "unknown_reduce";}
-
- return this.viewMeta.total_rows || "unknown";
- },
-
- updateSeq: function() {
- return this.viewMeta.update_seq || false;
- },
-
- simple: function () {
- var docs = this.map(function (item) {
- return {
- _id: item.id,
- key: item.get('key'),
- value: item.get('value')
- };
- });
-
- return new Documents.IndexCollection(docs, {
- database: this.database,
- params: this.params,
- view: this.view,
- design: this.design
- });
- },
-
- parse: function(resp) {
- var rows = resp.rows;
- this.endTime = new Date().getTime();
- this.requestDuration = (this.endTime - this.startTime);
-
- if (this.skipFirstItem) {
- rows = rows.splice(1);
- }
-
- this.viewMeta = {
- total_rows: resp.total_rows,
- offset: resp.offset,
- update_seq: resp.update_seq
- };
- return _.map(rows, function(row) {
- return {
- value: row.value,
- key: row.key,
- doc: row.doc,
- id: row.id
- };
- });
- },
-
- buildAllDocs: function(){
- this.fetch();
- },
-
- // We implement our own fetch to store the starttime so we that
- // we can get the request duration
- fetch: function () {
- this.startTime = new Date().getTime();
- return Backbone.Collection.prototype.fetch.call(this);
- },
-
- allDocs: function(){
- return this.models;
- },
-
- // This is taken from futon.browse.js $.timeString
- requestDurationInString: function () {
- var ms, sec, min, h, timeString, milliseconds = this.requestDuration;
-
- sec = Math.floor(milliseconds / 1000.0);
- min = Math.floor(sec / 60.0);
- sec = (sec % 60.0).toString();
- if (sec.length < 2) {
- sec = "0" + sec;
- }
-
- h = (Math.floor(min / 60.0)).toString();
- if (h.length < 2) {
- h = "0" + h;
- }
-
- min = (min % 60.0).toString();
- if (min.length < 2) {
- min = "0" + min;
- }
-
- timeString = h + ":" + min + ":" + sec;
-
- ms = (milliseconds % 1000.0).toString();
- while (ms.length < 3) {
- ms = "0" + ms;
- }
- timeString += "." + ms;
-
- return timeString;
- }
- });
-
-
- Documents.PouchIndexCollection = Backbone.Collection.extend({
- model: Documents.ViewRow,
- documentation: function(){
- return "docs";
- },
- initialize: function(_models, options) {
- this.database = options.database;
- this.rows = options.rows;
- this.view = options.view;
- this.design = options.design.replace('_design/','');
- this.params = _.extend({limit: 20, reduce: false}, options.params);
- this.idxType = "_view";
- },
-
- url: function () {
- return '';
- },
-
- simple: function () {
- var docs = this.map(function (item) {
- return {
- _id: item.id,
- key: item.get('key'),
- value: item.get('value')
- };
- });
-
- return new Documents.PouchIndexCollection(docs, {
- database: this.database,
- params: this.params,
- view: this.view,
- design: this.design,
- rows: this.rows
- });
-
- },
-
- fetch: function() {
- var deferred = FauxtonAPI.Deferred();
- this.reset(this.rows, {silent: true});
-
- this.viewMeta = {
- total_rows: this.rows.length,
- offset: 0,
- update_seq: false
- };
-
- deferred.resolve();
- return deferred;
- },
-
- recordStart: function () {
- return 1;
- },
-
- totalRows: function() {
- return this.viewMeta.total_rows || "unknown";
- },
-
- updateSeq: function() {
- return this.viewMeta.update_seq || false;
- },
-
- buildAllDocs: function(){
- this.fetch();
- },
-
- allDocs: function(){
- return this.models;
- }
- });
-
-
-
- return Documents;
-});
[23/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Keep errors from fading on Doc Editor
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6530f95c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6530f95c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6530f95c
Branch: refs/heads/api-options
Commit: 6530f95c0d33b1657336c51b363c6135b5aa7be6
Parents: 2e4d72b
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 12:37:11 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 12:37:11 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6530f95c/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 2502b58..80c8251 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -890,6 +890,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
notification = FauxtonAPI.addNotification({
msg: "Save failed: " + responseText,
type: "error",
+ fade: false,
clear: true,
selector: "#doc .errors-container"
});
[27/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
kill off app/templates for docs & dbs
They live under app/addons/databases &
app/addons/documents now (as with the
other addons).
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ae03a97b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ae03a97b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ae03a97b
Branch: refs/heads/api-options
Commit: ae03a97b3bc001be9c3c031b20f7272adc532501
Parents: 134dd40
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Jan 13 13:53:57 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:09:15 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/databases/views.js | 8 +-
src/fauxton/app/addons/documents/views.js | 40 ++++----
src/fauxton/app/templates/databases/item.html | 24 -----
src/fauxton/app/templates/databases/list.html | 35 -------
.../app/templates/databases/newdatabase.html | 17 ----
.../templates/documents/advanced_options.html | 98 --------------------
.../app/templates/documents/all_docs_item.html | 26 ------
.../templates/documents/all_docs_layout.html | 20 ----
.../app/templates/documents/all_docs_list.html | 43 ---------
.../templates/documents/all_docs_number.html | 23 -----
.../app/templates/documents/changes.html | 38 --------
.../app/templates/documents/ddoc_info.html | 28 ------
.../documents/design_doc_selector.html | 35 -------
src/fauxton/app/templates/documents/doc.html | 55 -----------
.../templates/documents/doc_field_editor.html | 74 ---------------
.../documents/doc_field_editor_tabs.html | 19 ----
.../documents/duplicate_doc_modal.html | 36 -------
.../app/templates/documents/edit_tools.html | 44 ---------
.../templates/documents/index_menu_item.html | 17 ----
.../templates/documents/index_row_docular.html | 27 ------
.../templates/documents/index_row_tabular.html | 25 -----
.../app/templates/documents/jumpdoc.html | 19 ----
src/fauxton/app/templates/documents/search.html | 15 ---
.../app/templates/documents/sidebar.html | 67 -------------
src/fauxton/app/templates/documents/tabs.html | 18 ----
.../app/templates/documents/upload_modal.html | 42 ---------
.../app/templates/documents/view_editor.html | 87 -----------------
27 files changed, 24 insertions(+), 956 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/addons/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js
index 0068305..df663eb 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -22,7 +22,7 @@ function(app, Components, FauxtonAPI, Databases) {
var Views = {};
Views.Item = FauxtonAPI.View.extend({
- template: "templates/databases/item",
+ template: "addons/databases/templates/item",
tagName: "tr",
establish: function(){
return [this.model.fetch()];
@@ -39,7 +39,7 @@ function(app, Components, FauxtonAPI, Databases) {
Views.List = FauxtonAPI.View.extend({
dbLimit: 20,
perPage: 20,
- template: "templates/databases/list",
+ template: "addons/databases/templates/list",
events: {
"click button.all": "selectAll",
"submit form#jump-to-db": "switchDatabase"
@@ -143,7 +143,7 @@ function(app, Components, FauxtonAPI, Databases) {
Views.NewDatabaseButton = FauxtonAPI.View.extend({
- template: "templates/databases/newdatabase",
+ template: "addons/databases/templates/newdatabase",
events: {
"click a#new": "newDatabase"
},
@@ -189,7 +189,7 @@ function(app, Components, FauxtonAPI, Databases) {
});
Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/databases/sidebar",
+ template: "addons/databases/templates/sidebar",
events: {
"click a#new": "newDatabase",
"click a#owned": "showMine",
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 80c8251..0139eca 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -31,7 +31,7 @@ define([
function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns) {
var Views = {};
Views.Tabs = FauxtonAPI.View.extend({
- template: "templates/documents/tabs",
+ template: "addons/documents/templates/tabs",
initialize: function(options){
this.collection = options.collection;
this.database = options.database;
@@ -81,7 +81,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.SearchBox = FauxtonAPI.View.extend({
- template: "templates/documents/search",
+ template: "addons/documents/templates/search",
tagName: "form",
initialize: function(options){
this.collection = options.collection;
@@ -131,7 +131,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.UploadModal = FauxtonAPI.View.extend({
- template: "templates/documents/upload_modal",
+ template: "addons/documents/templates/upload_modal",
disableLoader: true,
@@ -227,7 +227,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DuplicateDocModal = FauxtonAPI.View.extend({
- template: "templates/documents/duplicate_doc_modal",
+ template: "addons/documents/templates/duplicate_doc_modal",
initialize: function () {
_.bindAll(this);
@@ -299,7 +299,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.FieldEditorTabs = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor_tabs",
+ template: "addons/documents/templates/doc_field_editor_tabs",
disableLoader: true,
initialize: function(options) {
this.selected = options.selected;
@@ -330,7 +330,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Document = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_item",
+ template: "addons/documents/templates/all_docs_item",
tagName: "tr",
className: "all-docs-item",
@@ -390,7 +390,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Row = FauxtonAPI.View.extend({
- template: "templates/documents/index_row_docular",
+ template: "addons/documents/templates/index_row_docular",
tagName: "tr",
events: {
@@ -411,7 +411,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.IndexItem = FauxtonAPI.View.extend({
- template: "templates/documents/index_menu_item",
+ template: "addons/documents/templates/index_menu_item",
tagName: "li",
initialize: function(options){
@@ -444,7 +444,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.AllDocsNumber = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_number",
+ template: "addons/documents/templates/all_docs_number",
initialize: function (options) {
this.newView = options.newView || false;
@@ -487,7 +487,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.AllDocsLayout = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_layout",
+ template: "addons/documents/templates/all_docs_layout",
className: "row",
initialize: function (options) {
@@ -565,7 +565,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
// TODO: Rename to reflect that this is a list of rows or documents
Views.AllDocsList = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_list",
+ template: "addons/documents/templates/all_docs_list",
events: {
"click button.all": "selectAll",
"click button.bulk-delete": "bulkDelete",
@@ -759,7 +759,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Doc = FauxtonAPI.View.extend({
- template: "templates/documents/doc",
+ template: "addons/documents/templates/doc",
events: {
"click button.save-doc": "saveDoc",
"click button.delete": "destroy",
@@ -977,7 +977,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DocFieldEditor = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor",
+ template: "addons/documents/templates/doc_field_editor",
disableLoader: true,
events: {
"click button.save": "saveDoc"
@@ -1024,7 +1024,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.AdvancedOptions = FauxtonAPI.View.extend({
- template: "templates/documents/advanced_options",
+ template: "addons/documents/templates/advanced_options",
className: "advanced-options well",
initialize: function (options) {
@@ -1176,7 +1176,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DesignDocSelector = FauxtonAPI.View.extend({
- template: "templates/documents/design_doc_selector",
+ template: "addons/documents/templates/design_doc_selector",
events: {
"change select#ddoc": "updateDesignDoc"
@@ -1237,7 +1237,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.ViewEditor = FauxtonAPI.View.extend({
- template: "templates/documents/view_editor",
+ template: "addons/documents/templates/view_editor",
builtinReduces: ['_sum', '_count', '_stats'],
events: {
@@ -1668,7 +1668,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.JumpToDoc = FauxtonAPI.View.extend({
- template: "templates/documents/jumpdoc",
+ template: "addons/documents/templates/jumpdoc",
initialize: function (options) {
this.database = options.database;
@@ -1691,7 +1691,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/documents/sidebar",
+ template: "addons/documents/templates/sidebar",
events: {
"click button#delete-database": "deleteDatabase"
},
@@ -1800,7 +1800,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
Views.Indexed = FauxtonAPI.View.extend({});
Views.Changes = FauxtonAPI.View.extend({
- template: "templates/documents/changes",
+ template: "addons/documents/templates/changes",
establish: function() {
return [ this.model.changes.fetch()];
@@ -1819,7 +1819,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DdocInfo = FauxtonAPI.View.extend({
- template: "templates/documents/ddoc_info",
+ template: "addons/documents/templates/ddoc_info",
initialize: function (options) {
this.refreshTime = options.refreshTime || 5000;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/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 e2f8071..0000000
--- a/src/fauxton/app/templates/databases/item.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<td>
- <a href="#/database/<%=encoded%>/_all_docs?limit=<%=docLimit%>"><%= database.get("name") %></a>
-</td>
-<td><%= database.status.humanSize() %></td>
-<td><%= database.status.numDocs() %></td>
-<td><%= database.status.updateSeq() %></td>
-<td>
- <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a>
- <a class="db-actions btn icon-lock set-permissions" title="Set permissions for <%= database.get("name") %>" href="#/database/<%=encoded%>/permissions"></a>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/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 31c0977..0000000
--- a/src/fauxton/app/templates/databases/list.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="result-tools" style="">
- <div id="newButton" class="pull-left"></div>
- <form id="jump-to-db" class="navbar-form pull-right input-append database-search">
- <input type="text" class="search-autocomplete" name="search-query" placeholder="Database name"></input>
- <button class="fonticon-search btn button red " type="submit"></button>
- </form>
-
-
-</div>
-<table class="databases table table-striped">
- <thead>
- <th>Name</th>
- <th>Size</th>
- <th># of Docs</th>
- <th>Update Seq</th>
- <th>Actions</th>
- </thead>
- <tbody>
- </tbody>
-</table>
-<div id="database-pagination"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/databases/newdatabase.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/newdatabase.html b/src/fauxton/app/templates/databases/newdatabase.html
deleted file mode 100644
index b357e0b..0000000
--- a/src/fauxton/app/templates/databases/newdatabase.html
+++ /dev/null
@@ -1,17 +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.
--->
-
-<a class="button new" id="new"><i class="icon fonticon-new-database"></i>Add New Database</a>
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/advanced_options.html b/src/fauxton/app/templates/documents/advanced_options.html
deleted file mode 100644
index e256325..0000000
--- a/src/fauxton/app/templates/documents/advanced_options.html
+++ /dev/null
@@ -1,98 +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="errors-container"></div>
-<form class="view-query-update custom-inputs">
- <div class="controls-group">
- <div class="row-fluid">
- <div class="controls controls-row">
- <input name="key" class="span6" type="text" placeholder="Key">
- <input name="keys" class="span6" type="text" placeholder="Keys">
- </div>
- </div>
- <div class="row-fluid">
- <div class="controls controls-row">
- <input name="startkey" class="span6" type="text" placeholder="Start Key">
- <input name="endkey" class="span6" type="text" placeholder="End Key">
- </div>
- </div>
- </div>
- <div class="controls-group">
- <div class="row-fluid">
- <div class="controls controls-row">
- <div class="checkbox inline">
- <input id="check1" type="checkbox" name="include_docs" value="true">
- <label name="include_docs" for="check1">Include Docs</label>
- <% if (hasReduce) { %>
- <input id="check2" name="reduce" type="checkbox" value="true">
- <label for="check2">Reduce</label>
- </div>
- <label id="select1" class="drop-down inline">
- Group Level:
- <select id="select1" disabled name="group_level" class="input-small">
- <option value="0">None</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="999" selected="selected">exact</option>
- </select>
- </label>
- <% } else{ %>
- </div>
- <% } %>
-
- <div class="checkbox inline">
- <input id="check3" name="stale" type="checkbox" value="ok">
- <label for="check3">Stale</label>
- <input id="check4" name="descending" type="checkbox" value="true">
- <label for="check4">Descending</label>
- </div>
- <label class="drop-down inline">
- Limit:
- <select name="limit" class="input-small">
- <option>5</option>
- <option>10</option>
- <option selected="selected">20</option>
- <option>30</option>
- <option>50</option>
- <option>100</option>
- </select>
- </label>
- <div class="checkbox inline">
- <input id="check5" name="inclusive_end" type="checkbox" value="false">
- <label for="check5">Disable Inclusive End</label>
- <input id="check6" name="update_seq" type="checkbox" value="true">
- <label for="check6">Update Sequence</label>
- </div>
- </div>
- </div>
- </div>
- <div class="controls-group">
- <div class="row-fluid">
- <div id="button-options" class="controls controls-row">
- <button type="submit" class="button green">Query</button>
- <% if (showPreview) { %>
- <button class="button btn-info preview">Browser Preview</button>
- <% } %>
- </div>
- </div>
- </div>
-</form>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/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 bfedaaa..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('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>
- <% } %>
- </div>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/all_docs_layout.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_layout.html b/src/fauxton/app/templates/documents/all_docs_layout.html
deleted file mode 100644
index 6b4a31b..0000000
--- a/src/fauxton/app/templates/documents/all_docs_layout.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.
--->
-<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav">
- <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-bypass="true" data-toggle="tab">Query Options</a></li>
-</ul>
-<div class="tab-content">
- <div class="tab-pane" id="query">
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/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 335b040..0000000
--- a/src/fauxton/app/templates/documents/all_docs_list.html
+++ /dev/null
@@ -1,43 +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>
- <% if (expandDocs) { %>
- <button id="collapse" class="btn"><i class="icon-minus"></i> Collapse</button>
- <% } else { %>
- <button id="collapse" class="btn"><i class="icon-plus"></i> Expand</button>
- <% } %>
- </div>
- </div>
- <% } %>
- <p>
-
- <div id="item-numbers"> </div>
-
- <% 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 id="documents-pagination"></div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/all_docs_number.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_number.html b/src/fauxton/app/templates/documents/all_docs_number.html
deleted file mode 100644
index df8fe07..0000000
--- a/src/fauxton/app/templates/documents/all_docs_number.html
+++ /dev/null
@@ -1,23 +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.
--->
-<% if (totalRows === "unknown"){ %>
- Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
-<% } else if (showNumbers) { %>
- Showing <%=offset%> - <%= numModels %> of <%= totalRows %> rows
-<% } else { %>
- Showing <%=pageStart%> - <%= pageEnd %>
-<%}%>
-<% if (updateSeq) { %>
- -- Update Sequence: <%= updateSeq %>
-<% } %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/changes.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/changes.html b/src/fauxton/app/templates/documents/changes.html
deleted file mode 100644
index 9408979..0000000
--- a/src/fauxton/app/templates/documents/changes.html
+++ /dev/null
@@ -1,38 +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.
--->
-
-<table id="changes-table" class="table">
- <thead>
- <th id="seq"> seq </th>
- <th> id </th>
- <th id="changes"> changes </th>
- <th id="deleted"> deleted? </th>
- </thead>
- <tbody>
- <% _.each(changes, function (change) { %>
- <tr>
- <td> <%= change.seq %> </td>
- <% if (change.deleted) { %>
- <td> <%= change.id %> </td>
- <% } else { %>
- <td> <a href="#<%= database.url('app') %>/<%= change.id %>"><%= change.id %></a> </td>
- <% } %>
- <td>
- <pre class="prettyprint"> <%- JSON.stringify({changes: change.changes, doc: change.doc}, null, " ") %> </pre>
- </td>
- <td><%= change.deleted ? "true" : "false" %></td>
- </tr>
- <% }); %>
- </tbody>
-</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/ddoc_info.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/ddoc_info.html b/src/fauxton/app/templates/documents/ddoc_info.html
deleted file mode 100644
index ed0aed6..0000000
--- a/src/fauxton/app/templates/documents/ddoc_info.html
+++ /dev/null
@@ -1,28 +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>
- <h2> Design Doc MetaData </h2>
- <div class="row-fluid">
- <% i=0; _.map(view_index, function (val, key) { %>
- <% if(i%2==0){%>
- <div class="row-fluid">
- <% }; %>
- <div class="span6 well-item"><strong> <%= key %></strong> : <%= val %> </div>
- <% if(i%2==1){%>
- </div>
- <% }; %>
- <% ++i;
- }); %>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/design_doc_selector.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/design_doc_selector.html b/src/fauxton/app/templates/documents/design_doc_selector.html
deleted file mode 100644
index 7bbe310..0000000
--- a/src/fauxton/app/templates/documents/design_doc_selector.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-<div class="span3">
- <label for="ddoc">Save to Design Document <a href="<%=getDocUrl('design_doc')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
- <select id="ddoc">
- <optgroup label="Select a document">
- <option value="new-doc">New document</option>
- <% ddocs.each(function(ddoc) { %>
- <% if (ddoc.id === ddocName) { %>
- <option selected="selected" value="<%= ddoc.id %>"><%= ddoc.id %></option>
- <% } else { %>
- <option value="<%= ddoc.id %>"><%= ddoc.id %></option>
- <% } %>
- <% }); %>
- </optgroup>
- </select>
-</div>
-
-<div id="new-ddoc-section" class="span5" style="display:none">
- <label class="control-label" for="new-ddoc"> _design/ </label>
- <div class="controls">
- <input type="text" id="new-ddoc" placeholder="newDesignDoc">
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/doc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc.html b/src/fauxton/app/templates/documents/doc.html
deleted file mode 100644
index 10bbf8b..0000000
--- a/src/fauxton/app/templates/documents/doc.html
+++ /dev/null
@@ -1,55 +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 id="doc">
- <div class="errors-container"></div>
-
-<div class="row doc-editor-buttons">
- <div class="span3">
- <button class="save-doc button green btn-medium save fonticon-circle-check" type="button">Save</button>
- <button class="button cancel-button gray btn-medium">Back to _all_docs</button>
- </div>
-
- <div class="span7">
- <% if (attachments) { %>
- <div class="btn-group">
- <a class="button gray btn-medium dropdown-toggle btn" data-bypass="true" data-toggle="dropdown" href="#">
- View Attachments
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu">
- <%_.each(attachments, function (att) { %>
- <li>
- <a href="<%= att.url %>" target="_blank"> <strong> <%= att.fileName %> </strong> -
- <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
- </a>
- </li>
- <% }) %>
- </ul>
- </div>
- <% } %>
- <button class="button gray btn-medium upload"><i class="icon-circle-arrow-up"></i> Upload Attachment</button>
- <button class="button gray btn-medium duplicate"><i class="icon-repeat"></i> Duplicate document</button>
- </div>
-
- <button class="button red btn-medium delete"><i class="icon-trash"></i></button>
- </ul>
-
-<div id="upload-modal"> </div>
-<div id="duplicate-modal"> </div>
-</div>
-
- <div id="editor-container" class="doc-code"><%- JSON.stringify(doc.attributes, null, " ") %></div>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/doc_field_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc_field_editor.html b/src/fauxton/app/templates/documents/doc_field_editor.html
deleted file mode 100644
index 77d9278..0000000
--- a/src/fauxton/app/templates/documents/doc_field_editor.html
+++ /dev/null
@@ -1,74 +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 id="doc-field-editor">
- <div class="tools">
-
- <div class="btn-toolbar pull-left">
- <button class="btn btn-small all">✓ All</button>
- <button class="btn btn-small disabled delete"><i class="icon-trash"></i> Delete field</button>
- <button class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</button>
- </div>
- <div class="btn-toolbar pull-right">
- <button class="btn btn-small cancel button cancel-button outlineGray fonticon-circle-x">Cancel</button>
- <button class="btn btn-small save button green fonticon-circle-check">Save</button>
- </div>
- </div>
-
- <div class="clearfix"></div>
- <!-- <hr style="margin-top: 0"/> -->
-
- <table class="table table-striped table-condensed">
- <thead>
- <tr>
- <th class="select">
- </th>
- <th>Key</th>
- <th>Value</th>
- </tr>
- </thead>
- <tbody>
- <tr style="display:none">
- <td class="select"><input type="checkbox" /></td>
- <td class="key"><input type="text" class="input-large" value='' /></td>
- <td class="value"><input type="text" class="input-xxlarge" value='' /></td>
- </tr>
- <% _.each(doc, function(value, key) { %>
- <tr>
- <td class="select"><input type="checkbox" /></td>
- <td class="key">
- <input type="text" class="input-large" name="doc[<%= key %>]" value="<%= key %>" />
- </td>
- <td class="value"><input type="text" class="input-xxlarge" value='<%= JSON.stringify(value) %>' /></td>
- </tr>
- <% }); %>
- <tr>
- <th colspan="3">
- Attachments
- </th>
- </tr>
- <%_.each(attachments, function (att) { %>
- <tr>
- <td class="select"><input type="checkbox" /></td>
- <td colspan="2">
- <a href="<%= att.url %>" target="_blank"> <%= att.fileName %> </a>
- <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
- </td>
- </tr>
- <% }) %>
- </tbody>
- </table>
- <a class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</a>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc_field_editor_tabs.html b/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
deleted file mode 100644
index 766647c..0000000
--- a/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<!--<ul class="nav nav-tabs">
- <li id="field_editor" class="<%= isSelectedClass('field_editor') %>"><a href="#<%= doc.url('app') %>/field_editor">Doc fields</a></li>
- <li id="code_editor" class="<%= isSelectedClass('code_editor') %>"><a href="#<%= doc.url('app') %>/code_editor"><i class="icon-pencil"> </i> Code editor</a>
- </li>
-</ul>-->
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/duplicate_doc_modal.html b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
deleted file mode 100644
index dbb25bc..0000000
--- a/src/fauxton/app/templates/documents/duplicate_doc_modal.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Duplicate Document</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form id="doc-duplicate" class="form" method="post">
- <p class="help-block">
- Set new documents ID:
- </p>
- <input id="dup-id" type="text" class="input-xlarge">
- </form>
-
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn button cancel-button outlineGray fonticon-circle-x">Cancel</a>
- <a href="#" id="duplicate-btn" class="btn btn-primary button green save fonticon-circle-check">Duplicate</a>
- </div>
-</div>
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/edit_tools.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/edit_tools.html b/src/fauxton/app/templates/documents/edit_tools.html
deleted file mode 100644
index 40c884d..0000000
--- a/src/fauxton/app/templates/documents/edit_tools.html
+++ /dev/null
@@ -1,44 +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">
- <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="#">«</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="#">»</a></li>
- </ul>
- </div>
- -->
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/index_menu_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_menu_item.html b/src/fauxton/app/templates/documents/index_menu_item.html
deleted file mode 100644
index 7ca9012..0000000
--- a/src/fauxton/app/templates/documents/index_menu_item.html
+++ /dev/null
@@ -1,17 +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.
--->
-
-<a id="<%= ddoc_clean %>_<%= index_clean %>" href="#database/<%= database_encoded %>/_design/<%= ddoc_encoded %>/_view/<%= index_encoded %>" class="toggle-view">
- <%= ddoc %><span class="divider">/</span><%= index %>
-</a>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_row_docular.html b/src/fauxton/app/templates/documents/index_row_docular.html
deleted file mode 100644
index f1b2217..0000000
--- a/src/fauxton/app/templates/documents/index_row_docular.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-<% if (doc.isEditable()) { %>
- <td class="select"><input type="checkbox"></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/ae03a97b/src/fauxton/app/templates/documents/index_row_tabular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_row_tabular.html b/src/fauxton/app/templates/documents/index_row_tabular.html
deleted file mode 100644
index f5f68fa..0000000
--- a/src/fauxton/app/templates/documents/index_row_tabular.html
+++ /dev/null
@@ -1,25 +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"></td>
-<td>
- <div>
- <pre class="prettyprint"><%- JSON.stringify(doc.get("key")) %></pre>
- </div>
-</td>
-<td>
- <div>
- <pre class="prettyprint"><%- JSON.stringify(doc.get("value")) %></pre>
- </div>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/jumpdoc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/jumpdoc.html b/src/fauxton/app/templates/documents/jumpdoc.html
deleted file mode 100644
index 43fdb9c..0000000
--- a/src/fauxton/app/templates/documents/jumpdoc.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<form id="jump-to-doc" class="form-inline input-append" >
- <input type="text" id="jump-to-doc-id" class="input-large" placeholder="Document ID"></input>
-
- <button class="fonticon-search btn button red " type="submit"></button>
-</form>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/search.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/search.html b/src/fauxton/app/templates/documents/search.html
deleted file mode 100644
index bb84891..0000000
--- a/src/fauxton/app/templates/documents/search.html
+++ /dev/null
@@ -1,15 +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.
--->
-
-<input id="searchbox" type="text" class="span12" placeholder="Search by doc id, view key or search index">
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/sidebar.html b/src/fauxton/app/templates/documents/sidebar.html
deleted file mode 100644
index 8a73ae9..0000000
--- a/src/fauxton/app/templates/documents/sidebar.html
+++ /dev/null
@@ -1,67 +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 id="sidenav">
- <header class="row-fluid">
- <div class="span12">
- <div class="btn-group">
- <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown">
- Docs
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <!-- dropdown menu links -->
- <li><a class="icon-file" href="<%= db_url %>">Docs</a></li>
- <li><a class="icon-lock" href="<%= permissions_url %>">Permissions</a></li>
- <li><a class="icon-forward" href="<%= changes_url %>">Changes</a></li>
- <% _.each(docLinks, function (link) { %>
- <li><a class="<%= link.icon %>" href="<%= database_url + '/' + link.url %>"><%= link.title %></a></li>
- <% }); %>
- </ul>
- </div>
-
- <div class="btn-group">
- <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown">
- New
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <!-- dropdown menu links -->
- <li>
- <a id="doc" href="#<%= database.url('app') %>/new">Document</a>
- </li>
- <li>
- <a href="#<%= database.url('app') %>/new_view">Secondary Index</a>
- <% _.each(newLinks, function (item) { %>
- <a href="#<%= database.url('app') %>/<%=item.url%>"> <%= item.name %></a>
- <% }); %>
- </li>
- </ul>
- </div>
- <button id="delete-database" class="btn"><i class="icon-trash"></i> Database</button>
- </div>
- </header>
-
- <nav>
- <ul class="nav nav-list">
- <li class="active"><a id="all-docs" href="#<%= database.url('index') %>?limit=<%= docLimit %>" class="toggle-view"> All documents</a></li>
- <li><a id="design-docs" href='#<%= database.url("index") %>?limit=<%= docLimit %>&startkey="_design"&endkey="_e"' class="toggle-view"> All design docs</a></li>
- </ul>
- <ul class="nav nav-list views">
- <li class="nav-header">Secondary Indexes</li>
- <li><a id="new-view" href="#<%= database.url('app') %>/new_view" class="new"><i class="icon-plus"></i> New</a></li>
- </ul>
- <div id="extension-navs"></div>
- </nav>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/tabs.html b/src/fauxton/app/templates/documents/tabs.html
deleted file mode 100644
index f8b0c4b..0000000
--- a/src/fauxton/app/templates/documents/tabs.html
+++ /dev/null
@@ -1,18 +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.
--->
-
-<ul class="nav nav-tabs">
- <li class="active"><a href="<%= db_url %>">Docs</a></li>
- <li id="changes"><a href="<%= changes_url %>">Changes</a></li>
-</ul>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/upload_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/upload_modal.html b/src/fauxton/app/templates/documents/upload_modal.html
deleted file mode 100644
index 9a5c5cd..0000000
--- a/src/fauxton/app/templates/documents/upload_modal.html
+++ /dev/null
@@ -1,42 +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="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Upload an Attachment</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="alert alert-error hide" style="font-size: 16px;"> </div>
- <form id="file-upload" class="form" method="post">
- <p class="help-block">
- Please select the file you want to upload as an attachment to this document.
- Please note that this will result in the immediate creation of a new revision of the document,
- so it's not necessary to save the document after the upload.
- </p>
- <input id="_attachments" type="file" name="_attachments">
- <input id="_rev" type="hidden" name="_rev" value="" >
- <br/>
- </form>
-
- <div class="progress progress-info">
- <div class="bar" style="width: 0%"></div>
- </div>
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" data-bypass="true" class="btn button cancel-button outlineGray fonticon-circle-x">Cancel</a>
- <a href="#" id="upload-btn" data-bypass="true" class="btn btn-primary button green save fonticon-circle-check">Upload</a>
- </div>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/view_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html
deleted file mode 100644
index ddb5a0c..0000000
--- a/src/fauxton/app/templates/documents/view_editor.html
+++ /dev/null
@@ -1,87 +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">
- <ul class="nav nav-tabs" id="db-views-tabs-nav">
- <li class="active"> <a data-bypass="true" id="index-nav" class="fonticon-wrench fonticon" data-toggle="tab" href="#index"><% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
- <% if (!newView) { %>
- <li><a data-bypass="true" id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
- <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
- <% } %>
- </ul>
- <div class="all-docs-list errors-container"></div>
- <div class="tab-content">
- <div class="tab-pane active" id="index">
- <div id="define-view" class="ddoc-alert well">
- <div class="errors-container"></div>
- <form class="form-horizontal view-query-save">
-
- <div class="control-group design-doc-group">
- </div>
-
- <div class="control-group">
- <label for="index-name">Index name <a href="<%=getDocUrl('view_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
- <input type="text" id="index-name" value="<%= viewName %>" placeholder="Index name" />
- </div>
-
-
- <div class="control-group">
- <label for="map-function">Map function <a href="<%=getDocUrl('map_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
- <% if (newView) { %>
- <div class="js-editor" id="map-function"><%= langTemplates.map %></div>
- <% } else { %>
- <div class="js-editor" id="map-function"><%- ddoc.get('views')[viewName].map %></div>
- <% } %>
- </div>
-
-
- <div class="control-group">
- <label for="reduce-function-selector">Reduce (optional) <a href="<%=getDocUrl('reduce_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
-
- <select id="reduce-function-selector">
- <option value="" <%= !reduceFunStr ? 'selected="selected"' : '' %>>None</option>
- <% _.each(["_sum", "_count", "_stats"], function(reduce) { %>
- <option value="<%= reduce %>" <% if (reduce == reduceFunStr) { %>selected<% } %>><%= reduce %></option>
- <% }) %>
- <option value="CUSTOM" <% if (isCustomReduce) { %>selected<% } %>>Custom Reduce function</option>
- </select>
- </div>
-
- <div class="control-group reduce-function">
- <label for="reduce-function">Custom Reduce function</label>
- <% if (newView) { %>
- <div class="js-editor" id="reduce-function"><%= langTemplates.reduce %></div>
- <% } else { %>
- <div class="js-editor" id="reduce-function"><%- ddoc.get('views')[viewName].reduce %></div>
- <% } %>
- </div>
-
- <div class="control-group">
- <button class="button green save fonticon-circle-check">Save & Build Index</button>
- <button class="button btn-info preview">Preview</button>
- <% if (!newView) { %>
- <button class="button delete outlineGray fonticon-circle-x">Delete</button>
- <% } %>
- </div>
- <div class="clearfix"></div>
- </form>
- </div>
- </div>
- <div class="tab-pane" id="metadata">
- <div id="ddoc-info" class="well"> </div>
- </div>
- <div class="tab-pane" id="query">
- </div>
- </div>
-</div>
-
[17/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: move modules to addons
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/89810cce
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/89810cce
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/89810cce
Branch: refs/heads/api-options
Commit: 89810cce9837d52db4b6beae3206c7b36b6854df
Parents: 62f939c
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Jan 6 12:33:00 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 13 10:51:51 2014 +0200
----------------------------------------------------------------------
.gitignore | 4 +
src/fauxton/app/addons/activetasks/resources.js | 2 +-
src/fauxton/app/addons/compaction/routes.js | 2 +-
src/fauxton/app/addons/databases/base.js | 37 +
src/fauxton/app/addons/databases/resources.js | 193 ++
src/fauxton/app/addons/databases/routes.js | 69 +
.../app/addons/databases/templates/item.html | 24 +
.../app/addons/databases/templates/list.html | 35 +
.../addons/databases/templates/newdatabase.html | 17 +
.../app/addons/databases/templates/sidebar.html | 31 +
src/fauxton/app/addons/databases/views.js | 255 +++
src/fauxton/app/addons/documents/base.js | 24 +
src/fauxton/app/addons/documents/resources.js | 646 ++++++
src/fauxton/app/addons/documents/routes.js | 409 ++++
.../documents/templates/advanced_options.html | 97 +
.../documents/templates/all_docs_item.html | 26 +
.../documents/templates/all_docs_layout.html | 20 +
.../documents/templates/all_docs_list.html | 43 +
.../documents/templates/all_docs_number.html | 21 +
.../app/addons/documents/templates/changes.html | 38 +
.../addons/documents/templates/ddoc_info.html | 28 +
.../templates/design_doc_selector.html | 35 +
.../app/addons/documents/templates/doc.html | 55 +
.../documents/templates/doc_field_editor.html | 74 +
.../templates/doc_field_editor_tabs.html | 19 +
.../templates/duplicate_doc_modal.html | 36 +
.../addons/documents/templates/edit_tools.html | 44 +
.../documents/templates/index_menu_item.html | 17 +
.../documents/templates/index_row_docular.html | 26 +
.../documents/templates/index_row_tabular.html | 25 +
.../app/addons/documents/templates/jumpdoc.html | 19 +
.../app/addons/documents/templates/search.html | 15 +
.../app/addons/documents/templates/sidebar.html | 67 +
.../app/addons/documents/templates/tabs.html | 18 +
.../documents/templates/upload_modal.html | 42 +
.../addons/documents/templates/view_editor.html | 87 +
.../app/addons/documents/tests/resourcesSpec.js | 84 +
src/fauxton/app/addons/documents/views.js | 1855 ++++++++++++++++++
src/fauxton/app/addons/fauxton/base.js | 271 +++
src/fauxton/app/addons/fauxton/components.js | 337 ++++
src/fauxton/app/addons/fauxton/layout.js | 98 +
.../app/addons/fauxton/templates/api_bar.html | 30 +
.../addons/fauxton/templates/breadcrumbs.html | 24 +
.../app/addons/fauxton/templates/footer.html | 15 +
.../fauxton/templates/index_pagination.html | 24 +
.../app/addons/fauxton/templates/nav_bar.html | 75 +
.../addons/fauxton/templates/notification.html | 18 +
.../addons/fauxton/templates/pagination.html | 31 +
src/fauxton/app/addons/permissions/routes.js | 2 +-
src/fauxton/app/addons/pouchdb/base.js | 47 +
src/fauxton/app/addons/pouchdb/pouch.collate.js | 115 ++
.../app/addons/pouchdb/pouchdb.mapreduce.js | 324 +++
src/fauxton/app/addons/replication/views.js | 2 +-
src/fauxton/app/addons/stats/resources.js | 2 +-
.../app/addons/verifyinstall/resources.js | 4 +-
src/fauxton/app/api.js | 2 +-
src/fauxton/app/app.js | 8 +-
src/fauxton/app/modules/databases/base.js | 37 -
src/fauxton/app/modules/databases/resources.js | 193 --
src/fauxton/app/modules/databases/routes.js | 69 -
src/fauxton/app/modules/databases/views.js | 255 ---
src/fauxton/app/modules/documents/base.js | 24 -
src/fauxton/app/modules/documents/resources.js | 646 ------
src/fauxton/app/modules/documents/routes.js | 409 ----
.../modules/documents/tests/resourcesSpec.js | 84 -
src/fauxton/app/modules/documents/views.js | 1855 ------------------
src/fauxton/app/modules/fauxton/base.js | 275 ---
src/fauxton/app/modules/fauxton/components.js | 337 ----
src/fauxton/app/modules/fauxton/layout.js | 98 -
src/fauxton/app/modules/pouchdb/base.js | 47 -
.../app/modules/pouchdb/pouch.collate.js | 115 --
.../app/modules/pouchdb/pouchdb.mapreduce.js | 324 ---
src/fauxton/app/router.js | 39 +-
src/fauxton/settings.json.default | 3 +
74 files changed, 5965 insertions(+), 4813 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 3d6c0f6..784444d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,6 +103,10 @@ src/fauxton/app/addons/*
!src/fauxton/app/addons/permissions
!src/fauxton/app/addons/verifyinstall
!src/fauxton/app/addons/compaction
+!src/fauxton/app/addons/fauxton
+!src/fauxton/app/addons/pouchdb
+!src/fauxton/app/addons/databases
+!src/fauxton/app/addons/documents
src/fauxton/settings.json*
!src/fauxton/settings.json.default
src/ibrowse/ibrowse.app
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/activetasks/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/resources.js b/src/fauxton/app/addons/activetasks/resources.js
index ca732fb..3ac0898 100644
--- a/src/fauxton/app/addons/activetasks/resources.js
+++ b/src/fauxton/app/addons/activetasks/resources.js
@@ -13,7 +13,7 @@
define([
"app",
"backbone",
- "modules/fauxton/base",
+ "addons/fauxton/base",
"d3"
],
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/compaction/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/routes.js b/src/fauxton/app/addons/compaction/routes.js
index 2a33e07..ff15c88 100644
--- a/src/fauxton/app/addons/compaction/routes.js
+++ b/src/fauxton/app/addons/compaction/routes.js
@@ -17,7 +17,7 @@ define([
// Modules
"addons/compaction/views",
- "modules/databases/resources"
+ "addons/databases/resources"
],
function(app, FauxtonAPI, Compaction, Databases) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/base.js b/src/fauxton/app/addons/databases/base.js
new file mode 100644
index 0000000..1a3dc66
--- /dev/null
+++ b/src/fauxton/app/addons/databases/base.js
@@ -0,0 +1,37 @@
+// 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
+ "addons/databases/routes",
+ // Views
+ "addons/databases/views"
+
+],
+
+function(app, FauxtonAPI, Databases, Views) {
+ Databases.Views = Views;
+
+ // Utility functions
+ Databases.databaseUrl = function(database) {
+ var name = _.isObject(database) ? database.id : database,
+ dbname = app.mixins.safeURLName(name);
+
+ return ["/database/", dbname, "/_all_docs?limit=" + Databases.DocLimit].join('');
+ };
+
+ return Databases;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js
new file mode 100644
index 0000000..b6d6536
--- /dev/null
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -0,0 +1,193 @@
+// 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
+ "addons/documents/resources"
+],
+
+function(app, FauxtonAPI, Documents) {
+ var Databases = FauxtonAPI.addon();
+
+ Databases.DocLimit = 20;
+
+ Databases.Model = Backbone.Model.extend({
+ initialize: function(options) {
+ this.status = new Databases.Status({
+ database: this
+ });
+ },
+
+ documentation: function(){
+ return "all_dbs";
+ },
+
+ buildAllDocs: function(params) {
+ this.allDocs = new Documents.AllDocs(null, {
+ database: this,
+ params: params
+ });
+
+ return this.allDocs;
+ },
+
+ isNew: function(){
+ // Databases are never new, to make Backbone do a PUT
+ return false;
+ },
+
+ url: function(context) {
+ if (context === "index") {
+ return "/database/" + this.safeID() + "/_all_docs";
+ } else if (context === "web-index") {
+ return "#/database/"+ this.safeID() + "/_all_docs?limit=" + Databases.DocLimit;
+ } else if (context === "apiurl") {
+ return window.location.origin + "/database/" + this.safeID() + "/_all_docs";
+ } else if (context === "changes") {
+ return "/database/" + this.safeID() + "/_changes?descending=true&limit=100&include_docs=true";
+ } else if (context === "changes-apiurl") {
+ return window.location.origin + "/database/" + this.safeID() + "/_changes?descending=true&limit=100&include_docs=true";
+ } else if (context === "app") {
+ return "/database/" + this.safeID();
+ } else {
+ return app.host + "/" + this.safeID();
+ }
+ },
+ safeName: function(){
+ return app.mixins.safeURLName(this.get("name"));
+ },
+ safeID: function() {
+ return app.mixins.safeURLName(this.id);
+ },
+ buildChanges: function (params) {
+ this.changes = new Databases.Changes({
+ database: this,
+ params: params
+ });
+
+ return this.changes;
+ }
+ });
+
+ Databases.Changes = Backbone.Collection.extend({
+
+ initialize: function(options) {
+ this.database = options.database;
+ this.params = options.params;
+ },
+ documentation: function(){
+ return "changes";
+ },
+ url: function (context) {
+ var query = "";
+ if (this.params) {
+ query = "?" + $.param(this.params);
+ }
+ if (context === "apiurl") {
+ return window.location.origin + '/' + this.database.safeID() + '/_changes' + query;
+ } else {
+
+ return app.host + '/' + this.database.safeID() + '/_changes' + query;
+ }
+ },
+
+ parse: function (resp) {
+ this.last_seq = resp.last_seq;
+ return resp.results;
+ }
+ });
+
+ Databases.Status = Backbone.Model.extend({
+ url: function() {
+ return app.host + "/" + this.database.safeID();
+ },
+
+ initialize: function(options) {
+ this.database = options.database;
+ },
+
+ numDocs: function() {
+ return this.get("doc_count");
+ },
+
+ updateSeq: function(full) {
+ var updateSeq = this.get("update_seq");
+ if (full || (typeof(updateSeq) === 'number')) {
+ return updateSeq;
+ } else if (updateSeq) {
+ return updateSeq.split('-')[0];
+ } else {
+ return 0;
+ }
+ },
+
+ humanSize: function() {
+ // cribbed from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable
+ var i = -1;
+ var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
+ var fileSizeInBytes = this.dataSize();
+
+ if (!fileSizeInBytes) {
+ return 0;
+ }
+
+ do {
+ fileSizeInBytes = fileSizeInBytes / 1024;
+ i++;
+ } while (fileSizeInBytes > 1024);
+
+ return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
+ },
+ diskSize: function () {
+ return this.get("disk_size");
+ },
+
+ dataSize: function () {
+ if (this.get("other")){
+ return this.get("other").data_size;
+ }else{
+ return 0;
+ }
+ }
+ });
+
+ // TODO: shared databases - read from the user doc
+ Databases.List = Backbone.Collection.extend({
+ model: Databases.Model,
+ documentation: function(){
+ return "all_dbs";
+ },
+ url: function(context) {
+ if (context === "apiurl") {
+ return window.location.origin + "/_all_dbs";
+ } else {
+ return app.host + "/_all_dbs";
+ }
+ },
+
+ parse: function(resp) {
+ // TODO: pagination!
+ return _.map(resp, function(database) {
+ return {
+ id: app.mixins.safeURLName(database),
+ name: database
+ };
+ });
+ }
+ });
+
+ return Databases;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/routes.js b/src/fauxton/app/addons/databases/routes.js
new file mode 100644
index 0000000..c413018
--- /dev/null
+++ b/src/fauxton/app/addons/databases/routes.js
@@ -0,0 +1,69 @@
+// 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
+ "addons/databases/resources",
+ // TODO:: fix the include flow modules so we don't have to require views here
+ "addons/databases/views"
+],
+
+function(app, FauxtonAPI, Databases, Views) {
+
+ var AllDbsRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "one_pane",
+
+ crumbs: [
+ {"name": "Databases", "link": "/_all_dbs"}
+ ],
+
+ routes: {
+ "": "allDatabases",
+ "index.html": "allDatabases",
+ "_all_dbs(:params)": "allDatabases"
+ },
+
+ apiUrl: function() {
+ return [this.databases.url("apiurl"), this.databases.documentation()];
+ },
+
+ selectedHeader: "Databases",
+
+ initialize: function() {
+ this.databases = new Databases.List();
+ this.deferred = FauxtonAPI.Deferred();
+ },
+
+ allDatabases: function() {
+ var params = app.getParams(),
+ dbPage = params.page;
+
+ this.databasesView = this.setView("#dashboard-content", new Views.List({
+ collection: this.databases
+ }));
+
+ this.databasesView.setPage(dbPage);
+ },
+
+ establish: function() {
+ return [this.databases.fetch()];
+ }
+ });
+
+ Databases.RouteObjects = [AllDbsRouteObject];
+
+ return Databases;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/templates/item.html b/src/fauxton/app/addons/databases/templates/item.html
new file mode 100644
index 0000000..e2f8071
--- /dev/null
+++ b/src/fauxton/app/addons/databases/templates/item.html
@@ -0,0 +1,24 @@
+<!--
+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/<%=encoded%>/_all_docs?limit=<%=docLimit%>"><%= database.get("name") %></a>
+</td>
+<td><%= database.status.humanSize() %></td>
+<td><%= database.status.numDocs() %></td>
+<td><%= database.status.updateSeq() %></td>
+<td>
+ <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a>
+ <a class="db-actions btn icon-lock set-permissions" title="Set permissions for <%= database.get("name") %>" href="#/database/<%=encoded%>/permissions"></a>
+</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/templates/list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/templates/list.html b/src/fauxton/app/addons/databases/templates/list.html
new file mode 100644
index 0000000..31c0977
--- /dev/null
+++ b/src/fauxton/app/addons/databases/templates/list.html
@@ -0,0 +1,35 @@
+<!--
+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="">
+ <div id="newButton" class="pull-left"></div>
+ <form id="jump-to-db" class="navbar-form pull-right input-append database-search">
+ <input type="text" class="search-autocomplete" name="search-query" placeholder="Database name"></input>
+ <button class="fonticon-search btn button red " type="submit"></button>
+ </form>
+
+
+</div>
+<table class="databases table table-striped">
+ <thead>
+ <th>Name</th>
+ <th>Size</th>
+ <th># of Docs</th>
+ <th>Update Seq</th>
+ <th>Actions</th>
+ </thead>
+ <tbody>
+ </tbody>
+</table>
+<div id="database-pagination"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/templates/newdatabase.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/templates/newdatabase.html b/src/fauxton/app/addons/databases/templates/newdatabase.html
new file mode 100644
index 0000000..b357e0b
--- /dev/null
+++ b/src/fauxton/app/addons/databases/templates/newdatabase.html
@@ -0,0 +1,17 @@
+<!--
+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.
+-->
+
+<a class="button new" id="new"><i class="icon fonticon-new-database"></i>Add New Database</a>
+
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/databases/templates/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/templates/sidebar.html b/src/fauxton/app/addons/databases/templates/sidebar.html
new file mode 100644
index 0000000..a8bbd89
--- /dev/null
+++ b/src/fauxton/app/addons/databases/templates/sidebar.html
@@ -0,0 +1,31 @@
+<!--
+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/89810cce/src/fauxton/app/addons/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js
new file mode 100644
index 0000000..80d64ed
--- /dev/null
+++ b/src/fauxton/app/addons/databases/views.js
@@ -0,0 +1,255 @@
+// 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",
+
+ "addons/fauxton/components",
+ "api",
+ "addons/databases/resources"
+],
+
+function(app, Components, FauxtonAPI, Databases) {
+ var Views = {};
+
+ Views.Item = FauxtonAPI.View.extend({
+ template: "templates/databases/item",
+ tagName: "tr",
+ establish: function(){
+ return [this.model.fetch()];
+ },
+ serialize: function() {
+ return {
+ encoded: app.mixins.safeURLName(this.model.get("name")),
+ database: this.model,
+ docLimit: Databases.DocLimit
+ };
+ }
+ });
+
+ Views.List = FauxtonAPI.View.extend({
+ dbLimit: 20,
+ perPage: 20,
+ template: "templates/databases/list",
+ events: {
+ "click button.all": "selectAll",
+ "submit form#jump-to-db": "switchDatabase"
+ },
+
+ initialize: function(options) {
+ var params = app.getParams();
+ this.page = params.page ? parseInt(params.page, 10) : 1;
+ },
+
+ serialize: function() {
+ return {
+ databases: this.collection
+ };
+ },
+ establish: function(){
+ var currentDBs = this.paginated();
+ var deferred = FauxtonAPI.Deferred();
+
+ FauxtonAPI.when(currentDBs.map(function(database) {
+ return database.status.fetch();
+ })).always(function(resp) {
+ //make this always so that even if a user is not allowed access to a database
+ //they will still see a list of all databases
+ deferred.resolve();
+ });
+ return [deferred];
+ },
+ switchDatabase: function(event, selectedName) {
+ event && event.preventDefault();
+
+ var dbname = this.$el.find("[name='search-query']").val().trim();
+
+ if (selectedName) {
+ dbname = selectedName;
+ }
+
+ if (dbname && this.collection.where({"id":app.mixins.safeURLName(dbname)}).length > 0){
+ // TODO: switch to using a model, or Databases.databaseUrl()
+ // Neither of which are in scope right now
+ // var db = new Database.Model({id: dbname});
+ var url = ["/database/", app.mixins.safeURLName(dbname), "/_all_docs?limit=" + Databases.DocLimit].join('');
+ FauxtonAPI.navigate(url);
+ } else {
+ FauxtonAPI.addNotification({
+ msg: 'Database does not exist.',
+ type: 'error'
+ });
+ }
+ },
+
+ paginated: function() {
+ var start = (this.page - 1) * this.perPage;
+ var end = this.page * this.perPage;
+ return this.collection.slice(start, end);
+ },
+
+ beforeRender: function() {
+
+ this.insertView("#newButton", new Views.NewDatabaseButton({
+ collection: this.collection
+ }));
+
+ _.each(this.paginated(), function(database) {
+ this.insertView("table.databases tbody", new Views.Item({
+ model: database
+ }));
+ }, this);
+
+ this.insertView("#database-pagination", new Components.Pagination({
+ page: this.page,
+ perPage: this.perPage,
+ total: this.collection.length,
+ urlFun: function(page) {
+ return "#/_all_dbs?page=" + page;
+ }
+ }));
+ },
+
+ setPage: function(page) {
+ this.page = page || 1;
+ },
+
+ afterRender: function() {
+ var that = this;
+ this.dbSearchTypeahead = new Components.DbSearchTypeahead({
+ dbLimit: this.dbLimit,
+ el: "input.search-autocomplete",
+ onUpdate: function (item) {
+ that.switchDatabase(null, item);
+ }
+ });
+
+ this.dbSearchTypeahead.render();
+ },
+
+ selectAll: function(evt){
+ $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
+ }
+ });
+
+
+ Views.NewDatabaseButton = FauxtonAPI.View.extend({
+ template: "templates/databases/newdatabase",
+ events: {
+ "click a#new": "newDatabase"
+ },
+ newDatabase: function() {
+ var notification;
+ var db;
+ // TODO: use a modal here instead of the prompt
+ var name = prompt('Name of database', 'newdatabase');
+ if (name === null) {
+ return;
+ } else if (name.length === 0) {
+ notification = FauxtonAPI.addNotification({
+ msg: "Please enter a valid database name",
+ type: "error",
+ clear: true
+ });
+ return;
+ }
+ db = new this.collection.model({
+ id: name,
+ name: name
+ });
+ notification = FauxtonAPI.addNotification({msg: "Creating database."});
+ db.save().done(function() {
+ notification = FauxtonAPI.addNotification({
+ msg: "Database created successfully",
+ type: "success",
+ clear: true
+ });
+ var route = "#/database/" + app.mixins.safeURLName(name) + "/_all_docs?limit=" + Databases.DocLimit;
+ app.router.navigate(route, { trigger: true });
+ }
+ ).error(function(xhr) {
+ var responseText = JSON.parse(xhr.responseText).reason;
+ notification = FauxtonAPI.addNotification({
+ msg: "Create database failed: " + responseText,
+ type: "error",
+ clear: true
+ });
+ }
+ );
+ }
+ });
+
+ Views.Sidebar = FauxtonAPI.View.extend({
+ template: "templates/databases/sidebar",
+ events: {
+ "click a#new": "newDatabase",
+ "click a#owned": "showMine",
+ "click a#shared": "showShared"
+ },
+
+ newDatabase: function() {
+ var notification;
+ var db;
+ // TODO: use a modal here instead of the prompt
+ var name = prompt('Name of database', 'newdatabase');
+ if (name === null) {
+ return;
+ } else if (name.length === 0) {
+ notification = FauxtonAPI.addNotification({
+ msg: "Please enter a valid database name",
+ type: "error",
+ clear: true
+ });
+ return;
+ }
+ db = new this.collection.model({
+ id: encodeURIComponent(name),
+ name: name
+ });
+ notification = FauxtonAPI.addNotification({msg: "Creating database."});
+ db.save().done(function() {
+ notification = FauxtonAPI.addNotification({
+ msg: "Database created successfully",
+ type: "success",
+ clear: true
+ });
+ var route = "#/database/" + name + "/_all_docs?limit=" + Databases.DocLimit;
+ app.router.navigate(route, { trigger: true });
+ }
+ ).error(function(xhr) {
+ var responseText = JSON.parse(xhr.responseText).reason;
+ notification = FauxtonAPI.addNotification({
+ msg: "Create database failed: " + responseText,
+ type: "error",
+ clear: true
+ });
+ }
+ );
+ },
+
+ showMine: function(){
+ $.contribute(
+ 'Show unshared databases',
+ 'app/addons/databases/views.js'
+ );
+ },
+
+ showShared: function(){
+ $.contribute(
+ 'Show shared databases (e.g. continuous replications to/from the database)',
+ 'app/addons/databases/views.js'
+ );
+ }
+ });
+
+ return Views;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/base.js b/src/fauxton/app/addons/documents/base.js
new file mode 100644
index 0000000..cb68a31
--- /dev/null
+++ b/src/fauxton/app/addons/documents/base.js
@@ -0,0 +1,24 @@
+// 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
+ "addons/documents/routes"
+],
+
+function(app, FauxtonAPI, Documents) {
+ return Documents;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
new file mode 100644
index 0000000..5254302
--- /dev/null
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -0,0 +1,646 @@
+// 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"
+],
+
+function(app, FauxtonAPI) {
+ var Documents = FauxtonAPI.addon();
+
+ Documents.Doc = Backbone.Model.extend({
+ idAttribute: "_id",
+ documentation: function(){
+ return "docs";
+ },
+ 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 if (context === "apiurl"){
+ return window.location.origin + "/" + this.getDatabase().safeID() + "/" + this.safeID();
+ } else {
+ return app.host + "/" + this.getDatabase().safeID() + "/" + this.safeID();
+ }
+ },
+
+ initialize: function(_attrs, options) {
+ if (this.collection && this.collection.database) {
+ this.database = this.collection.database;
+ } else if (options.database) {
+ this.database = options.database;
+ }
+ },
+
+ // HACK: the doc needs to know about the database, but it may be
+ // set directly or indirectly in all docs
+ getDatabase: function() {
+ return this.database ? this.database : this.collection.database;
+ },
+
+ validate: function(attrs, options) {
+ if (this.id && this.id !== attrs._id && this.get('_rev') ) {
+ return "Cannot change a documents id.";
+ }
+ },
+
+ docType: function() {
+ return this.id.match(/^_design/) ? "design doc" : "doc";
+ },
+
+ isEditable: function() {
+ return this.docType() != "reduction";
+ },
+
+ isDdoc: function() {
+ return this.docType() === "design doc";
+ },
+
+ hasViews: function() {
+ if (!this.isDdoc()) return false;
+ var doc = this.get('doc');
+ if (doc) {
+ return doc && doc.views && _.keys(doc.views).length > 0;
+ }
+
+ var views = this.get('views');
+ return views && _.keys(views).length > 0;
+ },
+
+ hasAttachments: function () {
+ return !!this.get('_attachments');
+ },
+
+ getDdocView: function(view) {
+ if (!this.isDdoc() || !this.hasViews()) return false;
+
+ var doc = this.get('doc');
+ if (doc) {
+ return doc.views[view];
+ }
+
+ return this.get('views')[view];
+ },
+
+ setDdocView: function (view, map, reduce) {
+ if (!this.isDdoc()) return false;
+ var views = this.get('views');
+ tempView = views[view] || {};
+
+ if (reduce) {
+ tempView.reduce=reduce;
+ } else {
+ delete tempView.reduce;
+ }
+ tempView.map= map;
+
+ views[view] = tempView;
+ this.set({views: views});
+
+ return true;
+ },
+
+ removeDdocView: function (viewName) {
+ if (!this.isDdoc()) return false;
+ var views = this.get('views');
+
+ delete views[viewName];
+ this.set({views: views});
+ },
+
+ dDocModel: function () {
+ if (!this.isDdoc()) return false;
+ var doc = this.get('doc');
+
+ if (doc) {
+ return new Documents.Doc(doc, {database: this.database});
+ }
+
+ return this;
+ },
+
+ viewHasReduce: function(viewName) {
+ var view = this.getDdocView(viewName);
+
+ return view && view.reduce;
+ },
+
+ // Need this to work around backbone router thinking _design/foo
+ // is a separate route. Alternatively, maybe these should be
+ // treated separately. For instance, we could default into the
+ // json editor for docs, or into a ddoc specific page.
+ safeID: function() {
+ if (this.isDdoc()){
+ var ddoc = this.id.replace(/^_design\//,"");
+ return "_design/"+app.mixins.safeURLName(ddoc);
+ }else{
+ return app.mixins.safeURLName(this.id);
+ }
+ },
+
+ destroy: function() {
+ var url = this.url() + "?rev=" + this.get('_rev');
+ return $.ajax({
+ url: url,
+ dataType: 'json',
+ type: 'DELETE'
+ });
+ },
+
+ parse: function(resp) {
+ if (resp.rev) {
+ resp._rev = resp.rev;
+ delete resp.rev;
+ }
+ if (resp.id) {
+ if (typeof(this.id) === "undefined") {
+ resp._id = resp.id;
+ }
+ delete resp.id;
+ }
+ if (resp.ok) {
+ delete resp.ok;
+ }
+ return resp;
+ },
+
+ prettyJSON: function() {
+ var data = this.get("doc") ? this.get("doc") : this;
+
+ return JSON.stringify(data, null, " ");
+ },
+
+ copy: function (copyId) {
+ return $.ajax({
+ type: 'COPY',
+ url: '/' + this.database.safeID() + '/' + this.safeID(),
+ headers: {Destination: copyId}
+ });
+ },
+
+ isNewDoc: function () {
+ return this.get('_rev') ? false : true;
+ }
+ });
+
+ Documents.DdocInfo = Backbone.Model.extend({
+ idAttribute: "_id",
+ documentation: function(){
+ return "docs";
+ },
+ initialize: function (_attrs, options) {
+ this.database = options.database;
+ },
+
+ url: function(context) {
+ if (context === "app") {
+ return this.database.url("app") + "/" + this.safeID() + '/_info';
+ } else if (context === "apiurl"){
+ return window.location.origin + "/" + this.database.safeID() + "/" + this.safeID() + '/_info';
+ } else {
+ return app.host + "/" + this.database.safeID() + "/" + this.safeID() + '/_info';
+ }
+ },
+
+ // Need this to work around backbone router thinking _design/foo
+ // is a separate route. Alternatively, maybe these should be
+ // treated separately. For instance, we could default into the
+ // json editor for docs, or into a ddoc specific page.
+ safeID: function() {
+ var ddoc = this.id.replace(/^_design\//,"");
+ return "_design/"+app.mixins.safeURLName(ddoc);
+ }
+
+ });
+
+ Documents.ViewRow = Backbone.Model.extend({
+ // this is a hack so that backbone.collections doesn't group
+ // these by id and reduce the number of items returned.
+ idAttribute: "_id",
+
+ docType: function() {
+ if (!this.id) return "reduction";
+
+ return this.id.match(/^_design/) ? "design doc" : "doc";
+ },
+ documentation: function(){
+ return "docs";
+ },
+ url: function(context) {
+ if (!this.isEditable()) return false;
+
+ return this.collection.database.url(context) + "/" + this.safeID();
+ },
+
+ isEditable: function() {
+ return this.docType() != "reduction";
+ },
+ safeID: function() {
+ return app.mixins.safeURLName(this.id);
+ },
+
+ prettyJSON: function() {
+ //var data = this.get("doc") ? this.get("doc") : this;
+ return JSON.stringify(this, null, " ");
+ }
+ });
+
+ Documents.NewDoc = Documents.Doc.extend({
+ fetch: function() {
+ var uuid = new FauxtonAPI.UUID();
+ var deferred = this.deferred = $.Deferred();
+ var that = this;
+
+ uuid.fetch().done(function() {
+ that.set("_id", uuid.next());
+ deferred.resolve();
+ });
+
+ return deferred.promise();
+ }
+
+ });
+
+ Documents.AllDocs = Backbone.Collection.extend({
+ model: Documents.Doc,
+ documentation: function(){
+ return "docs";
+ },
+ initialize: function(_models, options) {
+ this.database = options.database;
+ this.params = options.params;
+ this.skipFirstItem = false;
+
+ this.on("remove",this.decrementTotalRows , this);
+ },
+
+ url: function(context) {
+ var query = "";
+ if (this.params) {
+ query = "?" + $.param(this.params);
+ }
+
+ if (context === 'app') {
+ return 'database/' + this.database.safeID() + "/_all_docs" + query;
+ } else if (context === "apiurl"){
+ return window.location.origin + "/" + this.database.safeID() + "/_all_docs" + query;
+ } else {
+ return app.host + "/" + this.database.safeID() + "/_all_docs" + query;
+ }
+ },
+
+ simple: function () {
+ var docs = this.map(function (item) {
+ return {
+ _id: item.id,
+ _rev: item.get('_rev'),
+ };
+ });
+
+ return new Documents.AllDocs(docs, {
+ database: this.database,
+ params: this.params
+ });
+ },
+
+ urlNextPage: function (num, lastId) {
+ if (!lastId) {
+ var doc = this.last();
+
+ if (doc) {
+ lastId = doc.id;
+ } else {
+ lastId = '';
+ }
+ }
+
+ this.params.startkey_docid = '"' + lastId + '"';
+ this.params.startkey = '"' + lastId + '"';
+ // when paginating forward, fetch 21 and don't show
+ // the first item as it was the last item in the previous list
+ this.params.limit = num + 1;
+ return this.url('app');
+ },
+
+ urlPreviousPage: function (num, params) {
+ if (params) {
+ this.params = params;
+ } else {
+ this.params = {reduce: false};
+ }
+
+ this.params.limit = num;
+ return this.url('app');
+ },
+
+ totalRows: function() {
+ return this.viewMeta.total_rows || "unknown";
+ },
+
+ decrementTotalRows: function () {
+ if (this.viewMeta.total_rows) {
+ this.viewMeta.total_rows = this.viewMeta.total_rows -1;
+ this.trigger('totalRows:decrement');
+ }
+ },
+
+ updateSeq: function() {
+ return this.viewMeta.update_seq || false;
+ },
+
+ recordStart: function () {
+ if (this.viewMeta.offset === 0) {
+ return 1;
+ }
+
+ if (this.skipFirstItem) {
+ return this.viewMeta.offset + 2;
+ }
+
+ return this.viewMeta.offset + 1;
+ },
+
+ parse: function(resp) {
+ var rows = resp.rows;
+
+ this.viewMeta = {
+ total_rows: resp.total_rows,
+ offset: resp.offset,
+ update_seq: resp.update_seq
+ };
+
+ //Paginating, don't show first item as it was the last
+ //item in the previous page
+ if (this.skipFirstItem) {
+ rows = rows.splice(1);
+ }
+ return _.map(rows, function(row) {
+ return {
+ _id: row.id,
+ _rev: row.value.rev,
+ value: row.value,
+ key: row.key,
+ doc: row.doc || undefined
+ };
+ });
+ }
+ });
+
+ Documents.IndexCollection = Backbone.Collection.extend({
+ model: Documents.ViewRow,
+ documentation: function(){
+ return "docs";
+ },
+ initialize: function(_models, options) {
+ this.database = options.database;
+ this.params = _.extend({limit: 20, reduce: false}, options.params);
+ this.idxType = "_view";
+ this.view = options.view;
+ this.design = options.design.replace('_design/','');
+ this.skipFirstItem = false;
+ },
+
+ url: function(context) {
+ var query = "";
+ if (this.params) {
+ query = "?" + $.param(this.params);
+ }
+
+ var startOfUrl = app.host;
+ if (context === 'app') {
+ startOfUrl = 'database';
+ } else if (context === "apiurl"){
+ startOfUrl = window.location.origin;
+ }
+ var design = app.mixins.safeURLName(this.design),
+ view = app.mixins.safeURLName(this.view);
+
+ var url = [startOfUrl, this.database.safeID(), "_design", design, this.idxType, view];
+ return url.join("/") + query;
+ },
+
+ urlNextPage: function (num, lastId) {
+ if (!lastId) {
+ lastDoc = this.last();
+ }
+
+ var id = lastDoc.get("id");
+ if (id) {
+ this.params.startkey_docid = id;
+ }
+
+ this.params.startkey = JSON.stringify(lastDoc.get('key'));
+ this.params.limit = num + 1;
+ return this.url('app');
+ },
+
+ urlPreviousPage: function (num, params) {
+ if (params) {
+ this.params = params;
+ } else {
+ this.params = {reduce: false};
+ }
+
+ this.params.limit = num;
+ return this.url('app');
+ },
+
+ recordStart: function () {
+ if (this.viewMeta.offset === 0) {
+ return 1;
+ }
+
+ if (this.skipFirstItem) {
+ return this.viewMeta.offset + 2;
+ }
+
+ return this.viewMeta.offset + 1;
+ },
+
+ totalRows: function() {
+ if (this.params.reduce) { return "unknown_reduce";}
+
+ return this.viewMeta.total_rows || "unknown";
+ },
+
+ updateSeq: function() {
+ return this.viewMeta.update_seq || false;
+ },
+
+ simple: function () {
+ var docs = this.map(function (item) {
+ return {
+ _id: item.id,
+ key: item.get('key'),
+ value: item.get('value')
+ };
+ });
+
+ return new Documents.IndexCollection(docs, {
+ database: this.database,
+ params: this.params,
+ view: this.view,
+ design: this.design
+ });
+ },
+
+ parse: function(resp) {
+ var rows = resp.rows;
+ this.endTime = new Date().getTime();
+ this.requestDuration = (this.endTime - this.startTime);
+
+ if (this.skipFirstItem) {
+ rows = rows.splice(1);
+ }
+
+ this.viewMeta = {
+ total_rows: resp.total_rows,
+ offset: resp.offset,
+ update_seq: resp.update_seq
+ };
+ return _.map(rows, function(row) {
+ return {
+ value: row.value,
+ key: row.key,
+ doc: row.doc,
+ id: row.id
+ };
+ });
+ },
+
+ buildAllDocs: function(){
+ this.fetch();
+ },
+
+ // We implement our own fetch to store the starttime so we that
+ // we can get the request duration
+ fetch: function () {
+ this.startTime = new Date().getTime();
+ return Backbone.Collection.prototype.fetch.call(this);
+ },
+
+ allDocs: function(){
+ return this.models;
+ },
+
+ // This is taken from futon.browse.js $.timeString
+ requestDurationInString: function () {
+ var ms, sec, min, h, timeString, milliseconds = this.requestDuration;
+
+ sec = Math.floor(milliseconds / 1000.0);
+ min = Math.floor(sec / 60.0);
+ sec = (sec % 60.0).toString();
+ if (sec.length < 2) {
+ sec = "0" + sec;
+ }
+
+ h = (Math.floor(min / 60.0)).toString();
+ if (h.length < 2) {
+ h = "0" + h;
+ }
+
+ min = (min % 60.0).toString();
+ if (min.length < 2) {
+ min = "0" + min;
+ }
+
+ timeString = h + ":" + min + ":" + sec;
+
+ ms = (milliseconds % 1000.0).toString();
+ while (ms.length < 3) {
+ ms = "0" + ms;
+ }
+ timeString += "." + ms;
+
+ return timeString;
+ }
+ });
+
+
+ Documents.PouchIndexCollection = Backbone.Collection.extend({
+ model: Documents.ViewRow,
+ documentation: function(){
+ return "docs";
+ },
+ initialize: function(_models, options) {
+ this.database = options.database;
+ this.rows = options.rows;
+ this.view = options.view;
+ this.design = options.design.replace('_design/','');
+ this.params = _.extend({limit: 20, reduce: false}, options.params);
+ this.idxType = "_view";
+ },
+
+ url: function () {
+ return '';
+ },
+
+ simple: function () {
+ var docs = this.map(function (item) {
+ return {
+ _id: item.id,
+ key: item.get('key'),
+ value: item.get('value')
+ };
+ });
+
+ return new Documents.PouchIndexCollection(docs, {
+ database: this.database,
+ params: this.params,
+ view: this.view,
+ design: this.design,
+ rows: this.rows
+ });
+
+ },
+
+ fetch: function() {
+ var deferred = FauxtonAPI.Deferred();
+ this.reset(this.rows, {silent: true});
+
+ this.viewMeta = {
+ total_rows: this.rows.length,
+ offset: 0,
+ update_seq: false
+ };
+
+ deferred.resolve();
+ return deferred;
+ },
+
+ recordStart: function () {
+ return 1;
+ },
+
+ totalRows: function() {
+ return this.viewMeta.total_rows || "unknown";
+ },
+
+ updateSeq: function() {
+ return this.viewMeta.update_seq || false;
+ },
+
+ buildAllDocs: function(){
+ this.fetch();
+ },
+
+ allDocs: function(){
+ return this.models;
+ }
+ });
+
+
+
+ return Documents;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js
new file mode 100644
index 0000000..d120feb
--- /dev/null
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -0,0 +1,409 @@
+// 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
+ "addons/documents/views",
+ "addons/databases/base"
+],
+
+function(app, FauxtonAPI, Documents, Databases) {
+
+ var DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "one_pane",
+ disableLoader: true,
+ selectedHeader: "Databases",
+ initialize: function(route, masterLayout, options) {
+ var databaseName = options[0];
+ this.docID = options[1]||'new';
+
+ this.database = this.database || new Databases.Model({id: databaseName});
+ this.doc = new Documents.Doc({
+ _id: this.docID
+ }, {
+ database: this.database
+ });
+
+ this.tabsView = this.setView("#tabs", new Documents.Views.FieldEditorTabs({
+ disableLoader: true,
+ selected: "code_editor",
+ model: this.doc
+ }));
+
+ },
+
+ routes: {
+ // We are hiding the field_editor for this first release
+ // "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": 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.safeID() + '/' + app.mixins.safeURLName(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("apiurl"), this.doc.documentation()];
+ }
+ });
+
+ 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
+ }));
+
+ },
+ crumbs: function() {
+ return [
+ {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
+ {"name": "New", "link": "#"}
+ ];
+ },
+ routes: {
+ "database/:database/new": "code_editor"
+ },
+ selectedHeader: "Databases",
+
+ });
+
+ var DocumentsRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "with_tabs_sidebar",
+ selectedHeader: "Databases",
+ 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",
+ "route:paginate": "paginate"
+ },
+
+ 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
+ }));
+ },
+
+ establish: function () {
+ return this.data.designDocs.fetch();
+ },
+
+ allDocs: function(databaseName, options) {
+ var docOptions = app.getParams(options);
+
+ 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.toolsView = this.setView("#dashboard-upper-menu", new Documents.Views.JumpToDoc({
+ database: this.data.database,
+ collection: this.data.database.allDocs
+ }));
+
+ this.setView("#dashboard-upper-content", new Documents.Views.AllDocsLayout({
+ database: this.data.database,
+ collection: this.data.database.allDocs,
+ params: docOptions
+ }));
+
+ this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
+ collection: this.data.database.allDocs
+ }));
+
+ this.crumbs = [
+ {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
+ ];
+
+ this.apiUrl = [this.data.database.allDocs.url("apiurl"), this.data.database.allDocs.documentation() ];
+ },
+
+ viewFn: function (databaseName, ddoc, view) {
+ var params = app.getParams(),
+ decodeDdoc = decodeURIComponent(ddoc);
+
+ view = view.replace(/\?.*$/,'');
+
+ this.data.indexedDocs = new Documents.IndexCollection(null, {
+ database: this.data.database,
+ design: decodeDdoc,
+ view: view,
+ params: params
+ });
+
+ var ddocInfo = {
+ id: "_design/" + decodeDdoc,
+ 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
+ }));
+
+ if (this.toolsView) { this.toolsView.remove(); }
+
+ 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(app.mixins.removeSpecialCharacters(ddoc) + '_' + app.mixins.removeSpecialCharacters(view));
+
+ this.crumbs = function () {
+ return [
+ {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)},
+ ];
+ };
+
+ this.apiUrl = [this.data.indexedDocs.url("apiurl"), "docs"];
+ },
+
+ newViewEditor: function () {
+ var params = app.getParams();
+
+ if (this.toolsView) {
+ this.toolsView.remove();
+ }
+
+ 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');
+ this.crumbs = function () {
+ return [
+ {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)},
+ ];
+ };
+ },
+
+ updateAllDocsFromView: function (event) {
+ var view = event.view,
+ docOptions = app.getParams(),
+ ddoc = event.ddoc;
+
+ this.documentsView && this.documentsView.remove();
+
+ if (event.allDocs) {
+ this.data.database.buildAllDocs(docOptions);
+ this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
+ collection: this.data.database.allDocs
+ }));
+ return;
+ }
+
+ 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
+ }));
+ },
+
+ paginate: function (direction) {
+ _.extend(this.documentsView.collection.params, app.getParams());
+ this.documentsView.forceRender();
+ if (direction === 'next') {
+ this.documentsView.collection.skipFirstItem = true;
+ } else {
+ this.documentsView.collection.skipFirstItem = false;
+ }
+ },
+
+ reloadDesignDocs: function (event) {
+ this.sidebar.forceRender();
+
+ if (event && event.selectedTab) {
+ this.sidebar.setSelectedTab(event.selectedTab);
+ }
+ }
+
+ });
+
+ var ChangesRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "with_tabs",
+ selectedHeader: "Databases",
+ crumbs: function () {
+ return [
+ {"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.url("apiurl"), this.database.documentation()];
+ }
+
+ });
+
+ Documents.RouteObjects = [DocEditorRouteObject, NewDocEditorRouteObject, DocumentsRouteObject, ChangesRouteObject];
+
+ return Documents;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/advanced_options.html b/src/fauxton/app/addons/documents/templates/advanced_options.html
new file mode 100644
index 0000000..8e96574
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -0,0 +1,97 @@
+<!--
+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="errors-container"></div>
+<form class="view-query-update custom-inputs">
+ <div class="controls-group">
+ <div class="row-fluid">
+ <div class="controls controls-row">
+ <input name="key" class="span6" type="text" placeholder="Key">
+ <input name="keys" class="span6" type="text" placeholder="Keys">
+ </div>
+ </div>
+ <div class="row-fluid">
+ <div class="controls controls-row">
+ <input name="startkey" class="span6" type="text" placeholder="Start Key">
+ <input name="endkey" class="span6" type="text" placeholder="End Key">
+ </div>
+ </div>
+ </div>
+ <div class="controls-group">
+ <div class="row-fluid">
+ <div class="controls controls-row">
+ <div class="checkbox inline">
+ <input id="check1" type="checkbox" name="include_docs" value="true">
+ <label name="include_docs" for="check1">Include Docs</label>
+ <% if (hasReduce) { %>
+ <input id="check2" name="reduce" type="checkbox" value="true">
+ <label for="check2">Reduce</label>
+ </div>
+ <label id="select1" class="drop-down inline">
+ Group Level:
+ <select id="select1" disabled name="group_level" class="input-small">
+ <option value="0">None</option>
+ <option value="1">1</option>
+ <option value="2">2</option>
+ <option value="3">3</option>
+ <option value="4">4</option>
+ <option value="5">5</option>
+ <option value="6">6</option>
+ <option value="7">7</option>
+ <option value="8">8</option>
+ <option value="9">9</option>
+ <option value="999" selected="selected">exact</option>
+ </select>
+ </label>
+ <% } else{ %>
+ </div>
+ <% } %>
+
+ <div class="checkbox inline">
+ <input id="check3" name="stale" type="checkbox" value="ok">
+ <label for="check3">Stale</label>
+ <input id="check4" name="descending" type="checkbox" value="true">
+ <label for="check4">Descending</label>
+ </div>
+ <label class="drop-down inline">
+ Limit:
+ <select name="limit" class="input-small">
+ <option>5</option>
+ <option selected="selected">10</option>
+ <option>25</option>
+ <option>50</option>
+ <option>100</option>
+ </select>
+ </label>
+ <div class="checkbox inline">
+ <input id="check5" name="inclusive_end" type="checkbox" value="false">
+ <label for="check5">Disable Inclusive End</label>
+ <input id="check6" name="update_seq" type="checkbox" value="true">
+ <label for="check6">Update Sequence</label>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="controls-group">
+ <div class="row-fluid">
+ <div id="button-options" class="controls controls-row">
+ <button type="submit" class="button green">Query</button>
+ <% if (showPreview) { %>
+ <button class="button btn-info preview">Browser Preview</button>
+ <% } %>
+ </div>
+ </div>
+ </div>
+</form>
+</div>
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/all_docs_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_item.html b/src/fauxton/app/addons/documents/templates/all_docs_item.html
new file mode 100644
index 0000000..bfedaaa
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/all_docs_item.html
@@ -0,0 +1,26 @@
+<!--
+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('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>
+ <% } %>
+ </div>
+</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/all_docs_layout.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_layout.html b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
new file mode 100644
index 0000000..526c200
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
@@ -0,0 +1,20 @@
+<!--
+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.
+-->
+<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav">
+ <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
+</ul>
+<div class="tab-content">
+ <div class="tab-pane" id="query">
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_list.html b/src/fauxton/app/addons/documents/templates/all_docs_list.html
new file mode 100644
index 0000000..335b040
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/all_docs_list.html
@@ -0,0 +1,43 @@
+<!--
+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>
+ <% if (expandDocs) { %>
+ <button id="collapse" class="btn"><i class="icon-minus"></i> Collapse</button>
+ <% } else { %>
+ <button id="collapse" class="btn"><i class="icon-plus"></i> Expand</button>
+ <% } %>
+ </div>
+ </div>
+ <% } %>
+ <p>
+
+ <div id="item-numbers"> </div>
+
+ <% 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 id="documents-pagination"></div>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/all_docs_number.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_number.html b/src/fauxton/app/addons/documents/templates/all_docs_number.html
new file mode 100644
index 0000000..c4ea8f6
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<% if (totalRows === "unknown"){ %>
+ Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
+<% } else { %>
+ Showing <%=offset%> - <%= numModels %> of <%= totalRows %> rows
+<%}%>
+<% if (updateSeq) { %>
+ -- Update Sequence: <%= updateSeq %>
+<% } %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/changes.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/changes.html b/src/fauxton/app/addons/documents/templates/changes.html
new file mode 100644
index 0000000..9408979
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/changes.html
@@ -0,0 +1,38 @@
+<!--
+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.
+-->
+
+<table id="changes-table" class="table">
+ <thead>
+ <th id="seq"> seq </th>
+ <th> id </th>
+ <th id="changes"> changes </th>
+ <th id="deleted"> deleted? </th>
+ </thead>
+ <tbody>
+ <% _.each(changes, function (change) { %>
+ <tr>
+ <td> <%= change.seq %> </td>
+ <% if (change.deleted) { %>
+ <td> <%= change.id %> </td>
+ <% } else { %>
+ <td> <a href="#<%= database.url('app') %>/<%= change.id %>"><%= change.id %></a> </td>
+ <% } %>
+ <td>
+ <pre class="prettyprint"> <%- JSON.stringify({changes: change.changes, doc: change.doc}, null, " ") %> </pre>
+ </td>
+ <td><%= change.deleted ? "true" : "false" %></td>
+ </tr>
+ <% }); %>
+ </tbody>
+</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/ddoc_info.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/ddoc_info.html b/src/fauxton/app/addons/documents/templates/ddoc_info.html
new file mode 100644
index 0000000..ed0aed6
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/ddoc_info.html
@@ -0,0 +1,28 @@
+<!--
+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>
+ <h2> Design Doc MetaData </h2>
+ <div class="row-fluid">
+ <% i=0; _.map(view_index, function (val, key) { %>
+ <% if(i%2==0){%>
+ <div class="row-fluid">
+ <% }; %>
+ <div class="span6 well-item"><strong> <%= key %></strong> : <%= val %> </div>
+ <% if(i%2==1){%>
+ </div>
+ <% }; %>
+ <% ++i;
+ }); %>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/design_doc_selector.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/design_doc_selector.html b/src/fauxton/app/addons/documents/templates/design_doc_selector.html
new file mode 100644
index 0000000..7bbe310
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/design_doc_selector.html
@@ -0,0 +1,35 @@
+<!--
+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="span3">
+ <label for="ddoc">Save to Design Document <a href="<%=getDocUrl('design_doc')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
+ <select id="ddoc">
+ <optgroup label="Select a document">
+ <option value="new-doc">New document</option>
+ <% ddocs.each(function(ddoc) { %>
+ <% if (ddoc.id === ddocName) { %>
+ <option selected="selected" value="<%= ddoc.id %>"><%= ddoc.id %></option>
+ <% } else { %>
+ <option value="<%= ddoc.id %>"><%= ddoc.id %></option>
+ <% } %>
+ <% }); %>
+ </optgroup>
+ </select>
+</div>
+
+<div id="new-ddoc-section" class="span5" style="display:none">
+ <label class="control-label" for="new-ddoc"> _design/ </label>
+ <div class="controls">
+ <input type="text" id="new-ddoc" placeholder="newDesignDoc">
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/doc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/doc.html b/src/fauxton/app/addons/documents/templates/doc.html
new file mode 100644
index 0000000..10bbf8b
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/doc.html
@@ -0,0 +1,55 @@
+<!--
+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 id="doc">
+ <div class="errors-container"></div>
+
+<div class="row doc-editor-buttons">
+ <div class="span3">
+ <button class="save-doc button green btn-medium save fonticon-circle-check" type="button">Save</button>
+ <button class="button cancel-button gray btn-medium">Back to _all_docs</button>
+ </div>
+
+ <div class="span7">
+ <% if (attachments) { %>
+ <div class="btn-group">
+ <a class="button gray btn-medium dropdown-toggle btn" data-bypass="true" data-toggle="dropdown" href="#">
+ View Attachments
+ <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu">
+ <%_.each(attachments, function (att) { %>
+ <li>
+ <a href="<%= att.url %>" target="_blank"> <strong> <%= att.fileName %> </strong> -
+ <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
+ </a>
+ </li>
+ <% }) %>
+ </ul>
+ </div>
+ <% } %>
+ <button class="button gray btn-medium upload"><i class="icon-circle-arrow-up"></i> Upload Attachment</button>
+ <button class="button gray btn-medium duplicate"><i class="icon-repeat"></i> Duplicate document</button>
+ </div>
+
+ <button class="button red btn-medium delete"><i class="icon-trash"></i></button>
+ </ul>
+
+<div id="upload-modal"> </div>
+<div id="duplicate-modal"> </div>
+</div>
+
+ <div id="editor-container" class="doc-code"><%- JSON.stringify(doc.attributes, null, " ") %></div>
+
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/doc_field_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/doc_field_editor.html b/src/fauxton/app/addons/documents/templates/doc_field_editor.html
new file mode 100644
index 0000000..77d9278
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/doc_field_editor.html
@@ -0,0 +1,74 @@
+<!--
+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 id="doc-field-editor">
+ <div class="tools">
+
+ <div class="btn-toolbar pull-left">
+ <button class="btn btn-small all">✓ All</button>
+ <button class="btn btn-small disabled delete"><i class="icon-trash"></i> Delete field</button>
+ <button class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</button>
+ </div>
+ <div class="btn-toolbar pull-right">
+ <button class="btn btn-small cancel button cancel-button outlineGray fonticon-circle-x">Cancel</button>
+ <button class="btn btn-small save button green fonticon-circle-check">Save</button>
+ </div>
+ </div>
+
+ <div class="clearfix"></div>
+ <!-- <hr style="margin-top: 0"/> -->
+
+ <table class="table table-striped table-condensed">
+ <thead>
+ <tr>
+ <th class="select">
+ </th>
+ <th>Key</th>
+ <th>Value</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr style="display:none">
+ <td class="select"><input type="checkbox" /></td>
+ <td class="key"><input type="text" class="input-large" value='' /></td>
+ <td class="value"><input type="text" class="input-xxlarge" value='' /></td>
+ </tr>
+ <% _.each(doc, function(value, key) { %>
+ <tr>
+ <td class="select"><input type="checkbox" /></td>
+ <td class="key">
+ <input type="text" class="input-large" name="doc[<%= key %>]" value="<%= key %>" />
+ </td>
+ <td class="value"><input type="text" class="input-xxlarge" value='<%= JSON.stringify(value) %>' /></td>
+ </tr>
+ <% }); %>
+ <tr>
+ <th colspan="3">
+ Attachments
+ </th>
+ </tr>
+ <%_.each(attachments, function (att) { %>
+ <tr>
+ <td class="select"><input type="checkbox" /></td>
+ <td colspan="2">
+ <a href="<%= att.url %>" target="_blank"> <%= att.fileName %> </a>
+ <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
+ </td>
+ </tr>
+ <% }) %>
+ </tbody>
+ </table>
+ <a class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</a>
+
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/doc_field_editor_tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/doc_field_editor_tabs.html b/src/fauxton/app/addons/documents/templates/doc_field_editor_tabs.html
new file mode 100644
index 0000000..766647c
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/doc_field_editor_tabs.html
@@ -0,0 +1,19 @@
+<!--
+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.
+-->
+
+<!--<ul class="nav nav-tabs">
+ <li id="field_editor" class="<%= isSelectedClass('field_editor') %>"><a href="#<%= doc.url('app') %>/field_editor">Doc fields</a></li>
+ <li id="code_editor" class="<%= isSelectedClass('code_editor') %>"><a href="#<%= doc.url('app') %>/code_editor"><i class="icon-pencil"> </i> Code editor</a>
+ </li>
+</ul>-->
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
new file mode 100644
index 0000000..3f374b6
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
@@ -0,0 +1,36 @@
+<!--
+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="modal hide fade">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3>Duplicate Document</h3>
+ </div>
+ <div class="modal-body">
+ <div id="modal-error" class="hide alert alert-error"/>
+ <form id="file-upload" class="form" method="post">
+ <p class="help-block">
+ Set new documents ID:
+ </p>
+ <input id="dup-id" type="text" class="input-xlarge">
+ </form>
+
+ </div>
+ <div class="modal-footer">
+ <a href="#" data-dismiss="modal" class="btn button cancel-button outlineGray fonticon-circle-x">Cancel</a>
+ <a href="#" id="duplicate-btn" class="btn btn-primary button green save fonticon-circle-check">Duplicate</a>
+ </div>
+</div>
+
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/edit_tools.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/edit_tools.html b/src/fauxton/app/addons/documents/templates/edit_tools.html
new file mode 100644
index 0000000..40c884d
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/edit_tools.html
@@ -0,0 +1,44 @@
+<!--
+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">
+ <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="#">«</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="#">»</a></li>
+ </ul>
+ </div>
+ -->
+
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/index_menu_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_menu_item.html b/src/fauxton/app/addons/documents/templates/index_menu_item.html
new file mode 100644
index 0000000..7ca9012
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/index_menu_item.html
@@ -0,0 +1,17 @@
+<!--
+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.
+-->
+
+<a id="<%= ddoc_clean %>_<%= index_clean %>" href="#database/<%= database_encoded %>/_design/<%= ddoc_encoded %>/_view/<%= index_encoded %>" class="toggle-view">
+ <%= ddoc %><span class="divider">/</span><%= index %>
+</a>
[40/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
added fauxton grunt test stuff to .travis.yml
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c56e5a88
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c56e5a88
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c56e5a88
Branch: refs/heads/api-options
Commit: c56e5a88dfed49e0f8661b4b7d579d0860151997
Parents: f04485f
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Tue Jan 14 16:01:32 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 16 15:10:40 2014 +0200
----------------------------------------------------------------------
.travis.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/c56e5a88/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 827badf..f90895d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,11 @@ before_install:
- sudo apt-get -y install texlive-latex-extra texlive-fonts-recommended texinfo
- sudo apt-get -y install python-pygments python-docutils python-sphinx
before_script: ./bootstrap && ./configure
-script: make distcheck
+script:
+ - make distcheck
+ - cd src/fauxton
+ - npm install
+ - grunt test
language: erlang
otp_release:
- R16B
[19/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fix css files for addon mode
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/861f2024
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/861f2024
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/861f2024
Branch: refs/heads/api-options
Commit: 861f20249a4358dd5acbd8a44f5096f0b47bddf2
Parents: 3465b04
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 6 10:44:19 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 13 11:19:11 2014 +0200
----------------------------------------------------------------------
.../app/addons/config/assets/less/config.less | 3 ---
.../addons/documents/assets/less/documents.less | 11 +++++++++++
src/fauxton/app/addons/fauxton/base.js | 19 +++++++++----------
src/fauxton/assets/less/fauxton.less | 6 +-----
4 files changed, 21 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/861f2024/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 8495b69..737beb4 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -10,14 +10,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-
.config-item {
height: 41px;
.edit-button {
float: right;
- .btn;
- .btn-mini;
display:none;
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/861f2024/src/fauxton/app/addons/documents/assets/less/documents.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/assets/less/documents.less b/src/fauxton/app/addons/documents/assets/less/documents.less
new file mode 100644
index 0000000..ff9e88c
--- /dev/null
+++ b/src/fauxton/app/addons/documents/assets/less/documents.less
@@ -0,0 +1,11 @@
+/*ALL DOCS TABLE*/
+tr.all-docs-item{
+ border: none;
+ background: transparent;
+ .btn-group {
+ position: absolute;
+ right: 0;
+ top: 6px;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/861f2024/src/fauxton/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js
index aa4c3d4..1811e84 100644
--- a/src/fauxton/app/addons/fauxton/base.js
+++ b/src/fauxton/app/addons/fauxton/base.js
@@ -11,19 +11,18 @@
// the License.
define([
- "app",
- // Libs
- "backbone",
- "resizeColumns",
+ "app",
+ // Libs
+ "backbone",
+ "resizeColumns",
],
function(app, Backbone, resizeColumns) {
-
//resizeAnimation
app.resizeColumns = new resizeColumns({});
app.resizeColumns.onResizeHandler();
-
+
var Fauxton = {};
Fauxton.Breadcrumbs = Backbone.View.extend({
@@ -136,7 +135,7 @@ function(app, Backbone, resizeColumns) {
if(!$(e.target).is('a')){
toggleMenu();
}
- }
+ }
});
function toggleMenu(){
@@ -147,8 +146,8 @@ function(app, Backbone, resizeColumns) {
$('#primary-navbar').on("click", ".nav a", function(){
if (!($selectorList.hasClass('closeMenu'))){
- setTimeout(
- function(){
+ setTimeout(
+ function(){
$selectorList.addClass('closeMenu');
app.resizeColumns.onResizeHandler();
},3000);
@@ -266,6 +265,6 @@ function(app, Backbone, resizeColumns) {
}
});
-
+
return Fauxton;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/861f2024/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index d41780a..e1cfa06 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -911,11 +911,7 @@ pre.prettyprint {
color: #333333;
}
-/*ALL DOCS TABLE*/
-tr.all-docs-item{
- border: none;
- background: transparent;
-}
+
/*logs*/
#log-sidebar{
[11/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
added build-aux/compile to gitignore
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/62f939c2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/62f939c2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/62f939c2
Branch: refs/heads/api-options
Commit: 62f939c22cbbda69f5dfd9fd062eab74f9287512
Parents: e7b0a9a
Author: Andy Wenk <an...@apache.org>
Authored: Sun Jan 12 01:58:24 2014 +0100
Committer: Andy Wenk <an...@apache.org>
Committed: Sun Jan 12 11:20:20 2014 +0100
----------------------------------------------------------------------
.gitignore | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/62f939c2/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 1f8c4a6..3d6c0f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@ bin/couchjs_dev
bin/couchpw
build-aux/config.*
build-aux/depcomp
+build-aux/compile
build-aux/install-sh
build-aux/ltmain.sh
build-aux/missing
[24/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
blank files might sink ships
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b71c719d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b71c719d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b71c719d
Branch: refs/heads/api-options
Commit: b71c719dc44bbda8ec169320a38216e560b863c2
Parents: 6530f95
Author: Jan Lehnardt <ja...@apache.org>
Authored: Mon Jan 13 20:25:45 2014 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Mon Jan 13 20:26:05 2014 +0100
----------------------------------------------------------------------
.../priv/default.d/my_first_couchdb_plugin.ini | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b71c719d/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
----------------------------------------------------------------------
diff --git a/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini b/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
index e69de29..fbc2d98 100644
--- a/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
+++ b/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
@@ -0,0 +1,3 @@
+;per-plugin configuration goes here
+;[plugin-name]
+;config=value
[16/50] [abbrv] Fauxton: move modules to addons
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
new file mode 100644
index 0000000..3835453
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -0,0 +1,26 @@
+<!--
+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"></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/89810cce/src/fauxton/app/addons/documents/templates/index_row_tabular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_tabular.html b/src/fauxton/app/addons/documents/templates/index_row_tabular.html
new file mode 100644
index 0000000..f5f68fa
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/index_row_tabular.html
@@ -0,0 +1,25 @@
+<!--
+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"></td>
+<td>
+ <div>
+ <pre class="prettyprint"><%- JSON.stringify(doc.get("key")) %></pre>
+ </div>
+</td>
+<td>
+ <div>
+ <pre class="prettyprint"><%- JSON.stringify(doc.get("value")) %></pre>
+ </div>
+</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/jumpdoc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/jumpdoc.html b/src/fauxton/app/addons/documents/templates/jumpdoc.html
new file mode 100644
index 0000000..43fdb9c
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/jumpdoc.html
@@ -0,0 +1,19 @@
+<!--
+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.
+-->
+
+<form id="jump-to-doc" class="form-inline input-append" >
+ <input type="text" id="jump-to-doc-id" class="input-large" placeholder="Document ID"></input>
+
+ <button class="fonticon-search btn button red " type="submit"></button>
+</form>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/search.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/search.html b/src/fauxton/app/addons/documents/templates/search.html
new file mode 100644
index 0000000..bb84891
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/search.html
@@ -0,0 +1,15 @@
+<!--
+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.
+-->
+
+<input id="searchbox" type="text" class="span12" placeholder="Search by doc id, view key or search index">
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/sidebar.html b/src/fauxton/app/addons/documents/templates/sidebar.html
new file mode 100644
index 0000000..8a73ae9
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/sidebar.html
@@ -0,0 +1,67 @@
+<!--
+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 id="sidenav">
+ <header class="row-fluid">
+ <div class="span12">
+ <div class="btn-group">
+ <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown">
+ Docs
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ <!-- dropdown menu links -->
+ <li><a class="icon-file" href="<%= db_url %>">Docs</a></li>
+ <li><a class="icon-lock" href="<%= permissions_url %>">Permissions</a></li>
+ <li><a class="icon-forward" href="<%= changes_url %>">Changes</a></li>
+ <% _.each(docLinks, function (link) { %>
+ <li><a class="<%= link.icon %>" href="<%= database_url + '/' + link.url %>"><%= link.title %></a></li>
+ <% }); %>
+ </ul>
+ </div>
+
+ <div class="btn-group">
+ <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown">
+ New
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ <!-- dropdown menu links -->
+ <li>
+ <a id="doc" href="#<%= database.url('app') %>/new">Document</a>
+ </li>
+ <li>
+ <a href="#<%= database.url('app') %>/new_view">Secondary Index</a>
+ <% _.each(newLinks, function (item) { %>
+ <a href="#<%= database.url('app') %>/<%=item.url%>"> <%= item.name %></a>
+ <% }); %>
+ </li>
+ </ul>
+ </div>
+ <button id="delete-database" class="btn"><i class="icon-trash"></i> Database</button>
+ </div>
+ </header>
+
+ <nav>
+ <ul class="nav nav-list">
+ <li class="active"><a id="all-docs" href="#<%= database.url('index') %>?limit=<%= docLimit %>" class="toggle-view"> All documents</a></li>
+ <li><a id="design-docs" href='#<%= database.url("index") %>?limit=<%= docLimit %>&startkey="_design"&endkey="_e"' class="toggle-view"> All design docs</a></li>
+ </ul>
+ <ul class="nav nav-list views">
+ <li class="nav-header">Secondary Indexes</li>
+ <li><a id="new-view" href="#<%= database.url('app') %>/new_view" class="new"><i class="icon-plus"></i> New</a></li>
+ </ul>
+ <div id="extension-navs"></div>
+ </nav>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/tabs.html b/src/fauxton/app/addons/documents/templates/tabs.html
new file mode 100644
index 0000000..f8b0c4b
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/tabs.html
@@ -0,0 +1,18 @@
+<!--
+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.
+-->
+
+<ul class="nav nav-tabs">
+ <li class="active"><a href="<%= db_url %>">Docs</a></li>
+ <li id="changes"><a href="<%= changes_url %>">Changes</a></li>
+</ul>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/upload_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/upload_modal.html b/src/fauxton/app/addons/documents/templates/upload_modal.html
new file mode 100644
index 0000000..9a5c5cd
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/upload_modal.html
@@ -0,0 +1,42 @@
+<!--
+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="modal hide fade">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3>Upload an Attachment</h3>
+ </div>
+ <div class="modal-body">
+ <div id="modal-error" class="alert alert-error hide" style="font-size: 16px;"> </div>
+ <form id="file-upload" class="form" method="post">
+ <p class="help-block">
+ Please select the file you want to upload as an attachment to this document.
+ Please note that this will result in the immediate creation of a new revision of the document,
+ so it's not necessary to save the document after the upload.
+ </p>
+ <input id="_attachments" type="file" name="_attachments">
+ <input id="_rev" type="hidden" name="_rev" value="" >
+ <br/>
+ </form>
+
+ <div class="progress progress-info">
+ <div class="bar" style="width: 0%"></div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <a href="#" data-dismiss="modal" data-bypass="true" class="btn button cancel-button outlineGray fonticon-circle-x">Cancel</a>
+ <a href="#" id="upload-btn" data-bypass="true" class="btn btn-primary button green save fonticon-circle-check">Upload</a>
+ </div>
+</div>
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/templates/view_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/view_editor.html b/src/fauxton/app/addons/documents/templates/view_editor.html
new file mode 100644
index 0000000..ddb5a0c
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/view_editor.html
@@ -0,0 +1,87 @@
+<!--
+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">
+ <ul class="nav nav-tabs" id="db-views-tabs-nav">
+ <li class="active"> <a data-bypass="true" id="index-nav" class="fonticon-wrench fonticon" data-toggle="tab" href="#index"><% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
+ <% if (!newView) { %>
+ <li><a data-bypass="true" id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
+ <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
+ <% } %>
+ </ul>
+ <div class="all-docs-list errors-container"></div>
+ <div class="tab-content">
+ <div class="tab-pane active" id="index">
+ <div id="define-view" class="ddoc-alert well">
+ <div class="errors-container"></div>
+ <form class="form-horizontal view-query-save">
+
+ <div class="control-group design-doc-group">
+ </div>
+
+ <div class="control-group">
+ <label for="index-name">Index name <a href="<%=getDocUrl('view_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
+ <input type="text" id="index-name" value="<%= viewName %>" placeholder="Index name" />
+ </div>
+
+
+ <div class="control-group">
+ <label for="map-function">Map function <a href="<%=getDocUrl('map_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
+ <% if (newView) { %>
+ <div class="js-editor" id="map-function"><%= langTemplates.map %></div>
+ <% } else { %>
+ <div class="js-editor" id="map-function"><%- ddoc.get('views')[viewName].map %></div>
+ <% } %>
+ </div>
+
+
+ <div class="control-group">
+ <label for="reduce-function-selector">Reduce (optional) <a href="<%=getDocUrl('reduce_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
+
+ <select id="reduce-function-selector">
+ <option value="" <%= !reduceFunStr ? 'selected="selected"' : '' %>>None</option>
+ <% _.each(["_sum", "_count", "_stats"], function(reduce) { %>
+ <option value="<%= reduce %>" <% if (reduce == reduceFunStr) { %>selected<% } %>><%= reduce %></option>
+ <% }) %>
+ <option value="CUSTOM" <% if (isCustomReduce) { %>selected<% } %>>Custom Reduce function</option>
+ </select>
+ </div>
+
+ <div class="control-group reduce-function">
+ <label for="reduce-function">Custom Reduce function</label>
+ <% if (newView) { %>
+ <div class="js-editor" id="reduce-function"><%= langTemplates.reduce %></div>
+ <% } else { %>
+ <div class="js-editor" id="reduce-function"><%- ddoc.get('views')[viewName].reduce %></div>
+ <% } %>
+ </div>
+
+ <div class="control-group">
+ <button class="button green save fonticon-circle-check">Save & Build Index</button>
+ <button class="button btn-info preview">Preview</button>
+ <% if (!newView) { %>
+ <button class="button delete outlineGray fonticon-circle-x">Delete</button>
+ <% } %>
+ </div>
+ <div class="clearfix"></div>
+ </form>
+ </div>
+ </div>
+ <div class="tab-pane" id="metadata">
+ <div id="ddoc-info" class="well"> </div>
+ </div>
+ <div class="tab-pane" id="query">
+ </div>
+ </div>
+</div>
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/tests/resourcesSpec.js b/src/fauxton/app/addons/documents/tests/resourcesSpec.js
new file mode 100644
index 0000000..380a4e4
--- /dev/null
+++ b/src/fauxton/app/addons/documents/tests/resourcesSpec.js
@@ -0,0 +1,84 @@
+// 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([
+ 'addons/documents/resources',
+ 'testUtils'
+], function (Models, testUtils) {
+ var assert = testUtils.assert;
+
+ describe('IndexCollection', function () {
+ var collection;
+ beforeEach(function () {
+ collection = new Models.IndexCollection([{
+ id:'myId1',
+ doc: 'num1'
+ },
+ {
+ id:'myId2',
+ doc: 'num2'
+ }], {
+ database: {id: 'databaseId', safeID: function () { return this.id; }},
+ design: '_design/myDoc'
+ });
+
+ });
+
+ it('Should return urlNext', function () {
+ var url = collection.urlNextPage(20);
+
+ assert.equal(url, 'database/databaseId/_design/myDoc/_view/?limit=21&reduce=false&startkey_docid=myId2&startkey=');
+
+ });
+
+ it('Should return urlPrevious', function () {
+ var url = collection.urlPreviousPage(20, {limit: 21, reduce: false, startkey_docid: "myId1",startkey:"myId1"} );
+
+ assert.equal(url, 'database/databaseId/_design/myDoc/_view/?limit=20&reduce=false&startkey_docid=myId1&startkey=myId1');
+
+ });
+
+ });
+
+ describe('AllDocs', function () {
+ var collection;
+ beforeEach(function () {
+ collection = new Models.AllDocs([{
+ _id:'myId1',
+ doc: 'num1'
+ },
+ {
+ _id:'myId2',
+ doc: 'num2'
+ }], {
+ database: {id: 'databaseId', safeID: function () { return this.id; }},
+ params: {limit: 20}
+ });
+
+ });
+
+ it('Should return urlNext', function () {
+ var url = collection.urlNextPage(20);
+
+ assert.equal(url, 'database/databaseId/_all_docs?limit=21&startkey_docid=%22myId2%22&startkey=%22myId2%22');
+
+ });
+
+ it('Should return urlPrevious', function () {
+ var url = collection.urlPreviousPage(20, {limit: 21, startkey_docid: "myId1",startkey:"myId1"} );
+ assert.equal(url, 'database/databaseId/_all_docs?limit=20&startkey_docid=myId1&startkey=myId1');
+ });
+
+
+ });
+
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/89810cce/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
new file mode 100644
index 0000000..97d58e3
--- /dev/null
+++ b/src/fauxton/app/addons/documents/views.js
@@ -0,0 +1,1855 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+
+ "api",
+ "addons/fauxton/components",
+
+ "addons/documents/resources",
+ "addons/databases/resources",
+ "addons/pouchdb/base",
+
+ // Libs
+ "resizeColumns",
+
+ // Plugins
+ "plugins/prettify"
+
+],
+
+function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns) {
+ 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=' + Databases.DocLimit,
+ };
+ },
+
+ 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; }
+ FauxtonAPI.addNotification({
+ msg: "Deleting your database...",
+ type: "error"
+ });
+ return this.database.destroy().done(function () {
+ app.router.navigate('#/_all_dbs', {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",
+
+ disableLoader: true,
+
+ initialize: function (options) {
+ _.bindAll(this);
+ },
+
+ events: {
+ "click a#upload-btn": "uploadFile"
+ },
+
+ uploadFile: function (event) {
+ event.preventDefault();
+
+ var docRev = this.model.get('_rev'),
+ that = this,
+ $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 (resp) {
+ console.log('ERR on upload', resp);
+ return that.set_error_msg('Could not upload document: ' + JSON.parse(resp.responseText).reason);
+ }
+ });
+ },
+
+ 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();
+ $('.modal-backdrop').remove();
+ }, 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(),
+ encodedID = app.mixins.safeURLName(newId);
+
+ this.hideModal();
+ FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID);
+ },
+
+ _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: {
+ },
+ 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",
+ "dblclick pre.prettyprint": "edit"
+ },
+
+ attributes: function() {
+ return {
+ "data-id": this.model.id
+ };
+ },
+
+ serialize: function() {
+ return {
+ doc: this.model
+ };
+ },
+
+ establish: function() {
+ return [this.model.fetch()];
+ },
+
+ edit: function(event) {
+ event.preventDefault();
+ FauxtonAPI.navigate("#" + this.model.url('app'));
+ },
+
+ 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(function () {
+ that.remove();
+ });
+
+ that.model.collection.remove(that.model.id);
+ if (!!that.model.id.match('_design')) {
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
+ }
+ }, 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",
+
+ events: {
+ "click button.delete": "destroy"
+ },
+
+ destroy: function (event) {
+ event.preventDefault();
+
+ window.alert('Cannot delete a document generated from a view.');
+ },
+
+ 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,
+ index_clean: app.mixins.removeSpecialCharacters(this.index),
+ ddoc_clean: app.mixins.removeSpecialCharacters(this.ddoc),
+ index_encoded: app.mixins.safeURLName(this.index),
+ ddoc_encoded: app.mixins.safeURLName(this.ddoc),
+ database_encoded: app.mixins.safeURLName(this.database),
+ selected: this.selected
+ };
+ },
+
+ afterRender: function() {
+ if (this.selected) {
+ $("#sidenav ul.nav-list li").removeClass("active");
+ this.$el.addClass("active");
+ }
+ }
+ });
+
+ Views.AllDocsNumber = FauxtonAPI.View.extend({
+ template: "templates/documents/all_docs_number",
+
+ initialize: function (options) {
+ this.newView = options.newView || false;
+ this.showNumbers = options.showNumbers;
+ this.pagination = options.pagination;
+
+ this.listenTo(this.collection, 'totalRows:decrement', this.render);
+ },
+
+ serialize: function () {
+ var totalRows = 0,
+ recordStart = 0,
+ updateSeq = false,
+ pageStart = 0,
+ pageEnd = 20;
+
+ if (!this.newView) {
+ totalRows = this.collection.totalRows();
+ updateSeq = this.collection.updateSeq();
+ }
+
+ recordStart = this.collection.recordStart();
+ if (this.pagination) {
+ pageStart = this.pagination.pageStart();
+ pageEnd = this.pagination.pageEnd();
+ }
+
+ return {
+ database: app.mixins.safeURLName(this.collection.database.id),
+ updateSeq: updateSeq,
+ offset: recordStart,
+ totalRows: totalRows,
+ showNumbers: this.showNumbers,
+ numModels: this.collection.models.length + recordStart - 1,
+ pageStart: pageStart,
+ pageEnd: pageEnd
+ };
+ }
+
+ });
+
+ Views.AllDocsLayout = FauxtonAPI.View.extend({
+ template: "templates/documents/all_docs_layout",
+ className: "row",
+
+ initialize: function (options) {
+ this.database = options.database;
+ this.params = options.params;
+ },
+
+ events: {
+ 'click #toggle-query': "toggleQuery"
+ },
+
+ toggleQuery: function (event) {
+ $('#dashboard-content').scrollTop(0);
+ this.$('#query').toggle('fast');
+ },
+
+ beforeRender: function () {
+ this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
+ updateViewFn: this.updateAllDocs,
+ previewFn: this.previewView,
+ hasReduce: false,
+ showPreview: false,
+ database: this.database
+ }));
+
+ this.$('#query').hide();
+ },
+
+ afterRender: function () {
+ if (this.params) {
+ this.advancedOptions.updateFromParams(this.params);
+ }
+
+ },
+
+ updateAllDocs: function (event, paramInfo) {
+ event.preventDefault();
+
+ var 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: ".advanced-options .errors-container"
+ });
+ });
+ FauxtonAPI.addNotification({
+ msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
+ type: "warning",
+ selector: ".advanced-options .errors-container"
+ });
+
+ return false;
+ }
+
+ var fragment = window.location.hash.replace(/\?.*$/, '');
+ fragment = fragment + '?' + $.param(params);
+ FauxtonAPI.navigate(fragment, {trigger: false});
+
+ FauxtonAPI.triggerRouteEvent('updateAllDocs', {allDocs: true});
+ },
+
+ previewView: function (event) {
+ event.preventDefault();
+ }
+
+ });
+
+ // 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",
+ "click #collapse": "collapse",
+ "change .row-select":"toggleTrash"
+ },
+
+ toggleTrash: function () {
+ if (this.$('.row-select:checked').length > 0) {
+ this.$('.bulk-delete').removeClass('disabled');
+ } else {
+ this.$('.bulk-delete').addClass('disabled');
+ }
+ },
+
+ 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;
+ this.expandDocs = true;
+ },
+
+ establish: function() {
+ if (this.newView) { return null; }
+
+ return this.collection.fetch({reset: true}).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){
+ $('.all-docs').find("input:checkbox").prop('checked', !$(evt.target).hasClass('active')).trigger('change');
+ },
+
+ serialize: function() {
+ var requestDuration = false;
+
+ if (this.collection.requestDurationInString) {
+ requestDuration = this.collection.requestDurationInString();
+ }
+
+ return {
+ viewList: this.viewList,
+ requestDuration: requestDuration,
+ expandDocs: this.expandDocs
+ };
+ },
+
+ collapse: function (event) {
+ event.preventDefault();
+
+ if (this.expandDocs) {
+ this.expandDocs = false;
+ } else {
+ this.expandDocs = true;
+ }
+
+ this.render();
+ },
+
+ /*
+ * 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 (eles.length === 0 || !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(function () {
+ $(this).remove();
+ });
+
+ model.collection.remove(model.id);
+ if (!!model.id.match('_design')) {
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
+ }
+ that.$('.bulk-delete').addClass('disabled');
+ }, function(resp) {
+ FauxtonAPI.addNotification({
+ msg: "Failed to destroy your doc!",
+ type: "error"
+ });
+ });
+ }, this);
+ },
+
+ addPagination: function () {
+ var collection = this.collection;
+ var perPage = function () {
+ if (collection.params.limit && collection.skipFirstItem) {
+ return parseInt(collection.params.limit, 10) - 1;
+ } else if (collection.params.limit) {
+ return parseInt(collection.params.limit, 10);
+ }
+
+ return 20;
+ };
+
+ this.pagination = new Components.IndexPagination({
+ collection: this.collection,
+ scrollToSelector: '#dashboard-content',
+ previousUrlfn: function () {
+ return collection.urlPreviousPage(perPage(), this.previousParams.pop());
+ },
+ canShowPreviousfn: function () {
+ if (this.previousParams.length === 0) {
+ return false;
+ }
+
+ return true;
+ },
+ canShowNextfn: function () {
+ if (collection.length < (perPage() -1)) {
+ return false;
+ }
+
+ return true;
+ },
+
+ nextUrlfn: function () {
+ return collection.urlNextPage(perPage());
+ }
+ });
+ },
+
+ cleanup: function () {
+ //if (!this.pagination) { return; }
+ this.pagination.remove();
+ //this.pagination = null;
+ this.allDocsNumber.remove();
+ _.each(this.rows, function (row) {row.remove();});
+ },
+
+ beforeRender: function() {
+ var showNumbers = true;
+
+ if (!this.pagination) {
+ this.addPagination();
+ }
+
+ this.insertView('#documents-pagination', this.pagination);
+
+ if (this.designDocs || this.collection.idxType === '_view' || this.collection.params.startkey === '"_design"') {
+ showNumbers = false;
+ }
+
+ this.allDocsNumber = this.setView('#item-numbers', new Views.AllDocsNumber({
+ collection: this.collection,
+ newView: this.newView,
+ showNumbers: showNumbers,
+ pagination: this.pagination
+ }));
+
+ var docs = this.expandDocs ? this.collection : this.collection.simple();
+
+ docs.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",
+ "click button.delete": "destroy",
+ "click button.duplicate": "duplicate",
+ "click button.upload": "upload",
+ "click button.cancel-button": "goback"
+ },
+ disableLoader: true,
+ initialize: function (options) {
+ this.database = options.database;
+ _.bindAll(this);
+ },
+ goback: function(){
+ FauxtonAPI.navigate(this.database.url("index") + "?limit=100");
+ },
+ destroy: function(event) {
+ if (this.model.isNewDoc()) {
+ FauxtonAPI.addNotification({
+ msg: 'This document has not been saved yet.',
+ type: 'warning'
+ });
+ return;
+ }
+
+ 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) {
+ if (this.model.isNewDoc()) {
+ FauxtonAPI.addNotification({
+ msg: 'Please save the document before duplicating it.',
+ type: 'warning'
+ });
+ return;
+ }
+ event.preventDefault();
+ this.duplicateModal.showModal();
+ },
+
+ 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() {
+ var promise = this.model.fetch(),
+ databaseId = this.database.safeID(),
+ deferred = $.Deferred(),
+ that = this;
+
+ promise.then(function () {
+ deferred.resolve();
+ }, function (xhr, reason, msg) {
+ if (xhr.status === 404) {
+ FauxtonAPI.addNotification({
+ msg: 'The document does not exist',
+ type: 'error',
+ clear: true
+ });
+ that.goback();
+ }
+ deferred.reject();
+ });
+
+ return deferred;
+ },
+
+ saveDoc: function(event) {
+ var json, notification,
+ that = this,
+ editor = this.editor,
+ validDoc = this.getDocFromEditor();
+
+ if (validDoc) {
+ this.getDocFromEditor();
+
+ notification = FauxtonAPI.addNotification({msg: "Saving document."});
+
+ this.model.save().then(function () {
+ editor.editSaved();
+ FauxtonAPI.navigate('/database/' + that.database.safeID() + '/' + that.model.id);
+ }).fail(function(xhr) {
+
+ var responseText = JSON.parse(xhr.responseText).reason;
+ notification = FauxtonAPI.addNotification({
+ msg: "Save failed: " + responseText,
+ type: "error",
+ clear: true,
+ selector: "#doc .errors-container"
+ });
+ });
+ } else if(this.model.validationError && this.model.validationError === 'Cannot change a documents id.') {
+ notification = FauxtonAPI.addNotification({
+ msg: "Cannot save: " + 'Cannot change a documents _id, try Duplicate doc instead!',
+ type: "error",
+ selector: "#doc .errors-container"
+ });
+ delete this.model.validationError;
+ } 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().set(json, {validate: true});
+ if (this.model.validationError) {
+ return false;
+ }
+
+ return this.model;
+ },
+
+ hasValidCode: function() {
+ var errors = this.editor.getAnnotations();
+ return errors.length === 0;
+ },
+
+ 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() {
+ var saveDoc = this.saveDoc;
+
+ this.editor = new Components.Editor({
+ editorId: "editor-container",
+ commands: [{
+ name: 'save',
+ bindKey: {win: 'Ctrl-S', mac: 'Ctrl-S'},
+ exec: function(editor) {
+ saveDoc();
+ },
+ readOnly: true // false if this command should not apply in readOnly mode
+ }]
+ });
+ this.editor.render();
+ this.model.on("sync", this.updateValues, this);
+ },
+
+ cleanup: function () {
+ if (this.editor) this.editor.remove();
+ }
+ });
+
+ Views.DocFieldEditor = FauxtonAPI.View.extend({
+ template: "templates/documents/doc_field_editor",
+ disableLoader: true,
+ 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()];
+ }
+ });
+
+ Views.AdvancedOptions = FauxtonAPI.View.extend({
+ template: "templates/documents/advanced_options",
+ className: "advanced-options well",
+
+ initialize: function (options) {
+ this.database = options.database;
+ this.ddocName = options.ddocName;
+ this.viewName = options.viewName;
+ this.updateViewFn = options.updateViewFn;
+ this.previewFn = options.previewFn;
+ //this.hadReduce = options.hasReduce || true;
+
+ if (typeof(options.hasReduce) === 'undefined') {
+ this.hasReduce = true;
+ } else {
+ this.hasReduce = options.hasReduce;
+ }
+
+ if (typeof(options.showPreview) === 'undefined') {
+ this.showPreview = true;
+ } else {
+ this.showPreview = options.showPreview;
+ }
+ },
+
+ events: {
+ "change form.view-query-update input": "updateFilters",
+ "change form.view-query-update select": "updateFilters",
+ "submit form.view-query-update": "updateView",
+ "click button.preview": "previewView"
+ },
+
+ beforeRender: function () {
+ if (this.viewName && this.ddocName) {
+ var buttonViews = FauxtonAPI.getExtensions('advancedOptions:ViewButton');
+ _.each(buttonViews, function (view) {
+ this.insertView('#button-options', view);
+ view.update(this.database, this.ddocName, this.viewName);
+ }, this);
+ }
+ },
+
+ renderOnUpdatehasReduce: function (hasReduce) {
+ this.hasReduce = hasReduce;
+ this.render();
+ },
+
+ queryParams: function () {
+ var $form = this.$(".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};
+ },
+
+ 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;
+ }
+ },
+
+ updateFromParams: function (params) {
+ var $form = this.$el.find("form.view-query-update");
+ _.each(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);
+ },
+
+ updateView: function (event) {
+ this.updateViewFn(event, this.queryParams());
+ },
+
+ previewView: function (event) {
+ this.previewFn(event, this.queryParams());
+ },
+
+ serialize: function () {
+ return {
+ hasReduce: this.hasReduce,
+ showPreview: this.showPreview
+ };
+ }
+ });
+
+ Views.DesignDocSelector = FauxtonAPI.View.extend({
+ template: "templates/documents/design_doc_selector",
+
+ events: {
+ "change select#ddoc": "updateDesignDoc"
+ },
+
+ initialize: function (options) {
+ this.ddocName = options.ddocName;
+ this.database = options.database;
+ this.listenTo(this.collection, 'add', this.ddocAdded);
+ this.DocModel = options.DocModel || Documents.Doc;
+ },
+
+ ddocAdded: function (ddoc) {
+ this.ddocName = ddoc.id;
+ this.render();
+ },
+
+ serialize: function () {
+ return {
+ ddocName: this.ddocName,
+ ddocs: this.collection
+ };
+ },
+
+ updateDesignDoc: function () {
+ if (this.newDesignDoc()) {
+ this.$('#new-ddoc-section').show();
+ } else {
+ this.$('#new-ddoc-section').hide();
+ }
+ },
+
+ newDesignDoc: function () {
+
+ return this.$('#ddoc').val() === 'new-doc';
+ },
+
+ newDocValidation: function(){
+ return this.newDesignDoc() && this.$('#new-ddoc').val()==="";
+ },
+ getCurrentDesignDoc: function () {
+ if (this.newDesignDoc()) {
+ var doc = {
+ _id: '_design/' + this.$('#new-ddoc').val(),
+ views: {},
+ language: "javascript"
+ };
+ var ddoc = new this.DocModel(doc, {database: this.database});
+ //this.collection.add(ddoc);
+ return ddoc;
+ } else if ( !this.newDesignDoc() ) {
+ var ddocName = this.$('#ddoc').val();
+ return this.collection.find(function (ddoc) {
+ return ddoc.id === ddocName;
+ }).dDocModel();
+ }
+ }
+ });
+
+ Views.ViewEditor = FauxtonAPI.View.extend({
+ template: "templates/documents/view_editor",
+ builtinReduces: ['_sum', '_count', '_stats'],
+
+ events: {
+ "click button.save": "saveView",
+ "click button.delete": "deleteView",
+ "change select#reduce-function-selector": "updateReduce",
+ "click button.preview": "previewView",
+ "click #db-views-tabs-nav": 'toggleIndexNav'
+ },
+
+ 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});
+ }
+
+ this.showIndex = false;
+ _.bindAll(this);
+ },
+
+ establish: function () {
+ if (this.ddocInfo) {
+ return this.ddocInfo.fetch();
+ }
+ },
+
+ 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") {
+ this.createReduceEditor();
+ this.reduceEditor.setValue(this.langTemplates.javascript.reduce);
+ $reduceContainer.show();
+ } else {
+ $reduceContainer.hide();
+ }
+ },
+
+ 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.safeID() + '/_all_docs?limit=' + Databases.DocLimit);
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
+ });
+ },
+
+ saveView: function(event) {
+ var json, notification,
+ that = this;
+
+ if (event) { event.preventDefault();}
+
+ $('#dashboard-content').scrollTop(0); //scroll up
+
+ if (this.hasValidCode() && this.$('#new-ddoc:visible').val() !=="") {
+ 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",
+ clear: true
+ });
+
+ ddoc.setDdocView(viewName, mapVal, reduceVal);
+
+ ddoc.save().then(function () {
+ that.ddocs.add(ddoc);
+
+ that.mapEditor.editSaved();
+ that.reduceEditor && that.reduceEditor.editSaved();
+
+ FauxtonAPI.addNotification({
+ msg: "View has been saved.",
+ type: "success",
+ selector: "#define-view .errors-container",
+ clear: true
+ });
+
+ if (that.newView) {
+ var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.mixins.safeURLName(viewName);
+
+ FauxtonAPI.navigate(fragment, {trigger: false});
+ that.newView = false;
+ that.ddocID = ddoc.safeID();
+ that.viewName = viewName;
+ that.ddocInfo = ddoc;
+ that.showIndex = true;
+ that.render();
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs', {
+ selectedTab: app.mixins.removeSpecialCharacters(ddocName.replace(/_design\//,'')) + '_' + app.mixins.removeSpecialCharacters(viewName)
+ });
+ }
+
+ if (that.reduceFunStr !== reduceVal) {
+ that.reduceFunStr = reduceVal;
+ that.advancedOptions.renderOnUpdatehasReduce(that.hasReduce());
+ }
+
+ 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 {
+ var errormessage = (this.$('#new-ddoc:visible').val() ==="")?"Enter a design doc name":"Please fix the Javascript errors and try again.";
+ notification = FauxtonAPI.addNotification({
+ msg: errormessage,
+ type: "error",
+ selector: "#define-view .errors-container",
+ clear: true
+ });
+ }
+ },
+
+ updateView: function(event, paramInfo) {
+ event.preventDefault();
+
+ if (this.newView) { return alert('Please save this new view before querying it.'); }
+
+ var 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: ".advanced-options .errors-container",
+ clear: true
+ });
+ });
+ FauxtonAPI.addNotification({
+ msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
+ type: "warning",
+ selector: ".advanced-options .errors-container",
+ clear: true
+ });
+
+ 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});
+ },
+
+
+ previewView: function(event, paramsInfo) {
+ event.preventDefault();
+ var that = this,
+ mapVal = this.mapVal(),
+ reduceVal = this.reduceVal(),
+ paramsArr = [];
+
+ if (paramsInfo && paramsInfo.params) {
+ paramsArr = paramsInfo.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: ".advanced-options .errors-container",
+ fade: true
+ });
+
+ var promise = FauxtonAPI.Deferred();
+
+ if (!this.database.allDocs) {
+ this.database.buildAllDocs({limit: Databases.DocLimit.toString(), 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});
+ });
+ });
+ },
+
+ getCurrentDesignDoc: function () {
+ return this.designDocSelector.getCurrentDesignDoc();
+ },
+
+ isCustomReduceEnabled: function() {
+ return $("#reduce-function-selector").val() == "CUSTOM";
+ },
+
+ mapVal: function () {
+ if (this.mapEditor) {
+ return this.mapEditor.getValue();
+ }
+
+ return this.$('#map-function').text();
+ },
+
+ 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;
+ }
+ return editor.hadValidCode();
+ }, this);
+ },
+
+ toggleIndexNav: function (event) {
+ var $targetId = this.$(event.target).attr('id'),
+ $previousTab = this.$(this.$('li.active a').attr('href')),
+ $targetTab = this.$(this.$(event.target).attr('href'));
+
+ if ($targetTab.attr('id') !== $previousTab.attr('id')) {
+ $previousTab.removeAttr('style');
+ }
+
+ if ($targetId === 'index-nav') {
+ if (this.newView) { return; }
+ var that = this;
+ $('#dashboard-content').scrollTop(0); //scroll up
+ $targetTab.toggle('slow', function(){
+ that.showEditors();
+ });
+ } else {
+ $targetTab.toggle('slow');
+ }
+ },
+
+ serialize: function() {
+ return {
+ ddocs: this.ddocs,
+ ddoc: this.model,
+ ddocName: this.model.id,
+ viewName: this.viewName,
+ reduceFunStr: this.reduceFunStr,
+ isCustomReduce: this.hasCustomReduce(),
+ newView: this.newView,
+ langTemplates: this.langTemplates.javascript
+ };
+ },
+
+ hasCustomReduce: function() {
+ return this.reduceFunStr && ! _.contains(this.builtinReduces, this.reduceFunStr);
+ },
+
+ hasReduce: function () {
+ return this.reduceFunStr || false;
+ },
+
+ createReduceEditor: function () {
+ if (this.reduceEditor) {
+ this.reduceEditor.remove();
+ }
+
+ this.reduceEditor = new Components.Editor({
+ editorId: "reduce-function",
+ mode: "javascript",
+ couchJSHINT: true
+ });
+ this.reduceEditor.render();
+ },
+
+ 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 {
+ var ddocDecode = decodeURIComponent(this.ddocID);
+ this.model = this.ddocs.get(ddocDecode).dDocModel();
+ this.reduceFunStr = this.model.viewHasReduce(this.viewName);
+ this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
+ }
+
+ this.designDocSelector = this.setView('.design-doc-group', new Views.DesignDocSelector({
+ collection: this.ddocs,
+ ddocName: this.model.id,
+ database: this.database
+ }));
+
+ this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
+ updateViewFn: this.updateView,
+ previewFn: this.previewView,
+ database: this.database,
+ viewName: this.viewName,
+ ddocName: this.model.id,
+ hasReduce: this.hasReduce()
+ }));
+ },
+
+ afterRender: function() {
+ if (this.params) {
+ this.advancedOptions.updateFromParams(this.params);
+ }
+
+ this.designDocSelector.updateDesignDoc();
+ if (this.newView || this.showIndex) {
+ this.showEditors();
+ this.showIndex = false;
+ } else {
+ this.$('#index').hide();
+ this.$('#index-nav').parent().removeClass('active');
+ }
+ },
+
+ showEditors: function () {
+ this.mapEditor = new Components.Editor({
+ editorId: "map-function",
+ mode: "javascript",
+ couchJSHINT: true
+ });
+ this.mapEditor.render();
+
+ if (this.hasCustomReduce()) {
+ this.createReduceEditor();
+ } else {
+ $(".control-group.reduce-function").hide();
+ }
+
+ if (this.newView) {
+ this.mapEditor.setValue(this.langTemplates[this.defaultLang].map);
+ //Use a built in view by default
+ //this.reduceEditor.setValue(this.langTemplates[this.defaultLang].reduce);
+ }
+
+ this.mapEditor.editSaved();
+ this.reduceEditor && this.reduceEditor.editSaved();
+ },
+
+ cleanup: function () {
+ this.mapEditor && this.mapEditor.remove();
+ this.reduceEditor && this.reduceEditor.remove();
+ }
+ });
+
+ Views.JumpToDoc = FauxtonAPI.View.extend({
+ template: "templates/documents/jumpdoc",
+
+ initialize: function (options) {
+ this.database = options.database;
+ },
+
+ events: {
+ "submit #jump-to-doc": "jumpToDoc"
+ },
+
+ jumpToDoc: function (event) {
+ event.preventDefault();
+ var docId = this.$('#jump-to-doc-id').val().trim();
+ FauxtonAPI.navigate('/database/' + app.mixins.safeURLName(this.database.id) +'/' + app.mixins.safeURLName(docId), {trigger: true});
+ },
+
+ afterRender: function () {
+ this.typeAhead = new Components.DocSearchTypeahead({el: '#jump-to-doc-id', database: this.database});
+ this.typeAhead.render();
+ }
+ });
+
+ Views.Sidebar = FauxtonAPI.View.extend({
+ template: "templates/documents/sidebar",
+ events: {
+ "click button#delete-database": "deleteDatabase"
+ },
+
+ initialize: function(options) {
+ this.database = options.database;
+ if (options.ddocInfo) {
+ this.ddocID = options.ddocInfo.id;
+ this.currView = options.ddocInfo.currView;
+ }
+ },
+
+ deleteDatabase: function (event) {
+ event.preventDefault();
+
+ var result = confirm('Are you sure you want to delete this database?');
+
+ if (!result) { return; }
+ var databaseName = this.database.id;
+ FauxtonAPI.addNotification({
+ msg: "Deleting your database...",
+ type: "error",
+ clear: true
+ });
+
+ this.database.destroy().then(function () {
+ FauxtonAPI.navigate('#/_all_dbs');
+ FauxtonAPI.addNotification({
+ msg: 'The database ' + databaseName + ' has been deleted.',
+ clear: true
+ });
+ }).fail(function (rsp, error, msg) {
+ FauxtonAPI.addNotification({
+ msg: 'Could not delete the database, reason ' + msg + '.',
+ type: 'error',
+ clear: true
+ });
+ });
+ },
+
+ serialize: function() {
+ var docLinks = FauxtonAPI.getExtensions('docLinks'),
+ newLinks = FauxtonAPI.getExtensions('sidebar:newLinks'),
+ addLinks = FauxtonAPI.getExtensions('sidebar:links'),
+ extensionList = FauxtonAPI.getExtensions('sidebar:list');
+ return {
+ changes_url: '#' + this.database.url('changes'),
+ permissions_url: '#' + this.database.url('app') + '/permissions',
+ db_url: '#' + this.database.url('index') + '?limit=' + Databases.DocLimit,
+ database: this.collection.database,
+ database_url: '#' + this.database.url('app'),
+ docLinks: docLinks,
+ docLimit: Databases.DocLimit,
+ addLinks: addLinks,
+ newLinks: newLinks,
+ extensionList: extensionList > 0
+ };
+ },
+
+ 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) {
+
+ var sidebarListViews = FauxtonAPI.getExtensions('sidebar:list');
+ _.each(sidebarListViews, function (view) {
+ var extension = this.insertView('#extension-navs', view);
+ extension.update(this.database, this.collection, this.viewName);
+ extension.render();
+ }, this);
+
+
+ this.collection.each(function(design) {
+ if (design.has('doc')){
+ var ddoc = design.id.replace(/^_design\//,"");
+ 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/89810cce/src/fauxton/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js
new file mode 100644
index 0000000..aa4c3d4
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/base.js
@@ -0,0 +1,271 @@
+// 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",
+ "resizeColumns",
+],
+
+function(app, Backbone, resizeColumns) {
+
+
+ //resizeAnimation
+ app.resizeColumns = new resizeColumns({});
+ app.resizeColumns.onResizeHandler();
+
+ var Fauxton = {};
+
+ 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({
+ className:"navbar",
+ template: "templates/fauxton/nav_bar",
+ // TODO: can we generate this list from the router?
+ navLinks: [
+ {href:"#/_all_dbs", title:"Databases", icon: "fonticon-database", className: 'databases'}
+ ],
+
+ bottomNavLinks: [],
+ footerNavLinks: [],
+
+ serialize: function() {
+ return {
+ navLinks: this.navLinks,
+ bottomNavLinks: this.bottomNavLinks,
+ footerNavLinks: this.footerNavLinks
+ };
+ },
+
+ addLink: function(link) {
+ // link.top means it gets pushed to the top of the array,
+ // link.bottomNav means it goes to the additional bottom nav
+ // link.footerNav means goes to the footer nav
+ if (link.top && !link.bottomNav){
+ this.navLinks.unshift(link);
+ } else if (link.top && link.bottomNav){
+ this.bottomNavLinks.unshift(link);
+ } else if (link.bottomNav) {
+ this.bottomNavLinks.push(link);
+ } else if (link.footerNav) {
+ this.footerNavLinks.push(link);
+ } else {
+ this.navLinks.push(link);
+ }
+ },
+
+ removeLink: function (removeLink) {
+ var links = this.navlinks;
+
+ if (removeLink.bottomNav) {
+ links = this.bottomNavLinks;
+ } else if (removeLink.footerNav) {
+ links = this.footerNavLinks;
+ }
+
+ var foundIndex = -1;
+
+ _.each(links, function (link, index) {
+ if (link.title === removeLink.title) {
+ foundIndex = index;
+ }
+ });
+
+ if (foundIndex === -1) {return;}
+ links.splice(foundIndex, 1);
+ this.render();
+ },
+
+ afterRender: function(){
+
+ $('#primary-navbar li[data-nav-name="' + app.selectedHeader + '"]').addClass('active');
+
+ var menuOpen = true;
+ var $selectorList = $('body');
+ $('.brand').off();
+ $('.brand').on({
+ click: function(e){
+ if(!$(e.target).is('a')){
+ toggleMenu();
+ }
+ }
+ });
+
+ function toggleMenu(){
+ $selectorList.toggleClass('closeMenu');
+ menuOpen = $selectorList.hasClass('closeMenu');
+ app.resizeColumns.onResizeHandler();
+ }
+
+ $('#primary-navbar').on("click", ".nav a", function(){
+ if (!($selectorList.hasClass('closeMenu'))){
+ setTimeout(
+ function(){
+ $selectorList.addClass('closeMenu');
+ app.resizeColumns.onResizeHandler();
+ },3000);
+
+ }
+ });
+
+ app.resizeColumns.initialize();
+ },
+
+ beforeRender: function () {
+ this.addLinkViews();
+ },
+
+ addLinkViews: function () {
+ var that = this;
+
+ _.each(_.union(this.navLinks, this.bottomNavLinks), function (link) {
+ if (!link.view) { return; }
+
+ //TODO check if establish is a function
+ var establish = link.establish || [];
+ $.when.apply(null, establish).then( function () {
+ var selector = link.bottomNav ? '#bottom-nav-links' : '#nav-links';
+ that.insertView(selector, link.view).render();
+ });
+ }, this);
+ }
+
+ // TODO: ADD ACTIVE CLASS
+ });
+
+ Fauxton.ApiBar = Backbone.View.extend({
+ template: "templates/fauxton/api_bar",
+ endpoint: '_all_docs',
+
+ documentation: 'docs',
+
+ events: {
+ "click .api-url-btn" : "toggleAPIbar"
+ },
+
+ toggleAPIbar: function(e){
+ var $currentTarget = $(e.currentTarget).find('span');
+ if ($currentTarget.hasClass("fonticon-plus")){
+ $currentTarget.removeClass("fonticon-plus").addClass("fonticon-minus");
+ }else{
+ $currentTarget.removeClass("fonticon-minus").addClass("fonticon-plus");
+ }
+
+ $('.api-navbar').toggle();
+
+ },
+
+ serialize: function() {
+ return {
+ endpoint: this.endpoint,
+ documentation: this.documentation
+ };
+ },
+
+ hide: function(){
+ this.$el.addClass('hide');
+ },
+ show: function(){
+ this.$el.removeClass('hide');
+ },
+ update: function(endpoint) {
+ this.show();
+ this.endpoint = endpoint[0];
+ this.documentation = endpoint[1];
+ 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().$el.appendTo(selector);
+ this.delayedFade();
+ return this;
+ }
+ });
+
+
+ return Fauxton;
+});
[35/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Testing and improvements
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/42c44932
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/42c44932
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/42c44932
Branch: refs/heads/api-options
Commit: 42c44932863d51758b849ac15e3d545e36039621
Parents: 392f7b3
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 14 11:49:35 2014 +0200
Committer: suelockwood <de...@apache.org>
Committed: Tue Jan 14 10:45:56 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/api.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/42c44932/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 6d450de..9ac895e 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -333,7 +333,7 @@ function(app, Fauxton) {
triggerBroadcast('beforeRender', view, selector);
var viewPromise = view.establish();
routeObject.addPromise(viewPromise);
- FauxtonAPI.when(view.establish()).then(function(resp) {
+ FauxtonAPI.when(viewPromise).then(function(resp) {
masterLayout.setView(selector, view);
masterLayout.renderView(selector);
[20/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Update makefiles for module to addon move
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4b69ff38
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4b69ff38
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4b69ff38
Branch: refs/heads/api-options
Commit: 4b69ff383f5af5f11d137c80c99dfa4442f2d516
Parents: 861f202
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Jan 13 11:26:25 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 13 11:26:25 2014 +0200
----------------------------------------------------------------------
src/Makefile.am | 94 ++++++++++++++++++++++++++--------------------------
1 file changed, 47 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/4b69ff38/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 12c4fe3..cb37384 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -112,52 +112,52 @@ FAUXTON_FILES = \
fauxton/app/initialize.js.underscore \
fauxton/app/load_addons.js.underscore \
fauxton/app/main.js \
- fauxton/app/mixins.js \
- fauxton/app/modules/databases/base.js \
- fauxton/app/modules/databases/resources.js \
- fauxton/app/modules/databases/routes.js \
- fauxton/app/modules/databases/views.js \
- fauxton/app/modules/documents/base.js \
- fauxton/app/modules/documents/resources.js \
- fauxton/app/modules/documents/routes.js \
- fauxton/app/modules/documents/tests/resourcesSpec.js \
- fauxton/app/modules/documents/views.js \
- fauxton/app/modules/fauxton/base.js \
- fauxton/app/modules/fauxton/components.js \
- fauxton/app/modules/fauxton/layout.js \
- fauxton/app/modules/pouchdb/base.js \
- fauxton/app/modules/pouchdb/pouch.collate.js \
- fauxton/app/modules/pouchdb/pouchdb.mapreduce.js \
+ fauxton/app/utils.js \
+ fauxton/app/addons/databases/base.js \
+ fauxton/app/addons/databases/resources.js \
+ fauxton/app/addons/databases/routes.js \
+ fauxton/app/addons/databases/views.js \
+ fauxton/app/addons/documents/base.js \
+ fauxton/app/addons/documents/resources.js \
+ fauxton/app/addons/documents/routes.js \
+ fauxton/app/addons/documents/tests/resourcesSpec.js \
+ fauxton/app/addons/documents/views.js \
+ fauxton/app/addons/fauxton/base.js \
+ fauxton/app/addons/fauxton/components.js \
+ fauxton/app/addons/fauxton/layout.js \
+ fauxton/app/addons/pouchdb/base.js \
+ fauxton/app/addons/pouchdb/pouch.collate.js \
+ fauxton/app/addons/pouchdb/pouchdb.mapreduce.js \
fauxton/app/resizeColumns.js \
fauxton/app/router.js \
- fauxton/app/templates/databases/item.html \
- fauxton/app/templates/databases/list.html \
- fauxton/app/templates/databases/newdatabase.html \
- fauxton/app/templates/documents/all_docs_item.html \
- fauxton/app/templates/documents/all_docs_list.html \
- fauxton/app/templates/documents/changes.html \
- fauxton/app/templates/documents/ddoc_info.html \
- fauxton/app/templates/documents/doc.html \
- fauxton/app/templates/documents/doc_field_editor.html \
- fauxton/app/templates/documents/doc_field_editor_tabs.html \
- fauxton/app/templates/documents/duplicate_doc_modal.html \
- fauxton/app/templates/documents/edit_tools.html \
- fauxton/app/templates/documents/index_menu_item.html \
- fauxton/app/templates/documents/index_row_docular.html \
- fauxton/app/templates/documents/index_row_tabular.html \
- fauxton/app/templates/documents/jumpdoc.html \
- fauxton/app/templates/documents/search.html \
- fauxton/app/templates/documents/sidebar.html \
- fauxton/app/templates/documents/tabs.html \
- fauxton/app/templates/documents/upload_modal.html \
- fauxton/app/templates/documents/view_editor.html \
- fauxton/app/templates/fauxton/api_bar.html \
- fauxton/app/templates/fauxton/breadcrumbs.html \
- fauxton/app/templates/fauxton/footer.html \
- fauxton/app/templates/fauxton/index_pagination.html \
- fauxton/app/templates/fauxton/nav_bar.html \
- fauxton/app/templates/fauxton/notification.html \
- fauxton/app/templates/fauxton/pagination.html \
+ fauxton/app/addons/databases/templates/item.html \
+ fauxton/app/addons/databases/templates/list.html \
+ fauxton/app/addons/databases/templates/newdatabase.html \
+ fauxton/app/addons/documents/templates/all_docs_item.html \
+ fauxton/app/addons/documents/templates/all_docs_list.html \
+ fauxton/app/addons/documents/templates/changes.html \
+ fauxton/app/addons/documents/templates/ddoc_info.html \
+ fauxton/app/addons/documents/templates/doc.html \
+ fauxton/app/addons/documents/templates/doc_field_editor.html \
+ fauxton/app/addons/documents/templates/doc_field_editor_tabs.html \
+ fauxton/app/addons/documents/templates/duplicate_doc_modal.html \
+ fauxton/app/addons/documents/templates/edit_tools.html \
+ fauxton/app/addons/documents/templates/index_menu_item.html \
+ fauxton/app/addons/documents/templates/index_row_docular.html \
+ fauxton/app/addons/documents/templates/index_row_tabular.html \
+ fauxton/app/addons/documents/templates/jumpdoc.html \
+ fauxton/app/addons/documents/templates/search.html \
+ fauxton/app/addons/documents/templates/sidebar.html \
+ fauxton/app/addons/documents/templates/tabs.html \
+ fauxton/app/addons/documents/templates/upload_modal.html \
+ fauxton/app/addons/documents/templates/view_editor.html \
+ fauxton/app/addons/fauxton/templates/api_bar.html \
+ fauxton/app/addons/fauxton/templates/breadcrumbs.html \
+ fauxton/app/addons/fauxton/templates/footer.html \
+ fauxton/app/addons/fauxton/templates/index_pagination.html \
+ fauxton/app/addons/fauxton/templates/nav_bar.html \
+ fauxton/app/addons/fauxton/templates/notification.html \
+ fauxton/app/addons/fauxton/templates/pagination.html \
fauxton/app/templates/layouts/one_pane.html \
fauxton/app/templates/layouts/two_pane.html \
fauxton/app/templates/layouts/with_right_sidebar.html \
@@ -273,12 +273,12 @@ FAUXTON_FILES = \
fauxton/assets/less/bootstrap/utilities.less \
fauxton/assets/less/bootstrap/variables.less \
fauxton/assets/less/bootstrap/wells.less \
- fauxton/assets/less/config.less \
+ fauxton/addons/config/assets/less/config.less \
fauxton/assets/less/couchdb.less \
- fauxton/assets/less/database.less \
+ fauxton/addons/databases/assets/less/databases.less \
fauxton/assets/less/fauxton.less \
fauxton/assets/less/icons.less \
- fauxton/assets/less/logs.less \
+ fauxton/addons/logs/assets/less/logs.less \
fauxton/assets/less/prettyprint.less \
fauxton/assets/less/variables.less \
fauxton/bin/grunt \
[42/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: added dependencies to test task list
Added dependencies to test task list and
added test_inline task for use inside watchRun.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/32bb6ce4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/32bb6ce4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/32bb6ce4
Branch: refs/heads/api-options
Commit: 32bb6ce45d42f971c5d772bc1cdb23a1e678509d
Parents: a09318f
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Wed Jan 15 13:27:06 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 16 19:50:41 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/32bb6ce4/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index cf70440..b42e6b5 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -422,7 +422,9 @@ module.exports = function(grunt) {
*/
// clean out previous build artefactsa and lint
grunt.registerTask('lint', ['clean', 'jshint']);
- grunt.registerTask('test', ['lint', 'mochaSetup','jst', 'concat:test_config_js', 'mocha_phantomjs']);
+ grunt.registerTask('test', ['lint', 'dependencies', 'test_inline']);
+ // lighter weight test task for use inside dev/watch
+ grunt.registerTask('test_inline', ['mochaSetup','jst', 'concat:test_config_js', 'mocha_phantomjs']);
// Fetch dependencies (from git or local dir), lint them and make load_addons
grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default']);
// build templates, js and css
[04/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: Update paginate to work with new backbone
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b9a87c87
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b9a87c87
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b9a87c87
Branch: refs/heads/api-options
Commit: b9a87c875ef0eef2f920781805d26b0dd14e7871
Parents: c894491
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Jan 9 16:03:25 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 9 16:03:25 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/modules/documents/routes.js | 11 +++--
src/fauxton/app/modules/documents/views.js | 57 +++---------------------
src/fauxton/app/modules/fauxton/base.js | 1 -
3 files changed, 13 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9a87c87/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 dbad6d0..435ed5e 100644
--- a/src/fauxton/app/modules/documents/routes.js
+++ b/src/fauxton/app/modules/documents/routes.js
@@ -297,10 +297,14 @@ function(app, FauxtonAPI, Documents, Databases) {
docOptions = app.getParams(),
ddoc = event.ddoc;
+ this.documentsView && this.documentsView.remove();
+
if (event.allDocs) {
- this.documentsView.collection = this.data.database.buildAllDocs(docOptions);
- this.documentsView.cleanup();
- return this.documentsView.forceRender();
+ this.data.database.buildAllDocs(docOptions);
+ this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
+ collection: this.data.database.allDocs
+ }));
+ return;
}
this.data.indexedDocs = new Documents.IndexCollection(null, {
@@ -310,7 +314,6 @@ function(app, FauxtonAPI, Documents, Databases) {
params: app.getParams()
});
- this.documentsView && this.documentsView.remove();
this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
database: this.data.database,
collection: this.data.indexedDocs,
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9a87c87/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 1642f1f..05c86f8 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -31,56 +31,6 @@ define([
function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns) {
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=' + Databases.DocLimit,
- // };
- // },
-
- // 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; }
- // FauxtonAPI.addNotification({
- // msg: "Deleting your database...",
- // type: "error"
- // });
- // return this.database.destroy().done(function () {
- // app.router.navigate('#/_all_dbs', {trigger: true});
- // });
- // }
- // });
-
Views.SearchBox = FauxtonAPI.View.extend({
template: "templates/documents/search",
tagName: "form",
@@ -714,7 +664,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
},
cleanup: function () {
+ //if (!this.pagination) { return; }
this.pagination.remove();
+ //this.pagination = null;
this.allDocsNumber.remove();
_.each(this.rows, function (row) {row.remove();});
},
@@ -722,7 +674,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
beforeRender: function() {
var showNumbers = true;
- this.addPagination();
+ if (!this.pagination) {
+ this.addPagination();
+ }
+
this.insertView('#documents-pagination', this.pagination);
if (this.designDocs || this.collection.idxType === '_view' || this.collection.params.startkey === '"_design"') {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9a87c87/src/fauxton/app/modules/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
index 01c2928..cf6305c 100644
--- a/src/fauxton/app/modules/fauxton/base.js
+++ b/src/fauxton/app/modules/fauxton/base.js
@@ -20,7 +20,6 @@ define([
function(app, Backbone, resizeColumns) {
-
//resizeAnimation
app.resizeColumns = new resizeColumns({});
app.resizeColumns.onResizeHandler();
[44/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
ignoring index.css in concat:index_css
Which is why it was showing up twice.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/424e25af
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/424e25af
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/424e25af
Branch: refs/heads/api-options
Commit: 424e25afa329d4871e3cfeafd4e1cd253b897f4b
Parents: 0fd6a7e
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Thu Jan 16 14:59:27 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Jan 17 09:39:57 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/424e25af/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index b42e6b5..32065b6 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -210,7 +210,7 @@ module.exports = function(grunt) {
},
index_css: {
- src: ["dist/debug/css/*.css", 'assets/css/*.css'],
+ src: ["dist/debug/css/*.css", '!dist/debug/css/index.css', 'assets/css/*.css'],
dest: 'dist/debug/css/index.css'
},
[03/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
Fauxton: Update backbone.layoutmanager to V0.9.4
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c8944911
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c8944911
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c8944911
Branch: refs/heads/api-options
Commit: c8944911766816638682996eb6fd9efe890f3486
Parents: b058aef
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Jan 9 16:02:58 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 9 16:02:58 2014 +0200
----------------------------------------------------------------------
.../assets/js/plugins/backbone.layoutmanager.js | 418 +++++++++----------
1 file changed, 199 insertions(+), 219 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/c8944911/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/backbone.layoutmanager.js b/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
index b8296b4..c5d4a80 100644
--- a/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
+++ b/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
@@ -1,5 +1,5 @@
/*!
- * backbone.layoutmanager.js v0.9.1
+ * backbone.layoutmanager.js v0.9.4
* Copyright 2013, Tim Branyen (@tbranyen)
* backbone.layoutmanager.js may be freely distributed under the MIT license.
*/
@@ -24,30 +24,29 @@
// `window` object; in Node, it will be `global`.
var window = this;
-// Hoisted, referenced at the bottom of the source. This caches a list of all
-// LayoutManager options at definition time.
-var keys;
-
-// Maintain references to the two `Backbone.View` functions that are
-// overwritten so that they can be proxied.
-var _configure = Backbone.View.prototype._configure;
+// Maintain reference to the original constructor.
+var ViewConstructor = Backbone.View;
// Cache these methods for performance.
var aPush = Array.prototype.push;
var aConcat = Array.prototype.concat;
var aSplice = Array.prototype.splice;
+var trim = String.prototype.trim ?
+ _.bind(String.prototype.trim.call, String.prototype.trim) :
+ $.trim;
// LayoutManager is a wrapper around a `Backbone.View`.
+// Backbone.View.extend takes options (protoProps, staticProps)
var LayoutManager = Backbone.View.extend({
- _render: function(manage, options) {
+ _render: function() {
// Keep the view consistent between callbacks and deferreds.
var view = this;
// Shorthand the manager.
var manager = view.__manager__;
// Cache these properties.
- var beforeRender = options.beforeRender;
+ var beforeRender = view.beforeRender;
// Create a deferred instead of going off
- var def = options.deferred();
+ var def = view.deferred();
// Ensure all nested Views are properly scrubbed if re-rendering.
if (view.hasRendered) {
@@ -64,7 +63,7 @@ var LayoutManager = Backbone.View.extend({
view.trigger("beforeRender", view);
// Render!
- manage(view, options).render().then(function() {
+ view._viewRender(manager).render().then(function() {
// Complete this deferred once resolved.
def.resolve();
});
@@ -82,18 +81,142 @@ var LayoutManager = Backbone.View.extend({
// Return this intermediary promise.
return def.promise();
},
-
+
+ // This function is responsible for pairing the rendered template into the
+ // DOM element.
+ _applyTemplate: function(rendered, manager, def) {
+ // Actually put the rendered contents into the element.
+ if (_.isString(rendered)) {
+ // If no container is specified, we must replace the content.
+ if (manager.noel) {
+ rendered = $.parseHTML(rendered, true);
+
+ // Remove extra root elements.
+ this.$el.slice(1).remove();
+
+ // Swap out the View on the first top level element to avoid
+ // duplication.
+ this.$el.replaceWith(rendered);
+
+ // Don't delegate events here - we'll do that in resolve()
+ this.setElement(rendered, false);
+ } else {
+ this.html(this.$el, rendered);
+ }
+ }
+
+ // Resolve only after fetch and render have succeeded.
+ def.resolveWith(this, [this]);
+ },
+
+ // Creates a deferred and returns a function to call when finished.
+ // This gets passed to all _render methods. The `root` value here is passed
+ // from the `manage(this).render()` line in the `_render` function
+ _viewRender: function(manager) {
+ var url, contents, def;
+ var root = this;
+
+ // Once the template is successfully fetched, use its contents to proceed.
+ // Context argument is first, since it is bound for partial application
+ // reasons.
+ function done(context, template) {
+ // Store the rendered template someplace so it can be re-assignable.
+ var rendered;
+
+ // Trigger this once the render method has completed.
+ manager.callback = function(rendered) {
+ // Clean up asynchronous manager properties.
+ delete manager.isAsync;
+ delete manager.callback;
+
+ root._applyTemplate(rendered, manager, def);
+ };
+
+ // Ensure the cache is up-to-date.
+ LayoutManager.cache(url, template);
+
+ // Render the View into the el property.
+ if (template) {
+ rendered = root.renderTemplate.call(root, template, context);
+ }
+
+ // If the function was synchronous, continue execution.
+ if (!manager.isAsync) {
+ root._applyTemplate(rendered, manager, def);
+ }
+ }
+
+ return {
+ // This `render` function is what gets called inside of the View render,
+ // when `manage(this).render` is called. Returns a promise that can be
+ // used to know when the element has been rendered into its parent.
+ render: function() {
+ var context = root.serialize;
+ var template = root.template;
+
+ // Create a deferred specifically for fetching.
+ def = root.deferred();
+
+ // If data is a function, immediately call it.
+ if (_.isFunction(context)) {
+ context = context.call(root);
+ }
+
+ // Set the internal callback to trigger once the asynchronous or
+ // synchronous behavior has completed.
+ manager.callback = function(contents) {
+ // Clean up asynchronous manager properties.
+ delete manager.isAsync;
+ delete manager.callback;
+
+ done(context, contents);
+ };
+
+ // Set the url to the prefix + the view's template property.
+ if (typeof template === "string") {
+ url = root.prefix + template;
+ }
+
+ // Check if contents are already cached and if they are, simply process
+ // the template with the correct data.
+ if (contents = LayoutManager.cache(url)) {
+ done(context, contents, url);
+
+ return def;
+ }
+
+ // Fetch layout and template contents.
+ if (typeof template === "string") {
+ contents = root.fetchTemplate.call(root, root.prefix +
+ template);
+ // If the template is already a function, simply call it.
+ } else if (typeof template === "function") {
+ contents = template;
+ // If its not a string and not undefined, pass the value to `fetch`.
+ } else if (template != null) {
+ contents = root.fetchTemplate.call(root, template);
+ }
+
+ // If the function was synchronous, continue execution.
+ if (!manager.isAsync) {
+ done(context, contents);
+ }
+
+ return def;
+ }
+ };
+ },
+
// This named function allows for significantly easier debugging.
constructor: function Layout(options) {
- // Options may not always be passed to the constructor, this ensures it is
- // always an object.
- options = options || {};
-
// Grant this View superpowers.
- LayoutManager.setupView(this, options);
+ this.manage = true;
+
+ // Give this View access to all passed options as instance properties.
+ _.extend(this, options);
// Have Backbone set up the rest of this View.
- Backbone.View.call(this, options);
+ Backbone.View.apply(this, arguments);
},
// This method is used within specific methods to indicate that they should
@@ -122,8 +245,7 @@ var LayoutManager = Backbone.View.extend({
renderViews: function() {
var root = this;
var manager = root.__manager__;
- var options = root.getAllOptions();
- var newDeferred = options.deferred();
+ var newDeferred = root.deferred();
// Collect all promises from rendering the child views and wait till they
// all complete.
@@ -136,7 +258,7 @@ var LayoutManager = Backbone.View.extend({
// Once all child views have completed rendering, resolve parent deferred
// with the correct context.
- options.when(promises).then(function() {
+ root.when(promises).then(function() {
newDeferred.resolveWith(root, [root]);
});
@@ -239,7 +361,7 @@ var LayoutManager = Backbone.View.extend({
// Must definitely wrap any render method passed in or defaults to a
// typical render function `return layout(this).render()`.
setView: function(name, view, insert) {
- var manager, options, selector;
+ var manager, selector;
// Parent view, the one you are setting a View on.
var root = this;
@@ -261,18 +383,12 @@ var LayoutManager = Backbone.View.extend({
"Backbone.View instances.");
}
- // Assign options.
- options = view.getAllOptions();
-
// Add reference to the parentView.
manager.parent = root;
// Add reference to the placement selector used.
selector = manager.selector = root.sections[name] || name;
- // Call the `setup` method, since we now have a relationship created.
- _.result(view, "setup");
-
// Code path is less complex for Views that are not being inserted. Simply
// remove existing Views and bail out with the assignment.
if (!insert) {
@@ -280,7 +396,7 @@ var LayoutManager = Backbone.View.extend({
// into the parent.
if (view.hasRendered) {
// Apply the partial.
- options.partial(root.$el, view.$el, root.__manager__, manager);
+ view.partial(root.$el, view.$el, root.__manager__, manager);
}
// Ensure remove is called when swapping View's.
@@ -327,11 +443,10 @@ var LayoutManager = Backbone.View.extend({
// once all subviews and main view have been rendered into the view.el.
render: function() {
var root = this;
- var options = root.getAllOptions();
var manager = root.__manager__;
var parent = manager.parent;
var rentManager = parent && parent.__manager__;
- var def = options.deferred();
+ var def = root.deferred();
// Triggered once the render has succeeded.
function resolve() {
@@ -341,16 +456,16 @@ var LayoutManager = Backbone.View.extend({
_.each(root.views, function(views, selector) {
// Fragments aren't used on arrays of subviews.
if (_.isArray(views)) {
- options.htmlBatch(root, views, selector);
+ root.htmlBatch(root, views, selector);
}
});
// If there is a parent and we weren't attached to it via the previous
// method (single view), attach.
if (parent && !manager.insertedViaFragment) {
- if (!options.contains(parent.el, root.el)) {
+ if (!root.contains(parent.el, root.el)) {
// Apply the partial using parent's html() method.
- parent.getAllOptions().partial(parent.$el, root.$el, rentManager,
+ parent.partial(parent.$el, root.$el, rentManager,
manager);
}
}
@@ -377,7 +492,7 @@ var LayoutManager = Backbone.View.extend({
// and setting the hasRendered flag.
function completeRender() {
var console = window.console;
- var afterRender = options.afterRender;
+ var afterRender = root.afterRender;
if (afterRender) {
afterRender.call(root, root);
@@ -391,7 +506,7 @@ var LayoutManager = Backbone.View.extend({
if (manager.noel && root.$el.length > 1) {
// Do not display a warning while testing or if warning suppression
// is enabled.
- if (_.isFunction(console.warn) && !options.suppressWarnings) {
+ if (_.isFunction(console.warn) && !root.suppressWarnings) {
console.warn("`el: false` with multiple top level elements is " +
"not supported.");
@@ -420,11 +535,10 @@ var LayoutManager = Backbone.View.extend({
// Actually facilitate a render.
function actuallyRender() {
- var options = root.getAllOptions();
// The `_viewRender` method is broken out to abstract away from having
// too much code in `actuallyRender`.
- root._render(LayoutManager._viewRender, options).done(function() {
+ root._render().done(function() {
// If there are no children to worry about, complete the render
// instantly.
if (!_.keys(root.views).length) {
@@ -443,7 +557,7 @@ var LayoutManager = Backbone.View.extend({
// Mark each subview's manager so they don't attempt to attach by
// themselves. Return a single promise representing the entire
// render.
- return options.when(_.map(view, function(subView) {
+ return root.when(_.map(view, function(subView) {
subView.__manager__.insertedViaFragment = true;
return subView.render().__manager__.renderDeferred;
}));
@@ -456,7 +570,7 @@ var LayoutManager = Backbone.View.extend({
// Once all nested Views have been rendered, resolve this View's
// deferred.
- options.when(promises).done(resolve);
+ root.when(promises).done(resolve);
});
}
@@ -489,148 +603,14 @@ var LayoutManager = Backbone.View.extend({
// Call the original remove function.
return this._remove.apply(this, arguments);
- },
-
- // Merge instance and global options.
- getAllOptions: function() {
- // Instance overrides take precedence, fallback to prototype options.
- return _.extend({}, this, LayoutManager.prototype.options, this.options);
}
},
+
+// Static Properties
{
// Clearable cache.
_cache: {},
- // Creates a deferred and returns a function to call when finished.
- // This gets passed to all _render methods. The `root` value here is passed
- // from the `manage(this).render()` line in the `_render` function
- _viewRender: function(root, options) {
- var url, contents, def, renderedEl;
- var manager = root.__manager__;
-
- // This function is responsible for pairing the rendered template into
- // the DOM element.
- function applyTemplate(rendered) {
- // Actually put the rendered contents into the element.
- if (_.isString(rendered)) {
- // If no container is specified, we must replace the content.
- if (manager.noel) {
- // Trim off the whitespace, since the contents are passed into `$()`.
- rendered = $.trim(rendered);
-
- // Hold a reference to created element as replaceWith doesn't return
- // new el.
- renderedEl = $(rendered);
-
- // Remove extra root elements.
- root.$el.slice(1).remove();
-
- // Swap out the View on the first top level element to avoid
- // duplication.
- root.$el.replaceWith(renderedEl);
-
- // Don't delegate events here - we'll do that in resolve()
- root.setElement(renderedEl, false);
- } else {
- options.html(root.$el, rendered);
- }
- }
-
- // Resolve only after fetch and render have succeeded.
- def.resolveWith(root, [root]);
- }
-
- // Once the template is successfully fetched, use its contents to proceed.
- // Context argument is first, since it is bound for partial application
- // reasons.
- function done(context, contents) {
- // Store the rendered template someplace so it can be re-assignable.
- var rendered;
-
- // Trigger this once the render method has completed.
- manager.callback = function(rendered) {
- // Clean up asynchronous manager properties.
- delete manager.isAsync;
- delete manager.callback;
-
- applyTemplate(rendered);
- };
-
- // Ensure the cache is up-to-date.
- LayoutManager.cache(url, contents);
-
- // Render the View into the el property.
- if (contents) {
- rendered = options.renderTemplate.call(root, contents, context);
- }
-
- // If the function was synchronous, continue execution.
- if (!manager.isAsync) {
- applyTemplate(rendered);
- }
- }
-
- return {
- // This `render` function is what gets called inside of the View render,
- // when `manage(this).render` is called. Returns a promise that can be
- // used to know when the element has been rendered into its parent.
- render: function() {
- var context = root.serialize || options.serialize;
- var template = root.template || options.template;
-
- // Create a deferred specifically for fetching.
- def = options.deferred();
-
- // If data is a function, immediately call it.
- if (_.isFunction(context)) {
- context = context.call(root);
- }
-
- // Set the internal callback to trigger once the asynchronous or
- // synchronous behavior has completed.
- manager.callback = function(contents) {
- // Clean up asynchronous manager properties.
- delete manager.isAsync;
- delete manager.callback;
-
- done(context, contents);
- };
-
- // Set the url to the prefix + the view's template property.
- if (typeof template === "string") {
- url = options.prefix + template;
- }
-
- // Check if contents are already cached and if they are, simply process
- // the template with the correct data.
- if (contents = LayoutManager.cache(url)) {
- done(context, contents, url);
-
- return def;
- }
-
- // Fetch layout and template contents.
- if (typeof template === "string") {
- contents = options.fetchTemplate.call(root, options.prefix +
- template);
- // If the template is already a function, simply call it.
- } else if (typeof template === "function") {
- contents = template;
- // If its not a string and not undefined, pass the value to `fetch`.
- } else if (template != null) {
- contents = options.fetchTemplate.call(root, template);
- }
-
- // If the function was synchronous, continue execution.
- if (!manager.isAsync) {
- done(context, contents);
- }
-
- return def;
- }
- };
- },
-
// Remove all nested Views.
_removeViews: function(root, force) {
// Shift arguments around.
@@ -713,8 +693,6 @@ var LayoutManager = Backbone.View.extend({
cleanViews: function(views) {
// Clear out all existing views.
_.each(aConcat.call([], views), function(view) {
- var cleanup;
-
// Remove all custom events attached to this View.
view.unbind();
@@ -733,16 +711,15 @@ var LayoutManager = Backbone.View.extend({
// If a custom cleanup method was provided on the view, call it after
// the initial cleanup is done
- cleanup = view.getAllOptions().cleanup;
- if (_.isFunction(cleanup)) {
- cleanup.call(view);
+ if (_.isFunction(view.cleanup)) {
+ view.cleanup();
}
});
},
// This static method allows for global configuration of LayoutManager.
configure: function(options) {
- _.extend(LayoutManager.prototype.options, options);
+ _.extend(LayoutManager.prototype, options);
// Allow LayoutManager to manage Backbone.View.prototype.
if (options.manage) {
@@ -762,6 +739,9 @@ var LayoutManager = Backbone.View.extend({
// Configure a View to work with the LayoutManager plugin.
setupView: function(views, options) {
+ // Don't break the options object (passed into Backbone.View#initialize).
+ options = options || {};
+
// Set up all Views passed.
_.each(aConcat.call([], views), function(view) {
// If the View has already been setup, no need to do it again.
@@ -769,9 +749,8 @@ var LayoutManager = Backbone.View.extend({
return;
}
- var views, declaredViews, viewOptions;
+ var views, declaredViews;
var proto = LayoutManager.prototype;
- var viewOverrides = _.pick(view, keys);
// Ensure necessary properties are set.
_.defaults(view, {
@@ -795,20 +774,11 @@ var LayoutManager = Backbone.View.extend({
// Mix in all LayoutManager prototype properties as well.
}, LayoutManager.prototype);
- // Extend the options with the prototype and passed options.
- options = view.options = _.defaults(options || {}, view.options,
- proto.options);
-
- // Ensure view events are properly copied over.
- viewOptions = _.pick(options, aConcat.call(["events", "sections"],
- _.values(options.events)));
+ // Assign passed options.
+ view.options = options;
// Merge the View options into the View.
- _.extend(view, viewOptions);
-
- // Pick out the specific properties that can be dynamically added at
- // runtime and ensure they are available on the view object.
- _.extend(options, viewOverrides);
+ _.extend(view, options);
// By default the original Remove function is the Backbone.View one.
view._remove = Backbone.View.prototype.remove;
@@ -835,43 +805,42 @@ var LayoutManager = Backbone.View.extend({
// Reset the property to avoid duplication or overwritting.
view.views = {};
+ // If any declared view is wrapped in a function, invoke it.
+ _.each(declaredViews, function(declaredView, key) {
+ if (typeof declaredView === "function") {
+ declaredViews[key] = declaredView.call(view, view);
+ }
+ });
+
// Set the declared Views.
view.setViews(declaredViews);
}
-
- // If a template is passed use that instead.
- if (view.options.template) {
- view.options.template = options.template;
- // Ensure the template is mapped over.
- } else if (view.template) {
- options.template = view.template;
- }
});
}
});
-// Tack on the version.
-LayoutManager.VERSION = "0.9.1";
+LayoutManager.VERSION = "0.9.4";
+// Expose through Backbone object.
Backbone.Layout = LayoutManager;
// Override _configure to provide extra functionality that is necessary in
// order for the render function reference to be bound during initialize.
-Backbone.View.prototype._configure = function(options) {
- var noel, retVal;
+Backbone.View = function(options) {
+ var noel;
+
+ // Ensure options is always an object.
+ options = options || {};
// Remove the container element provided by Backbone.
if ("el" in options ? options.el === false : this.el === false) {
noel = true;
}
- // Run the original _configure.
- retVal = _configure.apply(this, arguments);
-
// If manage is set, do it!
if (options.manage || this.manage) {
// Set up this View.
- LayoutManager.setupView(this);
+ LayoutManager.setupView(this, options);
}
// Assign the `noel` property once we're sure the View we're working with is
@@ -882,11 +851,17 @@ Backbone.View.prototype._configure = function(options) {
}
// Act like nothing happened.
- return retVal;
+ ViewConstructor.apply(this, arguments);
};
+// Copy over the extend method.
+Backbone.View.extend = ViewConstructor.extend;
+
+// Copy over the prototype as well.
+Backbone.View.prototype = ViewConstructor.prototype;
+
// Default configuration options; designed to be overriden.
-LayoutManager.prototype.options = {
+var defaultOptions = {
// Prefix template/layout paths.
prefix: "",
@@ -901,9 +876,14 @@ LayoutManager.prototype.options = {
return _.template($(path).html());
},
- // By default, render using underscore's templating.
+ // By default, render using underscore's templating and trim output.
renderTemplate: function(template, context) {
- return template(context);
+ return trim(template(context));
+ },
+
+ // By default, pass model attributes to the templates
+ serialize: function() {
+ return this.model ? _.clone(this.model.attributes) : {};
},
// This is the most common way you will want to partially apply a view into
@@ -987,8 +967,8 @@ LayoutManager.prototype.options = {
}
};
-// Maintain a list of the keys at define time.
-keys = _.keys(LayoutManager.prototype.options);
+// Extend LayoutManager with default options.
+_.extend(LayoutManager.prototype, defaultOptions);
// Assign `LayoutManager` object for AMD loaders.
return LayoutManager;
[28/50] [abbrv] couchdb commit: updated refs/heads/api-options to
bd721a5
Posted by ga...@apache.org.
moving over post-addons refactor template changes
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/134dd40f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/134dd40f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/134dd40f
Branch: refs/heads/api-options
Commit: 134dd40f259d0365b37db760e039f0873e81aa43
Parents: a37a3eb
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Jan 13 13:45:22 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:09:15 2014 -0500
----------------------------------------------------------------------
.../app/addons/documents/templates/advanced_options.html | 5 +++--
src/fauxton/app/addons/documents/templates/all_docs_layout.html | 2 +-
src/fauxton/app/addons/documents/templates/all_docs_number.html | 4 +++-
.../app/addons/documents/templates/duplicate_doc_modal.html | 2 +-
.../app/addons/documents/templates/index_row_docular.html | 5 +++--
5 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/advanced_options.html b/src/fauxton/app/addons/documents/templates/advanced_options.html
index 8e96574..e256325 100644
--- a/src/fauxton/app/addons/documents/templates/advanced_options.html
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -67,8 +67,9 @@ the License.
Limit:
<select name="limit" class="input-small">
<option>5</option>
- <option selected="selected">10</option>
- <option>25</option>
+ <option>10</option>
+ <option selected="selected">20</option>
+ <option>30</option>
<option>50</option>
<option>100</option>
</select>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/all_docs_layout.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_layout.html b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
index 526c200..6b4a31b 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_layout.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
@@ -12,7 +12,7 @@ License for the specific language governing permissions and limitations under
the License.
-->
<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav">
- <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
+ <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-bypass="true" data-toggle="tab">Query Options</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="query">
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/all_docs_number.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_number.html b/src/fauxton/app/addons/documents/templates/all_docs_number.html
index c4ea8f6..df8fe07 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_number.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html
@@ -13,8 +13,10 @@ the License.
-->
<% if (totalRows === "unknown"){ %>
Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
-<% } else { %>
+<% } else if (showNumbers) { %>
Showing <%=offset%> - <%= numModels %> of <%= totalRows %> rows
+<% } else { %>
+ Showing <%=pageStart%> - <%= pageEnd %>
<%}%>
<% if (updateSeq) { %>
-- Update Sequence: <%= updateSeq %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
index 3f374b6..dbb25bc 100644
--- a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
+++ b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
@@ -19,7 +19,7 @@ the License.
</div>
<div class="modal-body">
<div id="modal-error" class="hide alert alert-error"/>
- <form id="file-upload" class="form" method="post">
+ <form id="doc-duplicate" class="form" method="post">
<p class="help-block">
Set new documents ID:
</p>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
index 3835453..f1b2217 100644
--- a/src/fauxton/app/addons/documents/templates/index_row_docular.html
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -11,8 +11,9 @@ 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"></td>
+<% if (doc.isEditable()) { %>
+ <td class="select"><input type="checkbox"></td>
+<% } %>
<td>
<div>
<pre class="prettyprint"><%- doc.prettyJSON() %></pre>