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/02/11 16:25:28 UTC

[01/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Updated Branches:
  refs/heads/paginate-api-options 5d2a6f9c9 -> 33118afc2 (forced update)


added documentation fixes

made the deletion of a document clearer and
fixed some wording in the JSON structure tables


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/be483fd4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/be483fd4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/be483fd4

Branch: refs/heads/paginate-api-options
Commit: be483fd4141ea2c8cbb91f9ca8b490797d49eedf
Parents: 6fd3840
Author: Andy Wenk <an...@apache.org>
Authored: Fri Jan 24 00:20:41 2014 +0100
Committer: Andy Wenk <an...@nms.de>
Committed: Mon Feb 3 13:05:36 2014 +0100

----------------------------------------------------------------------
 share/doc/src/api/document/common.rst | 19 ++++---
 share/doc/src/json-structure.rst      | 84 +++++++++++++++---------------
 2 files changed, 54 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/be483fd4/share/doc/src/api/document/common.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/api/document/common.rst b/share/doc/src/api/document/common.rst
index f21c8df..bdd6702 100644
--- a/share/doc/src/api/document/common.rst
+++ b/share/doc/src/api/document/common.rst
@@ -238,18 +238,22 @@
         "rev": "1-917fa2381192822767f010b95b45325b"
     }
 
-
 .. http:delete:: /{db}/{docid}
   :synopsis: Deletes the document
 
-  Deletes the specified document from the database. You must supply the
-  current (latest) revision, either by using the ``rev`` parameter to
-  specify the revision.
+  Marks the specified document as deleted by adding a field ``_deleted`` with
+  the value ``true``. Documents with this field will not be returned within
+  requests anymore, but stay in the database. You must supply the current
+  (latest) revision, either by using the ``rev`` parameter or by using the
+  :header:`If-Match` header to specify the revision.
+
+  .. seealso::
+    :ref:`Retrieving Deleted Documents <api/doc/retrieving-deleted-documents>`
 
   .. note::
-    Note that deletion of a record increments the revision number.
-    The use of a revision for deletion of the record allows replication of
-    the database to correctly track the deletion in synchronized copies.
+    CouchDB doesn't actually delete documents. The reason is the need to track
+    them correctly during the replication process between databases to prevent
+    accidental document recovery for any previous state.
 
   :param db: Database name
   :param docid: Document ID
@@ -489,6 +493,7 @@ Basic Attachments Info
       "name": "Spaghetti with meatballs"
   }
 
+.. _api/doc/retrieving-deleted-documents:
 
 Retrieving Attachments Content
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/couchdb/blob/be483fd4/share/doc/src/json-structure.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/json-structure.rst b/share/doc/src/json-structure.rst
index 7d22f1e..4ab2f65 100644
--- a/share/doc/src/json-structure.rst
+++ b/share/doc/src/json-structure.rst
@@ -119,30 +119,30 @@ CouchDB database information object
 +================================+=============================================+
 | db_name                        | The name of the database.                   |
 +--------------------------------+---------------------------------------------+
-| committed_update_seq           | The number of committed update.             |
+| committed_update_seq           | The number of committed updates.            |
 +--------------------------------+---------------------------------------------+
-| doc_count                      | A count of the documents in the specified   |
-|                                | database.                                   |
+| doc_count                      | The number of documents in the database.    |
 +--------------------------------+---------------------------------------------+
-| doc_del_count                  | Number of deleted documents                 |
+| doc_del_count                  | The number of deleted documents.            |
 +--------------------------------+---------------------------------------------+
 | compact_running                | Set to true if the database compaction      |
 |                                | routine is operating on this database.      |
 +--------------------------------+---------------------------------------------+
 | disk_format_version            | The version of the physical format used for |
-|                                | the data when it is stored on disk.         |
+|                                | the data when it is stored on hard disk.    |
 +--------------------------------+---------------------------------------------+
-| disk_size                      | Size in bytes of the data as stored on the  |
-|                                | disk. Views indexes are not included in the |
+| disk_size                      | Size in bytes of the data as stored on disk.|
+|                                | View indexes are not included in the        |
 |                                | calculation.                                |
 +--------------------------------+---------------------------------------------+
-| instance_start_time            | Timestamp of when the database was opened,  |
-|                                | expressed in microseconds since the epoch.  |
+| instance_start_time            | Timestamp indicating when the database was  |
+|                                | opened, expressed in microseconds since the |
+|                                | epoch.                                      |
 +--------------------------------+---------------------------------------------+
 | purge_seq                      | The number of purge operations on the       |
 |                                | database.                                   |
 +--------------------------------+---------------------------------------------+
-| update_seq                     | The current number of updates to the        |
+| update_seq                     | The current number of updates made in the   |
 |                                | database.                                   |
 +--------------------------------+---------------------------------------------+
 
@@ -227,7 +227,7 @@ List of Active Tasks
 +--------------------------------+---------------------------------------------+
 | Field                          | Description                                 |
 +================================+=============================================+
-| tasks [array]                  | Active Task                                 |
+| tasks [array]                  | Active Tasks                                 |
 +--------------------------------+---------------------------------------------+
 |     pid                        | Process ID                                  |
 +--------------------------------+---------------------------------------------+
@@ -265,16 +265,16 @@ Replication Settings
 |                                | start                                       |
 +--------------------------------+---------------------------------------------+
 | filter (optional)              | name of the filter function in the form of  |
-|                                | ddoc/myfilter                               |
+|                                | ``ddoc/myfilter``                           |
 +--------------------------------+---------------------------------------------+
-| query_params (optional)        | query parameter that are passed to the      |
-|                                | filter function; value should be a document |
-|                                | containing parameters as members            |
+| query_params (optional)        | Query parameter that are passed to the      |
+|                                | filter function; the value should be a      |
+|                                | document containing parameters as members   |
 +--------------------------------+---------------------------------------------+
 | use_checkpoints (optional)     | Whether to use replication checkpoints      |
 |                                | or not                                      |
 +--------------------------------+---------------------------------------------+
-| checkpoint_interval (optional) | Specifies checkpoint interval in ms.        |
+| checkpoint_interval (optional) | Specifies the checkpoint interval in ms.    |
 +--------------------------------+---------------------------------------------+
 
 .. _replication-status:
@@ -289,7 +289,7 @@ Replication Status
 +--------------------------------+---------------------------------------------+
 | session_id                     | Unique session ID                           |
 +--------------------------------+---------------------------------------------+
-| source_last_seq                | Last sequence number read from source       |
+| source_last_seq                | Last sequence number read from the source   |
 |                                | database                                    |
 +--------------------------------+---------------------------------------------+
 | history [array]                | Replication History                         |
@@ -326,16 +326,16 @@ Request object
 | Field                          | Description                                 |
 +================================+=============================================+
 | body                           | Request body data as `string`.              |
-|                                | If request method is `GET` method contains  |
-|                                | this field contains ``"undefined"`` value,  |
-|                                | while if `DELETE` or `HEAD` value is ``""`` |
-|                                | (empty string)                              |
+|                                | If the request method is `GET` this field   |
+|                                | contains the value ``"undefined"``. If the  |
+|                                | method is `DELETE` or `HEAD` the value is   |
+|                                | ``""`` (empty string).                      |
 +--------------------------------+---------------------------------------------+
 | cookie                         | Cookies `object`.                           |
 +--------------------------------+---------------------------------------------+
 | form                           | Form data `object`.                         |
-|                                | Contains decoded body as key-value pairs if |
-|                                | `Content-Type` header was                   |
+|                                | Contains the decoded body as key-value      |
+|                                | pairs if the `Content-Type` header was      |
 |                                | ``application/x-www-form-urlencoded``.      |
 +--------------------------------+---------------------------------------------+
 | headers                        | Request headers `object`.                   |
@@ -346,18 +346,18 @@ Request object
 | info                           | :ref:`Database information <dbinfo_object>` |
 +--------------------------------+---------------------------------------------+
 | method                         | Request method as `string` or `array`.      |
-|                                | String value is method is one of: `HEAD`,   |
+|                                | String value is a method as one of: `HEAD`, |
 |                                | `GET`, `POST`, `PUT`, `DELETE`, `OPTIONS`,  |
-|                                | and `TRACE`, otherwise it will be           |
-|                                | represented as array of char codes.         |
+|                                | and `TRACE`. Otherwise it will be           |
+|                                | represented as an array of char codes.      |
 +--------------------------------+---------------------------------------------+
 | path                           | List of requested path sections.            |
 +--------------------------------+---------------------------------------------+
 | peer                           | Request source IP address.                  |
 +--------------------------------+---------------------------------------------+
 | query                          | URL query parameters `object`.              |
-|                                | Note that multiple keys not supported and   |
-|                                | last key value suppress others.             |
+|                                | Note that multiple keys are not supported   |
+|                                | and teh last key value suppresses others.   |
 +--------------------------------+---------------------------------------------+
 | requested_path                 | List of actual requested path section.      |
 +--------------------------------+---------------------------------------------+
@@ -367,8 +367,8 @@ Request object
 +--------------------------------+---------------------------------------------+
 | userCtx                        | :ref:`userctx_object`.                      |
 +--------------------------------+---------------------------------------------+
-| uuid                           | Generated UUID by specified algorithm in    |
-|                                | config file.                                |
+| uuid                           | Generated UUID by a specified algorithm in  |
+|                                | the config file.                            |
 +--------------------------------+---------------------------------------------+
 
 .. code-block:: javascript
@@ -481,15 +481,15 @@ Response object
 +--------------------------------+---------------------------------------------+
 
 .. warning::
-   ``body``, ``base64`` and ``json`` object keys are overlaps each other and
-   the last wins. Since most realizations of key-value objects doesn't preserve
-   key order mixing them may create confusing situation. Try to use only one of
-   them.
+   The ``body``, ``base64`` and ``json`` object keys are overlapping each other
+   where the last one wins. Since most realizations of key-value objects do
+   not preserve the key order or if they are mixed, confusing situations can
+   occure. Try to use only one of them.
 
 .. note::
-   Any custom property makes CouchDB raise internal exception.
-   Also `Response object` could be a simple string value which would be
-   implicitly wrapped into ``{"body": ...}`` object.
+   Any custom property makes CouchDB raise an internal exception.
+   Furthermore, the `Response object` could be a simple string value which would
+   be implicitly wrapped into a ``{"body": ...}`` object.
 
 
 Returned CouchDB Document with Detailed Revision Info
@@ -503,7 +503,7 @@ Returned CouchDB Document with Detailed Revision Info
 | _rev (optional)                | Revision ID (when updating an existing      |
 |                                | document)                                   |
 +--------------------------------+---------------------------------------------+
-| _revs_info [array]             | CouchDB Document Extended Revision Info     |
+| _revs_info [array]             | CouchDB document extended revision info     |
 +--------------------------------+---------------------------------------------+
 |         rev                    | Full revision string                        |
 +--------------------------------+---------------------------------------------+
@@ -521,7 +521,7 @@ Returned CouchDB Document with Revision Info
 | _rev (optional)                | Revision ID (when updating an existing      |
 |                                | document)                                   |
 +--------------------------------+---------------------------------------------+
-| _revisions                     | CouchDB Document Revisions                  |
+| _revisions                     | CouchDB document revisions                  |
 +--------------------------------+---------------------------------------------+
 |     ids [array]                | Array of valid revision IDs, in reverse     |
 |                                | order (latest first)                        |
@@ -540,7 +540,7 @@ Returned Document with Attachments
 | _rev (optional)                | Revision ID (when updating an existing      |
 |                                | document)                                   |
 +--------------------------------+---------------------------------------------+
-| _attachments (optional)        | Document Attachment                         |
+| _attachments (optional)        | Document attachment                         |
 +--------------------------------+---------------------------------------------+
 |     filename                   | Attachment                                  |
 +--------------------------------+---------------------------------------------+
@@ -601,8 +601,8 @@ User Context Object
 +--------------------------------+---------------------------------------------+
 | Field                          | Description                                 |
 +================================+=============================================+
-| db                             | Database name in context of provided        |
-|                                | operation.                                  |
+| db                             | Database name in the context of the         |
+|                                | provided operation.                         |
 +--------------------------------+---------------------------------------------+
 | name                           | User name.                                  |
 +--------------------------------+---------------------------------------------+


[16/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
add per page view limit and new advanced options


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6a225015
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6a225015
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6a225015

Branch: refs/heads/paginate-api-options
Commit: 6a225015d506fc9c91a8e52b907997dbcdc9d72f
Parents: 46edca2
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 28 16:30:38 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:25 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/resources.js   |   2 +-
 .../addons/documents/assets/less/documents.less |   8 +
 src/fauxton/app/addons/documents/resources.js   |  30 ++-
 src/fauxton/app/addons/documents/routes.js      |  16 +-
 .../documents/templates/advanced_options.html   |   6 +-
 .../templates/advanced_options_menu.html        |  46 +++++
 .../documents/templates/all_docs_layout.html    |   2 +
 .../documents/templates/all_docs_number.html    |  22 +-
 .../addons/documents/templates/view_editor.html |   1 +
 src/fauxton/app/addons/documents/views.js       | 207 +++++++++++++------
 src/fauxton/app/addons/fauxton/components.js    |  77 ++++---
 11 files changed, 312 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 ea1aed2..80cd533 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -22,7 +22,7 @@ define([
 function(app, FauxtonAPI, Documents) {
   var Databases = FauxtonAPI.addon();
 
-  Databases.DocLimit = 20;
+  Databases.DocLimit = 100;
 
   Databases.Model = FauxtonAPI.Model.extend({
     initialize: function(options) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 6f462ef..c1f0ed8 100644
--- a/src/fauxton/app/addons/documents/assets/less/documents.less
+++ b/src/fauxton/app/addons/documents/assets/less/documents.less
@@ -23,6 +23,14 @@ button.beautify {
 	margin-top: 20px;
 }
 
+#per-page {
+  float: right;
+
+  #select-per-page {
+    margin-top: 10px;
+  }
+  
+}
 
 /** used in all_docs_list.html **/
 .view {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 adfee1f..a1f43a5 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -281,7 +281,7 @@ function(app, FauxtonAPI) {
       this.database = options.database;
       this.params = options.params;
       this.skipFirstItem = false;
-
+      this.totalRowsToPaginate = 100;
       this.on("remove",this.decrementTotalRows , this);
     },
 
@@ -314,7 +314,17 @@ function(app, FauxtonAPI) {
       });
     },
 
-    urlNextPage: function (num, lastId) {
+    updateLimit: function (limit) {
+      if (this.params.startkey_docid && this.params.startkey) {
+        //we are paginating so set limit + 1
+        this.params.limit = limit + 1;
+        return;
+      }
+
+      this.params.limit = limit;
+    },
+
+    nextPage: function (num, lastId) {
       if (!lastId) {
         var doc = this.last();
 
@@ -333,7 +343,7 @@ function(app, FauxtonAPI) {
       return this.url('app');
     },
 
-    urlPreviousPage: function (num, params) {
+    previousPage: function (num, params) {
       if (params) { 
         this.params = params;
       } else {
@@ -430,7 +440,7 @@ function(app, FauxtonAPI) {
       return url.join("/") + query;
     },
 
-    urlNextPage: function (num, lastId) {
+    nextPage: function (num, lastId) {
       if (!lastId) {
         lastDoc = this.last();
       }
@@ -445,7 +455,7 @@ function(app, FauxtonAPI) {
       return this.url('app');
     },
 
-     urlPreviousPage: function (num, params) {
+     previousPage: function (num, params) {
       if (params) { 
         this.params = params;
       } else {
@@ -456,6 +466,16 @@ function(app, FauxtonAPI) {
       return this.url('app');
     },
 
+    updateLimit: function (limit) {
+      if (this.params.startkey_docid && this.params.startkey) {
+        //we are paginating so set limit + 1
+        this.params.limit = limit + 1;
+        return;
+      }
+
+      this.params.limit = limit;
+    },
+
     recordStart: function () {
       if (this.viewMeta.offset === 0) {
         return 1;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 be9ce2f..4275006 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -155,7 +155,8 @@ function(app, FauxtonAPI, Documents, Databases) {
       "route:updateAllDocs": "updateAllDocsFromView",
       "route:updatePreviewDocs": "updateAllDocsFromPreview",
       "route:reloadDesignDocs": "reloadDesignDocs",
-      "route:paginate": "paginate"
+      "route:paginate": "paginate",
+      "route:perPageChange": "perPageChange"
     },
 
     initialize: function (route, masterLayout, options) {
@@ -304,7 +305,6 @@ 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;
       }
 
@@ -345,13 +345,19 @@ function(app, FauxtonAPI, Documents, Databases) {
       }));
     },
 
-    paginate: function (direction) {
-      _.extend(this.documentsView.collection.params, app.getParams());
+    perPageChange: function (perPage) {
+      this.documentsView.collection.updateLimit(perPage);
       this.documentsView.forceRender();
-      if (direction === 'next') {
+    },
+
+    paginate: function (options) {
+      this.documentsView.forceRender();
+      if (options.direction === 'next') {
         this.documentsView.collection.skipFirstItem = true;
+        this.documentsView.collection.nextPage(options.perPage);
       } else {
         this.documentsView.collection.skipFirstItem = false;
+        this.documentsView.collection.previousPage(options.perPage);
       }
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 bea256a..8f592f4 100644
--- a/src/fauxton/app/addons/documents/templates/advanced_options.html
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -68,10 +68,12 @@ the License.
           <select name="limit" class="input-small">
             <option>5</option>
             <option>10</option>
-            <option selected="selected">20</option>
+            <option >20</option>
             <option>30</option>
             <option>50</option>
-            <option>100</option>
+            <option selected="selected">100</option>
+            <option>500</option>
+            <option>None</option>
           </select>
         </label>
         <div class="checkbox inline">  

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/src/fauxton/app/addons/documents/templates/advanced_options_menu.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/advanced_options_menu.html b/src/fauxton/app/addons/documents/templates/advanced_options_menu.html
new file mode 100644
index 0000000..abc08bd
--- /dev/null
+++ b/src/fauxton/app/addons/documents/templates/advanced_options_menu.html
@@ -0,0 +1,46 @@
+<!--
+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 custom-inputs">
+  <div class="controls controls-row">
+    <div class="checkbox inline">  
+      <input id="include-docs-views" type="checkbox" name="include-docs" value="true">  
+      <label for="include-docs-views">
+        Include Docs</label>  
+    </div> 
+    <% if (hasReduce) { %>
+    <div class="checkbox inline">  
+      <input id="reduce" name="reduce" type="checkbox" value="true">
+      <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">
+          <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> 
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 2862e16..b6428c9 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_layout.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
@@ -11,11 +11,13 @@ 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" href="#query" data-bypass="true" data-toggle="tab">
     <i class="fonticon fonticon-plus"></i> Query Options</a></li>
 </ul>
 <div class="tab-content">
+  <div id="query-options-wrapper"></div>
   <div class="tab-pane" id="query">
   </div>
 </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 df8fe07..4c9130b 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_number.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html
@@ -12,12 +12,24 @@ 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
+Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
 <% } else { %>
-  Showing <%=pageStart%> - <%= pageEnd %>
+Showing <%=pageStart%> - <%= pageEnd %>
 <%}%>
 <% if (updateSeq) { %>
-  -- Update Sequence: <%= updateSeq %>
+-- Update Sequence: <%= updateSeq %>
 <% } %>
+
+<div id="per-page">
+<label id="per-page" class="drop-down inline">
+  Per page:
+  <select id="select-per-page" name="per-page" class="input-small">
+    <option value="5">5</option>
+    <option value="10">10</option>
+    <option value="20">20</option>
+    <option value="30">30</option>
+    <option value="50">50</option>
+    <option value="100">100</option>
+  </select>
+</label>
+</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6a225015/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 b4addad..1b2a337 100644
--- a/src/fauxton/app/addons/documents/templates/view_editor.html
+++ b/src/fauxton/app/addons/documents/templates/view_editor.html
@@ -24,6 +24,7 @@ the License.
   </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/6a225015/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 13cbacb..ee4d30b 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -416,12 +416,28 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
 
     initialize: function (options) {
       this.newView = options.newView || false;
-      this.showNumbers = options.showNumbers;
       this.pagination = options.pagination;
+      
+      this.perPage = 20;
+      
 
       this.listenTo(this.collection, 'totalRows:decrement', this.render);
     },
 
+    events: {
+      'change #select-per-page': 'updatePerPage'
+    },
+
+    updatePerPage: function (event) {
+      this.perPage = parseInt(this.$('#select-per-page :selected').val(), 10);
+      FauxtonAPI.triggerRouteEvent('perPageChange', this.perPage);
+      this.pagination.updatePerPage(this.perPage);
+    },
+
+    afterRender: function () {
+      this.$('option[value="' + this.perPage + '"]').attr('selected', "selected");
+    },
+
     serialize: function () {
        var totalRows = 0,
           recordStart = 0,
@@ -445,7 +461,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         updateSeq: updateSeq,
         offset: recordStart,
         totalRows: totalRows,
-        showNumbers: this.showNumbers,
         numModels: this.collection.models.length + recordStart - 1,
         pageStart: pageStart,
         pageEnd: pageEnd
@@ -464,29 +479,38 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     },
 
     events: {
-      'click #toggle-query': "toggleQuery"
+      'click #query-nav': "toggleQuery"
     },
 
     toggleQuery: function (event) {
       $('#dashboard-content').scrollTop(0);
-      this.$('#query').toggle('fast');
+      this.$('#query').toggle('slow');
     },
 
     beforeRender: function () {
+      this.eventer = _.extend({}, Backbone.Events);
+
       this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
         updateViewFn: this.updateAllDocs,
         previewFn: this.previewView,
         hasReduce: false,
         showPreview: false,
-        database: this.database
+        database: this.database,
+        eventer: this.eventer
       }));
 
+      this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
+        hasReduce: false,
+        eventer:  this.eventer
+       }));
+
       this.$('#query').hide();
     },
 
     afterRender: function () {
       if (this.params) {
         this.advancedOptions.updateFromParams(this.params);
+        this.advancedOptionsMenu.updateFromParams(this.params);
       }
 
     },
@@ -577,15 +601,9 @@ 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
       };
     },
@@ -647,53 +665,20 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
 
     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());
-        }
+        scrollToSelector: '#dashboard-content'
       });
     },
 
     cleanup: function () {
+      this.pagination.remove();
       this.allDocsNumber.remove();
       _.each(this.rows, function (row) {row.remove();});
-
-      if (!this.pagination) { return; }
-      this.pagination.remove();
     },
 
     beforeRender: function() {
-      var showNumbers = true;
 
       if (!this.pagination) {
         this.addPagination();
@@ -701,16 +686,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
 
       this.insertView('#documents-pagination', this.pagination);
 
-      if (this.designDocs || this.collection.idxType === '_view' || this.collection.params.startkey === '"_design"') {
-        showNumbers = false;
+      if (!this.allDocsNumber) {
+        this.allDocsNumber = new Views.AllDocsNumber({
+          collection: this.collection,
+          newView: this.newView,
+          pagination: this.pagination
+        });
       }
 
-      this.allDocsNumber = this.setView('#item-numbers', new Views.AllDocsNumber({
-        collection: this.collection,
-        newView: this.newView,
-        showNumbers: showNumbers,
-        pagination: this.pagination
-      }));
+      this.setView('#item-numbers', this.allDocsNumber);
 
       var docs = this.expandDocs ? this.collection : this.collection.simple();
 
@@ -943,9 +927,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
           model = this.model;
 
       editor.editor.on("change", function (event) {
-        //if (event.data.action !== 'removeText') { return; }
-        //if (!event.data.text.match(/_id/) && !event.data.text.match(/_rev/)) { return; }
-
         var changedDoc;
         try {
           changedDoc = JSON.parse(editor.getValue());
@@ -1024,6 +1005,73 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     }
   });
 
+  Views.AdvancedOptionsMenu = FauxtonAPI.View.extend({
+    template: 'addons/documents/templates/advanced_options_menu',
+    tagName: "div",
+    className: "controls-group 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) {
+      var $groupLevel = this.$('#group-level-label'),
+          params = {
+            include_docs: false,
+            reduce: false,
+            group_level: 0
+          };
+
+      if (this.$('#include-docs-views').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();
+      }
+      this.eventer.trigger('options:param_update', params);
+    },
+
+    updateFromParams: function (params) {
+      if (params.reduce) {
+        var $reduce = this.$('#reduce');
+        $reduce.prop("checked", true);
+        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-views');
+        $include_docs.prop("checked", true);
+      }
+    },
+
+    serialize: function () {
+      return {
+        hasReduce: this.hasReduce
+      };
+    },
+
+    setHasReduce: function (hasReduce) {
+      this.hasReduce = hasReduce;
+    }
+
+  });
+
+
   Views.AdvancedOptions = FauxtonAPI.View.extend({
     template: "addons/documents/templates/advanced_options",
     className: "advanced-options well",
@@ -1034,7 +1082,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 +1095,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       } else {
         this.showPreview = options.showPreview;
       }
+
+      this.eventer && this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate);
     },
 
     events: {
@@ -1056,6 +1106,24 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       "click button.preview": "previewView"
     },
 
+    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;
+       } 
+
+      _.each(params, function(val, key) {
+        $form.find("input[name='"+key+"']").prop('checked', val);
+      });
+      this.$('form.view-query-update').submit();
+    },
+
     beforeRender: function () {
       if (this.viewName && this.ddocName) {
         var buttonViews = FauxtonAPI.getExtensions('advancedOptions:ViewButton');
@@ -1137,7 +1205,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":
@@ -1248,7 +1316,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       "click button.preview": "previewView",
       "click #db-views-tabs-nav": 'toggleIndexNav',
       "click .beautify_map":  "beautifyCode",
-      "click .beautify_reduce":  "beautifyCode"
+      "click .beautify_reduce":  "beautifyCode",
+      "click #query-options-wrapper": 'toggleIndexNav'
     },
 
     langTemplates: {
@@ -1369,6 +1438,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
           that.mapEditor.editSaved();
           that.reduceEditor && that.reduceEditor.editSaved();
 
+
           FauxtonAPI.addNotification({
             msg: "View has been saved.",
             type: "success",
@@ -1396,6 +1466,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
             that.advancedOptions.renderOnUpdatehasReduce(that.hasReduce());
           }
 
+          that.advancedOptionsMenu.setHasReduce(that.hasReduce());
+          that.advancedOptionsMenu.render();
+
           FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: ddocName, view: viewName});
 
         }, function(xhr) {
@@ -1623,19 +1696,29 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         database: this.database
       }));
 
+      this.eventer = _.extend({}, Backbone.Events);
+
       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()
+        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/6a225015/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 8b21916..eb1142c 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -69,34 +69,53 @@ function(app, FauxtonAPI, ace, spin) {
     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 = [];
+      this.pageNumber = 0;
+      this._pageStart = 1;
+      this.perPage = 20;
+    },
+
+    canShowPreviousfn: function () {
+      if (this.pageNumber <= 0) {
+        return false;
+      }
+      return true;
+    },
+
+    canShowNextfn: function () {
+      if (this.collection.length < (this.perPage -1)) {
+        return false;
+      }
+      return true;
     },
 
     previousClicked: function (event) {
       event.preventDefault();
       event.stopPropagation();
       if (!this.canShowPreviousfn()) { return; }
-      FauxtonAPI.navigate(this.previousUrlfn(), {trigger: false});
-      FauxtonAPI.triggerRouteEvent('paginate', 'previous');
+
+      this.pageNumber = this.pageNumber -1;
+      this.decPageStart();
+
+      FauxtonAPI.triggerRouteEvent('paginate', {
+       direction: 'previous',
+       perPage: this.perPage
+      });
     },
 
     nextClicked: function (event) {
       event.preventDefault();
       event.stopPropagation();
       if (!this.canShowNextfn()) { return; }
+      
+      this.pageNumber = this.pageNumber + 1;
+      this.incPageStart();
 
-      var params = _.clone(this.collection.params);
-
-      if (params) {
-        this.previousParams.push(params);
-      }
-
-      FauxtonAPI.navigate(this.nextUrlfn(), {trigger: false});
-      FauxtonAPI.triggerRouteEvent('paginate', 'next');
+      FauxtonAPI.triggerRouteEvent('paginate', {
+       direction: 'next',
+       perPage: this.perPage
+      });
     },
 
     serialize: function () {
@@ -106,29 +125,37 @@ function(app, FauxtonAPI, ace, spin) {
       };
     },
 
-    pageLimit: function () {
-      var limit = 20;
+    updatePerPage: function (perPage) {
+      this.perPage = perPage;
+    },
 
-      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);
+    page: function () {
+      return this._pageStart - 1;
+    },
+
+    incPageStart: function () {
+      this._pageStart = this._pageStart + this.perPage;
+    },
+
+    decPageStart: function () {
+      var val = this._pageStart - this.perPage;
+      if (val < 1) {
+        this._pageStart = 1;
+        return;
       }
 
-      return limit;
+      this._pageStart = val;
     },
 
     pageStart: function () {
-      return (this.previousParams.length * this.pageLimit()) + 1;
-
+      return this._pageStart;
     },
 
     pageEnd: function () {
-      if (this.collection.length < this.pageLimit()) {
-        return (this.previousParams.length * this.pageLimit()) + this.collection.length;
+      if (this.collection.length < this.perPage) {
+        return this.page() + this.collection.length;
       }
 
-      return (this.previousParams.length * this.pageLimit()) + this.pageLimit();
     }
 
   });


[08/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Fix failing grunt test


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/fb633cb2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/fb633cb2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/fb633cb2

Branch: refs/heads/paginate-api-options
Commit: fb633cb2892ff06316b49a1549b804537beaf59e
Parents: 8ec4cbc
Author: Garren Smith <ga...@gmail.com>
Authored: Fri Feb 7 15:13:05 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Feb 7 15:13:05 2014 +0200

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/fb633cb2/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 9507a60..c087afa 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -426,7 +426,7 @@ module.exports = function(grunt) {
    */
   // clean out previous build artefactsa and lint
   grunt.registerTask('lint', ['clean', 'jshint']);
-  grunt.registerTask('test', ['lint', 'dependencies', 'test_inline']);
+  grunt.registerTask('test', ['lint', 'dependencies', 'gen_initialize:development', '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


[07/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Add more caching locations


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/8ec4cbc1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/8ec4cbc1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/8ec4cbc1

Branch: refs/heads/paginate-api-options
Commit: 8ec4cbc11e337555dd82e27e19c802bda3bcb817
Parents: ed89f34
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Feb 5 19:23:12 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Feb 5 19:23:12 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/resources.js |  5 +++++
 src/fauxton/app/addons/databases/routes.js    |  2 +-
 src/fauxton/app/addons/databases/views.js     |  2 +-
 src/fauxton/app/addons/documents/views.js     | 21 +++------------------
 src/fauxton/app/core/base.js                  | 21 ++++++++++++++++++---
 src/fauxton/app/core/couchdbSession.js        | 11 +++++++++--
 6 files changed, 37 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/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 5fa931b..ea1aed2 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -171,6 +171,11 @@ function(app, FauxtonAPI, Documents) {
     documentation: function(){
       return "all_dbs";
     },
+
+    cache: {
+      expires: 60
+    },
+
     url: function(context) {
       if (context === "apiurl") { 
         return window.location.origin + "/_all_dbs";

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/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
index c413018..131abf9 100644
--- a/src/fauxton/app/addons/databases/routes.js
+++ b/src/fauxton/app/addons/databases/routes.js
@@ -59,7 +59,7 @@ function(app, FauxtonAPI, Databases, Views) {
     },
 
     establish: function() {
-     return [this.databases.fetch()];
+     return [this.databases.fetchOnce()];
     }
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/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 afe2d1c..7f23d65 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -61,7 +61,7 @@ function(app, Components, FauxtonAPI, Databases) {
       var deferred = FauxtonAPI.Deferred();
 
       FauxtonAPI.when(currentDBs.map(function(database) {
-        return database.status.fetch();
+        return database.status.fetchOnce();
       })).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

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/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 5476203..13cbacb 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1804,30 +1804,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     template: "addons/documents/templates/changes",
 
     initialize: function () {
-      var that = this;
-      this.listenTo( this.model.changes, 'change', function () {
-        console.log('render on change'); 
-        that.render();
-      });
-      this.listenTo( this.model.changes, 'cachesync', function () {
-        console.log('render on cachesync'); 
-        that.render();
-      });
+      this.listenTo( this.model.changes, 'sync', this.render);
+      this.listenTo( this.model.changes, 'cachesync', this.render);
     },
 
     establish: function() {
-      return [ this.model.changes.fetchOnce({prefill: true,
-        success: function () {
-          console.log('hi ajax success');
-        },
-        prefillSuccess: function () {
-          console.log('hi prefill success');
-        }
-      })];
+      return [ this.model.changes.fetchOnce({prefill: true})];
     },
 
     serialize: function () {
-      console.log('ss');
       return {
         changes: this.model.changes.toJSON(),
         database: this.model

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index 6fe3261..24b89cf 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -17,7 +17,6 @@ define([
 ],
 
 function(Backbone, LayoutManager, BackboneCache) {
-  console.log(BackboneCache);
   var FauxtonAPI = {
     //add default objects
     router: {
@@ -81,8 +80,24 @@ function(Backbone, LayoutManager, BackboneCache) {
   var caching = {
     fetchOnce: function (opts) {
       var options = _.defaults(opts || {}, this.cache, {cache: true});
-      console.log('opts', options);
-      return this.fetch(options);
+
+      if (opts && !opts.cache) {
+        delete options.cache;
+      }
+
+      if (!options.prefill) {
+        return this.fetch(options);
+      }
+
+      //With Prefill, the Caching with resolve with whatever is in the cache for that model/collection
+      //and at the sametime it will fetch from the server the latest. 
+      var promise = FauxtonAPI.Deferred(),
+          fetchPromise = this.fetch(options);
+
+      fetchPromise.progress(promise.resolveWith); // Fires when the cache hit happens
+      fetchPromise.then(promise.resolveWith); // Fires after the AJAX call
+
+      return promise;
     }
   };
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdbSession.js b/src/fauxton/app/core/couchdbSession.js
index 93bfd8a..b70ddf3 100644
--- a/src/fauxton/app/core/couchdbSession.js
+++ b/src/fauxton/app/core/couchdbSession.js
@@ -29,9 +29,16 @@ function (FauxtonAPI) {
 
       fetchUser: function (opt) {
         var that = this,
-        currentUser = this.user();
+            options = opt || {},
+        currentUser = this.user(),
+        fetch = this.fetchOnce;
 
-        return this.fetchOnce(opt).then(function () {
+        if (options.forceFetch) {
+          fetch = this.fetch;
+          Backbone.fetchCache.clearItem(_.result(this.url));
+        }
+
+        return this.fetch(opt).then(function () {
           var user = that.user();
 
           // Notify anyone listening on these events that either a user has changed


[11/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Merge branch 'key-vs-keys'


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/14a38b78
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/14a38b78
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/14a38b78

Branch: refs/heads/paginate-api-options
Commit: 14a38b783f11d11fd63fcf89686431279ad91da5
Parents: b3bb78e 2bc0784
Author: Robert Newson <rn...@apache.org>
Authored: Fri Feb 7 14:41:12 2014 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Feb 7 14:41:12 2014 +0000

----------------------------------------------------------------------
 src/couch_mrview/src/couch_mrview_util.erl | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[13/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Accept gzipped JSON request bodies

COUCHDB-2054


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4d893387
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4d893387
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4d893387

Branch: refs/heads/paginate-api-options
Commit: 4d893387291ef4db1058a2f101bc0fd3c5064b17
Parents: f7801e6
Author: Robert Newson <rn...@apache.org>
Authored: Fri Feb 7 20:33:57 2014 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Feb 7 20:33:57 2014 +0000

----------------------------------------------------------------------
 src/couchdb/couch_httpd.erl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4d893387/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index acc20d7..f00fdd0 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -544,7 +544,7 @@ body(#httpd{req_body=ReqBody}) ->
     ReqBody.
 
 json_body(Httpd) ->
-    ?JSON_DECODE(body(Httpd)).
+    ?JSON_DECODE(maybe_decompress(Httpd, body(Httpd))).
 
 json_body_obj(Httpd) ->
     case json_body(Httpd) of
@@ -554,6 +554,15 @@ json_body_obj(Httpd) ->
     end.
 
 
+maybe_decompress(Httpd, Body) ->
+    case header_value(Httpd, "Content-Encoding", "identity") of
+    "gzip" ->
+        zlib:gunzip(Body);
+    "identity" ->
+        Body;
+    Else ->
+        throw({bad_ctype, [Else, " is not a supported content encoding."]})
+    end.
 
 doc_etag(#doc{revs={Start, [DiskRev|_]}}) ->
     "\"" ++ ?b2l(couch_doc:rev_to_str({Start, DiskRev})) ++ "\"".


[15/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Fauxton: Improve spinners


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/46edca25
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/46edca25
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/46edca25

Branch: refs/heads/paginate-api-options
Commit: 46edca25a875096374097c6e01e746eaa0e5d31c
Parents: d2a0c46
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Feb 11 10:12:21 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:12:21 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/fauxton/components.js | 22 +++++++++++++++-------
 src/fauxton/app/core/routeObject.js          |  1 -
 2 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/46edca25/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 1f5e4ad..8b21916 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -415,6 +415,8 @@ function(app, FauxtonAPI, ace, spin) {
         shadow: false // Whether to render a shadow
      };
 
+     if (routeObjectSpinner) { return; }
+
      if (!$('.spinner').length) {
        $('<div class="spinner"></div>')
         .appendTo('#app-container');
@@ -428,18 +430,22 @@ function(app, FauxtonAPI, ace, spin) {
   var removeRouteObjectSpinner = function () {
     if (routeObjectSpinner) {
       routeObjectSpinner.stop();
+      routeObjectSpinner = null;
       $('.spinner').remove();
     }
   };
 
-  var removeViewSpinner = function () {
+  var removeViewSpinner = function (selector) {
+    var viewSpinner = viewSpinners[selector];
+
     if (viewSpinner){
       viewSpinner.stop();
-      $('.spinner').remove();
+      $(selector).find('.spinner').remove();
+      delete viewSpinners[selector];
     }
   };
 
-  var viewSpinner;
+  var viewSpinners = {};
   FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
     removeRouteObjectSpinner();
 
@@ -455,19 +461,21 @@ function(app, FauxtonAPI, ace, spin) {
         shadow: false // Whether to render a shadow
       };
 
-      viewSpinner = new Spinner(opts).spin();
+      var viewSpinner = new Spinner(opts).spin();
       $('<div class="spinner"></div>')
         .appendTo(selector)
         .append(viewSpinner.el);
+
+      viewSpinners[selector] = viewSpinner;
     }
   });
 
   FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
-    removeViewSpinner();
+    removeViewSpinner(selector);
   });
 
-  FauxtonAPI.RouteObject.on('viewHasRendered', function () {
-    removeViewSpinner();
+  FauxtonAPI.RouteObject.on('viewHasRendered', function (view, selector) {
+    removeViewSpinner(selector);
     removeRouteObjectSpinner();
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/46edca25/src/fauxton/app/core/routeObject.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/routeObject.js b/src/fauxton/app/core/routeObject.js
index 9f1067f..f8a238f 100644
--- a/src/fauxton/app/core/routeObject.js
+++ b/src/fauxton/app/core/routeObject.js
@@ -231,7 +231,6 @@ function(FauxtonAPI, Backbone) {
       if (_.isEmpty(promise)) { return; }
 
       if (!_.isArray(promise)) {
-        if (!promise.abort && !promise.reject) {
         return this._promises.push(promise);
       }
 


[12/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Fix Beautify button css


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f7801e66
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f7801e66
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f7801e66

Branch: refs/heads/paginate-api-options
Commit: f7801e669e522ca3bd92cfc4fdf2a65879369be1
Parents: 14a38b7
Author: suelockwood <de...@apache.org>
Authored: Fri Feb 7 14:46:43 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Fri Feb 7 14:47:05 2014 -0500

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/templates/view_editor.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f7801e66/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 be60090..b4addad 100644
--- a/src/fauxton/app/addons/documents/templates/view_editor.html
+++ b/src/fauxton/app/addons/documents/templates/view_editor.html
@@ -44,7 +44,7 @@ the License.
             <div class="js-editor" id="map-function"><%= langTemplates.map %></div>
             <% } else { %>
             <div class="js-editor" id="map-function"><%- ddoc.get('views')[viewName].map %></div>
-            <button class="beautify beautify_map button hide beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button>
+            <button class="beautify beautify_map btn btn-primary btn-large hide beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button>
             <% } %>
           </div>
 
@@ -67,7 +67,7 @@ the License.
             <div class="js-editor" id="reduce-function"><%= langTemplates.reduce %></div>
             <% } else { %>
             <div class="js-editor" id="reduce-function"><%- ddoc.get('views')[viewName].reduce %></div>
-            <button class="beautify beautify_reduce button hide beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button>
+            <button class="beautify beautify_reduce btn btn-primary btn-large hide beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button>
             <% } %>
           </div>
 


[14/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Fauxton: Improvements to xhr cancellations


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d2a0c46e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d2a0c46e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d2a0c46e

Branch: refs/heads/paginate-api-options
Commit: d2a0c46e9475b14c85067e0139b3ecb166fa475a
Parents: 4d89338
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Feb 10 15:53:10 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Feb 10 15:53:10 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/core/base.js                          | 1 +
 src/fauxton/app/core/couchdbSession.js                | 6 +++---
 src/fauxton/app/core/routeObject.js                   | 4 +++-
 src/fauxton/app/core/router.js                        | 6 +++---
 src/fauxton/assets/js/plugins/backbone.fetch-cache.js | 8 ++++----
 5 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a0c46e/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index 24b89cf..7cacf39 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -96,6 +96,7 @@ function(Backbone, LayoutManager, BackboneCache) {
 
       fetchPromise.progress(promise.resolveWith); // Fires when the cache hit happens
       fetchPromise.then(promise.resolveWith); // Fires after the AJAX call
+      promise.fail(fetchPromise.abort);
 
       return promise;
     }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a0c46e/src/fauxton/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdbSession.js b/src/fauxton/app/core/couchdbSession.js
index b70ddf3..c59a8fc 100644
--- a/src/fauxton/app/core/couchdbSession.js
+++ b/src/fauxton/app/core/couchdbSession.js
@@ -30,15 +30,15 @@ function (FauxtonAPI) {
       fetchUser: function (opt) {
         var that = this,
             options = opt || {},
-        currentUser = this.user(),
-        fetch = this.fetchOnce;
+            currentUser = this.user(),
+            fetch = _.bind(this.fetchOnce, this);
 
         if (options.forceFetch) {
           fetch = this.fetch;
           Backbone.fetchCache.clearItem(_.result(this.url));
         }
 
-        return this.fetch(opt).then(function () {
+        return fetch(opt).then(function () {
           var user = that.user();
 
           // Notify anyone listening on these events that either a user has changed

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a0c46e/src/fauxton/app/core/routeObject.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/routeObject.js b/src/fauxton/app/core/routeObject.js
index f3b8672..9f1067f 100644
--- a/src/fauxton/app/core/routeObject.js
+++ b/src/fauxton/app/core/routeObject.js
@@ -223,6 +223,7 @@ function(FauxtonAPI, Backbone) {
       _.each(this.views, function (view, selector) {
         view.remove();
         delete this.views[selector];
+        view = null;
       }, this);
     },
 
@@ -230,6 +231,7 @@ function(FauxtonAPI, Backbone) {
       if (_.isEmpty(promise)) { return; }
 
       if (!_.isArray(promise)) {
+        if (!promise.abort && !promise.reject) {
         return this._promises.push(promise);
       }
 
@@ -250,7 +252,7 @@ function(FauxtonAPI, Backbone) {
           return promise.abort("Route change");
         } 
 
-        promise.reject();
+        promise.reject && promise.reject();
       }, this);
 
       this._promises = [];

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a0c46e/src/fauxton/app/core/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/router.js b/src/fauxton/app/core/router.js
index cc1ca4f..bef4ced 100644
--- a/src/fauxton/app/core/router.js
+++ b/src/fauxton/app/core/router.js
@@ -59,13 +59,13 @@ function(FauxtonAPI, Auth, Backbone) {
 
           authPromise.then(function () {
             if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
-              if (that.activeRouteObject) {
-                that.activeRouteObject.cleanup();
-              }
+              that.activeRouteObject && that.activeRouteObject.cleanup();
+
               that.activeRouteObject = new RouteObject(route, masterLayout, args);
             }
 
             var routeObject = that.activeRouteObject;
+            routeObject.rejectPromises();
             routeObject.routeCallback(route, args);
             routeObject.renderWith(route, masterLayout, args);
           }, function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a0c46e/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/backbone.fetch-cache.js b/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
index c86a8b9..4aa7676 100644
--- a/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
+++ b/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
@@ -192,7 +192,7 @@
       }
 
       if (!opts.prefill) {
-        return deferred.promise();
+        return deferred;
       }
     }
 
@@ -206,7 +206,7 @@
       .fail( _.bind(deferred.reject, this, this) );
 
     // return a promise which provides the same methods as a jqXHR object
-    return deferred.promise();
+    return deferred;
   };
 
   // Override Model.prototype.sync and try to clear cache items if it looks
@@ -278,7 +278,7 @@
       }
 
       if (!opts.prefill) {
-        return deferred.promise();
+        return deferred;
       }
     }
 
@@ -292,7 +292,7 @@
       .fail( _.bind(deferred.reject, this, this) );
 
     // return a promise which provides the same methods as a jqXHR object
-    return deferred.promise();
+    return deferred;
   };
 
   // Prime the cache from localStorage on initialization


[10/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Send better error if user specifies key and keys

closes COUCHDB-2053


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/2bc07840
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2bc07840
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2bc07840

Branch: refs/heads/paginate-api-options
Commit: 2bc0784030847cbbdd8998d3f135f91992768f6a
Parents: e7fdc16
Author: Robert Newson <rn...@apache.org>
Authored: Fri Feb 7 11:00:24 2014 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Feb 7 14:40:40 2014 +0000

----------------------------------------------------------------------
 src/couch_mrview/src/couch_mrview_util.erl | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/2bc07840/src/couch_mrview/src/couch_mrview_util.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index c4272f8..95f7be4 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -359,11 +359,13 @@ validate_args(Args) ->
         _ -> mrverror(<<"`keys` must be an array of strings.">>)
     end,
 
-    case {Args#mrargs.keys, Args#mrargs.start_key} of
-        {undefined, _} -> ok;
-        {[], _} -> ok;
-        {[_|_], undefined} -> ok;
-        _ -> mrverror(<<"`start_key` is incompatible with `keys`">>)
+    case {Args#mrargs.keys, Args#mrargs.start_key,
+          Args#mrargs.end_key} of
+        {undefined, _, _} -> ok;
+        {[], _, _} -> ok;
+        {[_|_], undefined, undefined} -> ok;
+        _ -> mrverror(<<"`keys` is incompatible with `key`"
+                        ", `start_key` and `end_key`">>)
     end,
 
     case Args#mrargs.start_key_docid of
@@ -372,13 +374,6 @@ validate_args(Args) ->
         _ -> mrverror(<<"`start_key_docid` must be a string.">>)
     end,
 
-    case {Args#mrargs.keys, Args#mrargs.end_key} of
-        {undefined, _} -> ok;
-        {[], _} -> ok;
-        {[_|_], undefined} -> ok;
-        _ -> mrverror(<<"`end_key` is incompatible with `keys`">>)
-    end,
-
     case Args#mrargs.end_key_docid of
         undefined -> ok;
         EKDocId0 when is_binary(EKDocId0) -> ok;


[21/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
remove api options


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b95251ce
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b95251ce
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b95251ce

Branch: refs/heads/paginate-api-options
Commit: b95251cec04fb78a9c9dd9ba82fe31405d15efd1
Parents: 0959288
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Feb 11 08:49:47 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:26 2014 +0200

----------------------------------------------------------------------
 .../documents/templates/advanced_options.html   |  4 +--
 .../documents/templates/all_docs_layout.html    |  6 ++--
 .../addons/documents/templates/view_editor.html |  3 ++
 src/fauxton/app/addons/documents/views.js       | 30 +++++++++++---------
 4 files changed, 25 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b95251ce/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 8f592f4..fbf958e 100644
--- a/src/fauxton/app/addons/documents/templates/advanced_options.html
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -71,9 +71,9 @@ the License.
             <option >20</option>
             <option>30</option>
             <option>50</option>
-            <option selected="selected">100</option>
+            <option >100</option>
             <option>500</option>
-            <option>None</option>
+            <option selected="selected">None</option>
           </select>
         </label>
         <div class="checkbox inline">  

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b95251ce/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 1bbe59d..2862e16 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_layout.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
@@ -11,9 +11,11 @@ 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" href="#query" data-bypass="true" data-toggle="tab">
+    <i class="fonticon fonticon-plus"></i> Query Options</a></li>
+</ul>
 <div class="tab-content">
-  <div id="query-options-wrapper"></div>
   <div class="tab-pane" id="query">
   </div>
 </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b95251ce/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 0916a45..976be7a 100644
--- a/src/fauxton/app/addons/documents/templates/view_editor.html
+++ b/src/fauxton/app/addons/documents/templates/view_editor.html
@@ -17,6 +17,9 @@ the License.
       <i class="fonticon-wrench fonticon"></i>
       <% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
     <% if (!newView) { %>
+    <li><a data-bypass="true" id="query-nav" href="#query" data-toggle="tab">
+      <i class="fonticon-plus fonticon"></i> Query Options</a>
+    </li>
     <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
     <% } %>
   </ul>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b95251ce/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 d864c64..41b375c 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -26,8 +26,6 @@ define([
        // Plugins
        "plugins/beautify",
        "plugins/prettify",
-
-
 ],
 
 function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns, beautify) {
@@ -499,18 +497,18 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         eventer: this.eventer
       }));
 
-      this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
+      /*this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
         hasReduce: false,
         eventer:  this.eventer
-       }));
+       }));*/
 
-      this.$('#query').hide();
+      //this.$('#query').hide();
     },
 
     afterRender: function () {
       if (this.params) {
         this.advancedOptions.updateFromParams(this.params);
-        this.advancedOptionsMenu.updateFromParams(this.params);
+        //this.advancedOptionsMenu.updateFromParams(this.params);
       }
 
     },
@@ -1144,9 +1142,13 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     queryParams: function () {
       var $form = this.$(".view-query-update");
       // Ignore params without a value
-      var params = _.filter($form.serializeArray(), function(param) {
-        return param.value;
-      });
+      var params = _.reduce($form.serializeArray(), function(params, param) {
+        if (!params.value) { return params; }
+        if (param.name === "limit" && param.value === 'None') { return params; }
+
+        params.push(param.value);
+        return params;
+      }, []);
 
       // Validate *key* params to ensure they're valid JSON
       var keyParams = ["key","keys","startkey","endkey"];
@@ -1468,8 +1470,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
             that.advancedOptions.renderOnUpdatehasReduce(that.hasReduce());
           }
 
-          that.advancedOptionsMenu.setHasReduce(that.hasReduce());
-          that.advancedOptionsMenu.render();
+          //that.advancedOptionsMenu.setHasReduce(that.hasReduce());
+          //that.advancedOptionsMenu.render();
 
           FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: ddocName, view: viewName});
 
@@ -1712,10 +1714,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
           eventer: this.eventer
         }));
 
-        this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
+        /*this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
           hasReduce: this.hasReduce(),
           eventer:  this.eventer
-         }));
+         }));*/
       }
 
     },
@@ -1723,7 +1725,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     afterRender: function() {
       if (this.params && !this.newView) {
         this.advancedOptions.updateFromParams(this.params);
-        this.advancedOptionsMenu.updateFromParams(this.params);
+        //this.advancedOptionsMenu.updateFromParams(this.params);
       }
 
       this.designDocSelector.updateDesignDoc();


[18/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
fix previous paginate


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0959288f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0959288f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0959288f

Branch: refs/heads/paginate-api-options
Commit: 0959288fa7dfb8ff2f5165183d52a2a2f584034a
Parents: 4a8b5f7
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Feb 3 15:08:20 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:25 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js | 7 ++++++-
 src/fauxton/app/addons/documents/routes.js    | 8 ++++++--
 src/fauxton/app/addons/documents/views.js     | 1 -
 src/fauxton/app/addons/fauxton/components.js  | 8 ++++++--
 4 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/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 4028cb1..c2f9a70 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -281,7 +281,6 @@ function(app, FauxtonAPI) {
       this.database = options.database;
       this.params = _.clone(options.params);
       this.skipFirstItem = false;
-      this.totalRowsToPaginate = 100;
       this.on("remove",this.decrementTotalRows , this);
       this.perPageLimit = options.perPageLimit || 20;
 
@@ -426,6 +425,12 @@ function(app, FauxtonAPI) {
       this.view = options.view;
       this.design = options.design.replace('_design/','');
       this.skipFirstItem = false;
+      this.perPageLimit = options.perPageLimit || 20;
+
+      if (this.params.limit > this.perPageLimit) {
+        this.params.limit = this.perPageLimit; 
+      }
+
     },
 
     url: function(context) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/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 f9500b2..06db528 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -356,8 +356,12 @@ function(app, FauxtonAPI, Documents, Databases) {
         this.documentsView.collection.skipFirstItem = true;
         this.documentsView.collection.nextPage(options.perPage);
       } else {
-        this.documentsView.collection.skipFirstItem = false;
-        this.documentsView.collection.previousPage(options.perPage);
+        if (options.params && options.params.startkey) {
+          this.documentsView.collection.skipFirstItem = true;
+        } else {
+          this.documentsView.collection.skipFirstItem = false;
+        }
+        this.documentsView.collection.previousPage(options.perPage, options.params);
       }
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/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 eb99139..d864c64 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -456,7 +456,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         pageEnd =  this.pagination.pageEnd();
       }
 
-      console.log('t', totalRows, this.collection);
       return {
         database: app.utils.safeURLName(this.collection.database.id),
         updateSeq: updateSeq,

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0959288f/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 fd45aa2..130d3c7 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -75,6 +75,7 @@ function(app, FauxtonAPI, ace, spin) {
       this._pageStart = 1;
       this.perPage = 20;
       this.docLimit = options.docLimit || 100;
+      this.paramsHistory = [];
     },
 
     canShowPreviousfn: function () {
@@ -106,7 +107,8 @@ function(app, FauxtonAPI, ace, spin) {
 
       FauxtonAPI.triggerRouteEvent('paginate', {
        direction: 'previous',
-       perPage: this.perPage
+       perPage: this.perPage,
+       params: this.paramsHistory.pop()
       });
     },
 
@@ -114,7 +116,8 @@ function(app, FauxtonAPI, ace, spin) {
       event.preventDefault();
       event.stopPropagation();
       if (!this.canShowNextfn()) { return; }
-      
+
+      this.paramsHistory.push(_.clone(this.collection.params));
       this.pageNumber = this.pageNumber + 1;
       this.incPageStart();
 
@@ -129,6 +132,7 @@ function(app, FauxtonAPI, ace, spin) {
        direction: 'next',
        perPage: limit
       });
+
     },
 
     serialize: function () {


[20/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Set view limit on pagination


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4a8b5f7a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4a8b5f7a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4a8b5f7a

Branch: refs/heads/paginate-api-options
Commit: 4a8b5f7ae586ef5510803b2990c728b80c953f5b
Parents: 144144b
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Feb 3 12:10:08 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:25 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js   |  4 ++-
 src/fauxton/app/addons/documents/routes.js      |  5 ++-
 .../documents/templates/all_docs_layout.html    |  4 ---
 .../documents/templates/all_docs_number.html    |  2 +-
 .../addons/documents/templates/view_editor.html |  2 --
 src/fauxton/app/addons/documents/views.js       | 36 +++++++++++---------
 6 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4a8b5f7a/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 72cdb66..4028cb1 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -285,7 +285,9 @@ function(app, FauxtonAPI) {
       this.on("remove",this.decrementTotalRows , this);
       this.perPageLimit = options.perPageLimit || 20;
 
-      this.params.limit = this.perPageLimit; 
+      if (this.params.limit > this.perPageLimit) {
+        this.params.limit = this.perPageLimit; 
+      }
     },
 
     url: function(context) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4a8b5f7a/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 f4700d4..f9500b2 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -275,9 +275,8 @@ function(app, FauxtonAPI, Documents, Databases) {
     newViewEditor: function () {
       var params = app.getParams();
 
-      if (this.toolsView) {
-        this.toolsView.remove();
-      }
+      this.toolsView && this.toolsView.remove();
+      this.documentsView && this.documentsView.remove();
 
       this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({
         ddocs: this.data.designDocs,

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4a8b5f7a/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 b6428c9..1bbe59d 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_layout.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
@@ -12,10 +12,6 @@ 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" href="#query" data-bypass="true" data-toggle="tab">
-    <i class="fonticon fonticon-plus"></i> Query Options</a></li>
-</ul>
 <div class="tab-content">
   <div id="query-options-wrapper"></div>
   <div class="tab-pane" id="query">

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4a8b5f7a/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 4c9130b..fb9ea11 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_number.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html
@@ -11,7 +11,7 @@ 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"){ %>
+<% if (totalRows === "unknown" || totalRows === 0){ %>
 Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
 <% } else { %>
 Showing <%=pageStart%> - <%= pageEnd %>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4a8b5f7a/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 1b2a337..0916a45 100644
--- a/src/fauxton/app/addons/documents/templates/view_editor.html
+++ b/src/fauxton/app/addons/documents/templates/view_editor.html
@@ -17,8 +17,6 @@ the License.
       <i class="fonticon-wrench fonticon"></i>
       <% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
     <% if (!newView) { %>
-    <li><a data-bypass="true" id="query-nav" href="#query" data-toggle="tab">
-      <i class="fonticon-plus fonticon"></i> Query Options</a></li>
     <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
     <% } %>
   </ul>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4a8b5f7a/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 265ffe2..eb99139 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -446,7 +446,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
           pageEnd = 20;
 
       if (!this.newView) {
-        totalRows = this.collection.totalRows();
+        totalRows = this.collection.length;
         updateSeq = this.collection.updateSeq();
       }
 
@@ -456,6 +456,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         pageEnd =  this.pagination.pageEnd();
       }
 
+      console.log('t', totalRows, this.collection);
       return {
         database: app.utils.safeURLName(this.collection.database.id),
         updateSeq: updateSeq,
@@ -1698,27 +1699,30 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         database: this.database
       }));
 
-      this.eventer = _.extend({}, Backbone.Events);
 
-      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(),
-        eventer: this.eventer
-      }));
+      if (!this.newView) {
+        this.eventer = _.extend({}, Backbone.Events);
+
+        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(),
+          eventer: this.eventer
+        }));
 
-      this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
-        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) {
+      if (this.params && !this.newView) {
         this.advancedOptions.updateFromParams(this.params);
         this.advancedOptionsMenu.updateFromParams(this.params);
       }


[05/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
nv.d3.css is the one CSS used in Fauxton

And now it is loaded before the fauxton.less
file. Other options would include moving/renaming
it (to a .less file) and making it an @import.
Not necessary this time, but may be for other
needed CSS.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/34aabbfb
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/34aabbfb
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/34aabbfb

Branch: refs/heads/paginate-api-options
Commit: 34aabbfb58ca4f0ed60a20c466b6bf544b7dc28f
Parents: b8fe3cb
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Feb 3 15:20:26 2014 -0500
Committer: BigBlueHat <by...@bigbluehat.com>
Committed: Mon Feb 3 15:20:26 2014 -0500

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/34aabbfb/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 554eccb..9507a60 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -67,7 +67,7 @@ module.exports = function(grunt) {
       img: ["assets/img/**"],
       // used in concat:index_css to keep file ordering intact
       // fauxton.css should load first
-      css: ["dist/debug/css/fauxton.css"]
+      css: ["assets/css/*.css", "dist/debug/css/fauxton.css"]
     };
     helper.processAddons(function(addon){
       // Less files from addons


[04/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
fixed settings.json.dev; added fauxton & cachebuster


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/8462b9d3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/8462b9d3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/8462b9d3

Branch: refs/heads/paginate-api-options
Commit: 8462b9d3dcbd789d4ca61984584c3d284bee486d
Parents: 9185631
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Fri Jan 31 16:59:16 2014 -0500
Committer: BigBlueHat <by...@bigbluehat.com>
Committed: Mon Feb 3 11:29:00 2014 -0500

----------------------------------------------------------------------
 src/fauxton/settings.json.dev | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/8462b9d3/src/fauxton/settings.json.dev
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.dev b/src/fauxton/settings.json.dev
index e2df66b..d354c29 100644
--- a/src/fauxton/settings.json.dev
+++ b/src/fauxton/settings.json.dev
@@ -1,5 +1,6 @@
 {
   "deps": [
+  { "name": "fauxton" },
   { "name": "databases" },
   { "name": "documents" },
   { "name": "pouchdb" },
@@ -23,7 +24,8 @@
         "variables": {
           "requirejs": "/assets/js/libs/require.js",
           "css": "./css/index.css",
-          "base": null
+          "base": null,
+          "cachebuster": ""
         },
         "app": {
           "root": "/",
@@ -37,7 +39,8 @@
         "variables": {
           "requirejs": "./js/require.js",
           "css": "./css/index.css",
-          "base": null
+          "base": null,
+          "cachebuster": "?v1.0"
         },
         "app": {
           "root": "/_utils/fauxton/",


[06/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Add backbone.fetch-cache


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ed89f340
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ed89f340
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ed89f340

Branch: refs/heads/paginate-api-options
Commit: ed89f34020a10259344ded418785a4492159c23f
Parents: 34aabbf
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Feb 4 16:47:54 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 4 16:47:54 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/resources.js   |   8 +-
 src/fauxton/app/addons/documents/resources.js   |  14 +-
 src/fauxton/app/addons/documents/routes.js      |   2 +-
 src/fauxton/app/addons/documents/views.js       |  22 +-
 src/fauxton/app/config.js                       |   3 +-
 src/fauxton/app/core/base.js                    |  27 +-
 .../assets/js/plugins/backbone.fetch-cache.js   | 311 +++++++++++++++++++
 7 files changed, 365 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/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 1b55f88..5fa931b 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -24,7 +24,7 @@ function(app, FauxtonAPI, Documents) {
 
   Databases.DocLimit = 20;
 
-  Databases.Model = Backbone.Model.extend({
+  Databases.Model = FauxtonAPI.Model.extend({
     initialize: function(options) {
       this.status = new Databases.Status({
         database: this
@@ -82,7 +82,7 @@ function(app, FauxtonAPI, Documents) {
     }
   });
 
-  Databases.Changes = Backbone.Collection.extend({
+  Databases.Changes = FauxtonAPI.Collection.extend({
 
     initialize: function(options) {
       this.database = options.database;
@@ -110,7 +110,7 @@ function(app, FauxtonAPI, Documents) {
     }
   });
 
-  Databases.Status = Backbone.Model.extend({
+  Databases.Status = FauxtonAPI.Model.extend({
     url: function() {
       return app.host + "/" + this.database.safeID();
     },
@@ -166,7 +166,7 @@ function(app, FauxtonAPI, Documents) {
   });
 
   // TODO: shared databases - read from the user doc
-  Databases.List = Backbone.Collection.extend({
+  Databases.List = FauxtonAPI.Collection.extend({
     model: Databases.Model,
     documentation: function(){
       return "all_dbs";

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/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..adfee1f 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -18,7 +18,7 @@ define([
 function(app, FauxtonAPI) {
   var Documents = FauxtonAPI.addon();
 
-  Documents.Doc = Backbone.Model.extend({
+  Documents.Doc = FauxtonAPI.Model.extend({
     idAttribute: "_id",
     documentation: function(){
       return "docs";
@@ -194,7 +194,7 @@ function(app, FauxtonAPI) {
     }
   });
 
-  Documents.DdocInfo = Backbone.Model.extend({
+  Documents.DdocInfo = FauxtonAPI.Model.extend({
     idAttribute: "_id",
     documentation: function(){
       return "docs";
@@ -224,7 +224,7 @@ function(app, FauxtonAPI) {
 
   });
 
-  Documents.ViewRow = Backbone.Model.extend({
+  Documents.ViewRow = FauxtonAPI.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",
@@ -272,7 +272,7 @@ function(app, FauxtonAPI) {
 
   });
 
-  Documents.AllDocs = Backbone.Collection.extend({
+  Documents.AllDocs = FauxtonAPI.Collection.extend({
     model: Documents.Doc,
     documentation: function(){
       return "docs";
@@ -397,7 +397,7 @@ function(app, FauxtonAPI) {
     }
   });
 
-  Documents.IndexCollection = Backbone.Collection.extend({
+  Documents.IndexCollection = FauxtonAPI.Collection.extend({
     model: Documents.ViewRow,
     documentation: function(){
       return "docs";
@@ -527,7 +527,7 @@ function(app, FauxtonAPI) {
     // we can get the request duration
     fetch: function () {
       this.startTime = new Date().getTime();
-      return Backbone.Collection.prototype.fetch.call(this);
+      return FauxtonAPI.Collection.prototype.fetch.call(this);
     },
 
     allDocs: function(){
@@ -568,7 +568,7 @@ function(app, FauxtonAPI) {
   });
 
   
-  Documents.PouchIndexCollection = Backbone.Collection.extend({
+  Documents.PouchIndexCollection = FauxtonAPI.Collection.extend({
     model: Documents.ViewRow,
     documentation: function(){
       return "docs";

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/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 1510485..be9ce2f 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -182,7 +182,7 @@ function(app, FauxtonAPI, Documents, Databases) {
     },
 
     establish: function () {
-      return this.data.designDocs.fetch();
+      return this.data.designDocs.fetchOnce();
     },
 
     allDocs: function(databaseName, options) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/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 298cfb4..5476203 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1803,11 +1803,31 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
   Views.Changes = FauxtonAPI.View.extend({
     template: "addons/documents/templates/changes",
 
+    initialize: function () {
+      var that = this;
+      this.listenTo( this.model.changes, 'change', function () {
+        console.log('render on change'); 
+        that.render();
+      });
+      this.listenTo( this.model.changes, 'cachesync', function () {
+        console.log('render on cachesync'); 
+        that.render();
+      });
+    },
+
     establish: function() {
-      return [ this.model.changes.fetch()];
+      return [ this.model.changes.fetchOnce({prefill: true,
+        success: function () {
+          console.log('hi ajax success');
+        },
+        prefillSuccess: function () {
+          console.log('hi prefill success');
+        }
+      })];
     },
 
     serialize: function () {
+      console.log('ss');
       return {
         changes: this.model.changes.toJSON(),
         database: this.model

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/src/fauxton/app/config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/config.js b/src/fauxton/app/config.js
index 98be9c6..a5d764f 100644
--- a/src/fauxton/app/config.js
+++ b/src/fauxton/app/config.js
@@ -30,7 +30,8 @@ require.config({
     spin: "../assets/js/libs/spin.min",
     d3: "../assets/js/libs/d3",
     "nv.d3": "../assets/js/libs/nv.d3",
-    "ace":"../assets/js/libs/ace"
+    "ace":"../assets/js/libs/ace",
+    "backbone.fetch-cache": "../assets/js/plugins/backbone.fetch-cache"
   },
 
   baseUrl: '/',

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index 53316bc..6fe3261 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -12,10 +12,12 @@
 
 define([
   "backbone",
-  "plugins/backbone.layoutmanager"
+  "plugins/backbone.layoutmanager",
+  "backbone.fetch-cache"
 ],
 
-function(Backbone) {
+function(Backbone, LayoutManager, BackboneCache) {
+  console.log(BackboneCache);
   var FauxtonAPI = {
     //add default objects
     router: {
@@ -67,16 +69,25 @@ function(Backbone) {
     }
   });
 
+
   FauxtonAPI.Model = Backbone.Model.extend({
-    fetchOnce: function (opt) {
-      var options = _.extend({}, opt);
 
-      if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
-        this._deferred = this.fetch();
-      }
+  });
+
+  FauxtonAPI.Collection = Backbone.Collection.extend({
 
-      return this._deferred;
+  });
+
+  var caching = {
+    fetchOnce: function (opts) {
+      var options = _.defaults(opts || {}, this.cache, {cache: true});
+      console.log('opts', options);
+      return this.fetch(options);
     }
+  };
+
+  _.each([FauxtonAPI.Collection, FauxtonAPI.Model], function (ctor) {
+    _.extend(ctor.prototype, caching);
   });
 
   var extensions = _.extend({}, Backbone.Events);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ed89f340/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/backbone.fetch-cache.js b/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
new file mode 100644
index 0000000..c86a8b9
--- /dev/null
+++ b/src/fauxton/assets/js/plugins/backbone.fetch-cache.js
@@ -0,0 +1,311 @@
+/*!
+  backbone.fetch-cache v1.3.0
+  by Andy Appleton - https://github.com/mrappleton/backbone-fetch-cache.git
+ */
+
+// AMD wrapper from https://github.com/umdjs/umd/blob/master/amdWebGlobal.js
+
+(function (root, factory) {
+  if (typeof define === 'function' && define.amd) {
+    // AMD. Register as an anonymous module and set browser global
+    define(['underscore', 'backbone', 'jquery'], function (_, Backbone, $) {
+      return (root.Backbone = factory(_, Backbone, $));
+    });
+  } else {
+    // Browser globals
+    root.Backbone = factory(root._, root.Backbone, root.jQuery);
+  }
+}(this, function (_, Backbone, $) {
+
+  // Setup
+  var superMethods = {
+    modelFetch: Backbone.Model.prototype.fetch,
+    modelSync: Backbone.Model.prototype.sync,
+    collectionFetch: Backbone.Collection.prototype.fetch
+  },
+  supportLocalStorage = (function() {
+    var supported = typeof window.localStorage !== 'undefined';
+    if (supported) {
+      try {
+        // impossible to write on some platforms when private browsing is on and
+        // throws an exception = local storage not supported.
+        localStorage.setItem("test_support", "test_support");
+        localStorage.removeItem("test_support");
+      } catch (e) {
+        supported = false;
+      }
+    }
+    return supported;
+  })();
+
+  Backbone.fetchCache = (Backbone.fetchCache || {});
+  Backbone.fetchCache._cache = (Backbone.fetchCache._cache || {});
+
+  Backbone.fetchCache.priorityFn = function(a, b) {
+    if (!a || !a.expires || !b || !b.expires) {
+      return a;
+    }
+
+    return a.expires - b.expires;
+  };
+
+  Backbone.fetchCache._prioritize = function() {
+    var sorted = _.values(this._cache).sort(this.priorityFn);
+    var index = _.indexOf(_.values(this._cache), sorted[0]);
+    return _.keys(this._cache)[index];
+  };
+
+  Backbone.fetchCache._deleteCacheWithPriority = function() {
+    Backbone.fetchCache._cache[this._prioritize()] = null;
+    delete Backbone.fetchCache._cache[this._prioritize()];
+    Backbone.fetchCache.setLocalStorage();
+  };
+
+  Backbone.fetchCache.getLocalStorageKey = function() {
+    return 'backboneCache';
+  };
+
+  if (typeof Backbone.fetchCache.localStorage === 'undefined') {
+    Backbone.fetchCache.localStorage = true;
+  }
+
+  // Shared methods
+  function getCacheKey(instance, opts) {
+    var url;
+
+    if(opts && opts.url) {
+      url = opts.url;
+    } else {
+      url = _.isFunction(instance.url) ? instance.url() : instance.url;
+    }
+
+    // Need url to use as cache key so return if we can't get it
+    if(!url) { return; }
+
+    if(opts && opts.data) {
+      return url + "?" + $.param(opts.data);
+    }
+    return url;
+  }
+
+  function setCache(instance, opts, attrs) {
+    opts = (opts || {});
+    var key = Backbone.fetchCache.getCacheKey(instance, opts),
+        expires = false;
+
+    // Need url to use as cache key so return if we can't get it
+    if (!key) { return; }
+
+    // Never set the cache if user has explicitly said not to
+    if (opts.cache === false) { return; }
+
+    // Don't set the cache unless cache: true or prefill: true option is passed
+    if (!(opts.cache || opts.prefill)) { return; }
+
+    if (opts.expires !== false) {
+      expires = (new Date()).getTime() + ((opts.expires || 5 * 60) * 1000);
+    }
+
+    Backbone.fetchCache._cache[key] = {
+      expires: expires,
+      value: attrs
+    };
+
+    Backbone.fetchCache.setLocalStorage();
+  }
+
+  function clearItem(key) {
+    if (_.isFunction(key)) { key = key(); }
+    delete Backbone.fetchCache._cache[key];
+    Backbone.fetchCache.setLocalStorage();
+  }
+
+  function setLocalStorage() {
+    if (!supportLocalStorage || !Backbone.fetchCache.localStorage) { return; }
+    try {
+      localStorage.setItem(Backbone.fetchCache.getLocalStorageKey(), JSON.stringify(Backbone.fetchCache._cache));
+    } catch (err) {
+      var code = err.code || err.number || err.message;
+      if (code === 22) {
+        this._deleteCacheWithPriority();
+      } else {
+        throw(err);
+      }
+    }
+  }
+
+  function getLocalStorage() {
+    if (!supportLocalStorage || !Backbone.fetchCache.localStorage) { return; }
+    var json = localStorage.getItem(Backbone.fetchCache.getLocalStorageKey()) || '{}';
+    Backbone.fetchCache._cache = JSON.parse(json);
+  }
+
+  function nextTick(fn) {
+    return window.setTimeout(fn, 0);
+  }
+
+  // Instance methods
+  Backbone.Model.prototype.fetch = function(opts) {
+    opts = _.defaults(opts || {}, { parse: true });
+    var key = Backbone.fetchCache.getCacheKey(this, opts),
+        data = Backbone.fetchCache._cache[key],
+        expired = false,
+        attributes = false,
+        deferred = new $.Deferred(),
+        self = this;
+
+    function setData() {
+      if (opts.parse) {
+        attributes = self.parse(attributes, opts);
+      }
+
+      self.set(attributes, opts);
+      if (_.isFunction(opts.prefillSuccess)) { opts.prefillSuccess(self, attributes, opts); }
+
+      // Trigger sync events
+      self.trigger('cachesync', self, attributes, opts);
+      self.trigger('sync', self, attributes, opts);
+
+      // Notify progress if we're still waiting for an AJAX call to happen...
+      if (opts.prefill) { deferred.notify(self); }
+      // ...finish and return if we're not
+      else {
+        if (_.isFunction(opts.success)) { opts.success(self, attributes, opts); }
+        deferred.resolve(self);
+      }
+    }
+
+    if (data) {
+      expired = data.expires;
+      expired = expired && data.expires < (new Date()).getTime();
+      attributes = data.value;
+    }
+
+    if (!expired && (opts.cache || opts.prefill) && attributes) {
+      // Ensure that cache resolution adhers to async option, defaults to true.
+      if (opts.async == null) { opts.async = true; }
+
+      if (opts.async) {
+        nextTick(setData);
+      } else {
+        setData();
+      }
+
+      if (!opts.prefill) {
+        return deferred.promise();
+      }
+    }
+
+    // Delegate to the actual fetch method and store the attributes in the cache
+    superMethods.modelFetch.apply(this, arguments)
+      // resolve the returned promise when the AJAX call completes
+      .done( _.bind(deferred.resolve, this, this) )
+      // Set the new data in the cache
+      .done( _.bind(Backbone.fetchCache.setCache, null, this, opts) )
+      // Reject the promise on fail
+      .fail( _.bind(deferred.reject, this, this) );
+
+    // return a promise which provides the same methods as a jqXHR object
+    return deferred.promise();
+  };
+
+  // Override Model.prototype.sync and try to clear cache items if it looks
+  // like they are being updated.
+  Backbone.Model.prototype.sync = function(method, model, options) {
+    // Only empty the cache if we're doing a create, update, patch or delete.
+    if (method === 'read') {
+      return superMethods.modelSync.apply(this, arguments);
+    }
+
+    var collection = model.collection,
+        keys = [],
+        i, len;
+
+    // Build up a list of keys to delete from the cache, starting with this
+    keys.push(Backbone.fetchCache.getCacheKey(model, options));
+
+    // If this model has a collection, also try to delete the cache for that
+    if (!!collection) {
+      keys.push(Backbone.fetchCache.getCacheKey(collection));
+    }
+
+    // Empty cache for all found keys
+    for (i = 0, len = keys.length; i < len; i++) { clearItem(keys[i]); }
+
+    return superMethods.modelSync.apply(this, arguments);
+  };
+
+  Backbone.Collection.prototype.fetch = function(opts) {
+    opts = _.defaults(opts || {}, { parse: true });
+    var key = Backbone.fetchCache.getCacheKey(this, opts),
+        data = Backbone.fetchCache._cache[key],
+        expired = false,
+        attributes = false,
+        deferred = new $.Deferred(),
+        self = this;
+
+    function setData() {
+      self[opts.reset ? 'reset' : 'set'](attributes, opts);
+      if (_.isFunction(opts.prefillSuccess)) { opts.prefillSuccess(self); }
+
+      // Trigger sync events
+      self.trigger('cachesync', self, attributes, opts);
+      self.trigger('sync', self, attributes, opts);
+
+      // Notify progress if we're still waiting for an AJAX call to happen...
+      if (opts.prefill) { deferred.notify(self); }
+      // ...finish and return if we're not
+      else {
+        if (_.isFunction(opts.success)) { opts.success(self, attributes, opts); }
+        deferred.resolve(self);
+      }
+    }
+
+    if (data) {
+      expired = data.expires;
+      expired = expired && data.expires < (new Date()).getTime();
+      attributes = data.value;
+    }
+
+    if (!expired && (opts.cache || opts.prefill) && attributes) {
+      // Ensure that cache resolution adhers to async option, defaults to true.
+      if (opts.async == null) { opts.async = true; }
+
+      if (opts.async) {
+        nextTick(setData);
+      } else {
+        setData();
+      }
+
+      if (!opts.prefill) {
+        return deferred.promise();
+      }
+    }
+
+    // Delegate to the actual fetch method and store the attributes in the cache
+    superMethods.collectionFetch.apply(this, arguments)
+      // resolve the returned promise when the AJAX call completes
+      .done( _.bind(deferred.resolve, this, this) )
+      // Set the new data in the cache
+      .done( _.bind(Backbone.fetchCache.setCache, null, this, opts) )
+      // Reject the promise on fail
+      .fail( _.bind(deferred.reject, this, this) );
+
+    // return a promise which provides the same methods as a jqXHR object
+    return deferred.promise();
+  };
+
+  // Prime the cache from localStorage on initialization
+  getLocalStorage();
+
+  // Exports
+
+  Backbone.fetchCache._superMethods = superMethods;
+  Backbone.fetchCache.setCache = setCache;
+  Backbone.fetchCache.getCacheKey = getCacheKey;
+  Backbone.fetchCache.clearItem = clearItem;
+  Backbone.fetchCache.setLocalStorage = setLocalStorage;
+  Backbone.fetchCache.getLocalStorage = getLocalStorage;
+
+  return Backbone;
+}));


[09/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Add backbone.fetch-cache to license and notice


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b3bb78e7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b3bb78e7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b3bb78e7

Branch: refs/heads/paginate-api-options
Commit: b3bb78e7b54f8755faef1b8fa7ac26ceb49a0395
Parents: fb633cb
Author: Garren Smith <ga...@gmail.com>
Authored: Fri Feb 7 15:13:23 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Feb 7 15:13:23 2014 +0200

----------------------------------------------------------------------
 LICENSE | 24 ++++++++++++++++++++++++
 NOTICE  |  4 ++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b3bb78e7/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 7cd4f81..6ae7303 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1104,3 +1104,27 @@ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
+
+for src/fauxton/asserts/js/plugins/backbone.fetch-cache.js
+
+The MIT License (MIT)
+
+Copyright (c) 2012-2013 Andrew Appleton, http://floatleft.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b3bb78e7/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 0fa5d8d..fda3caf 100644
--- a/NOTICE
+++ b/NOTICE
@@ -185,3 +185,7 @@ This product also includes the following third-party components:
  * ace editor https://github.com/ajaxorg/ace
 
    Copyright (c) 2010, Ajax.org B.V.
+
+ * src/fauxton/asserts/js/plugins/backbone.fetch-cache.js
+
+   Copyright (c) 2012-2013 Andrew Appleton, http://floatleft.com


[22/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Paginiation with no limit


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/33118afc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/33118afc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/33118afc

Branch: refs/heads/paginate-api-options
Commit: 33118afc2d692d50e71d2b0d5ac3be55ed00b04c
Parents: b95251c
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Feb 11 17:24:02 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 17:24:02 2014 +0200

----------------------------------------------------------------------
 .../app/addons/databases/templates/item.html    |  2 +-
 src/fauxton/app/addons/databases/views.js       |  3 +-
 src/fauxton/app/addons/documents/routes.js      | 44 ++++++++++++---
 .../documents/templates/all_docs_number.html    | 22 ++++----
 .../app/addons/documents/templates/sidebar.html |  4 +-
 src/fauxton/app/addons/documents/views.js       | 58 +++++++++-----------
 src/fauxton/app/addons/fauxton/components.js    | 45 +++++++++------
 7 files changed, 104 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/33118afc/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
index e2f8071..549f421 100644
--- a/src/fauxton/app/addons/databases/templates/item.html
+++ b/src/fauxton/app/addons/databases/templates/item.html
@@ -13,7 +13,7 @@ the License.
 -->
 
 <td>
-  <a href="#/database/<%=encoded%>/_all_docs?limit=<%=docLimit%>"><%= database.get("name") %></a>
+  <a href="#/database/<%=encoded%>/_all_docs"><%= 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/33118afc/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 7f23d65..a56267f 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -31,8 +31,7 @@ function(app, Components, FauxtonAPI, Databases) {
       
       return {
         encoded: app.utils.safeURLName(this.model.get("name")),
-        database: this.model,
-        docLimit: Databases.DocLimit
+        database: this.model
       };
     }
   });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33118afc/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 06db528..047f998 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -187,8 +187,19 @@ function(app, FauxtonAPI, Documents, Databases) {
     },
 
     allDocs: function(databaseName, options) {
-      var docOptions = app.getParams(options);
+      var docOptions = app.getParams(options),
+          docLimit;
 
+      if (this.eventAllDocs) {
+        this.eventAllDocs = false;
+        return;
+      }
+
+      if (docOptions.limit) {
+        docLimit = docOptions.limit;
+      }
+
+      docOptions.limit = 20; //default per page
       this.data.database.buildAllDocs(docOptions);
 
       if (docOptions.startkey && docOptions.startkey.indexOf('_design') > -1) {
@@ -212,7 +223,7 @@ function(app, FauxtonAPI, Documents, Databases) {
 
       this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
         collection: this.data.database.allDocs,
-        docLimit: parseInt(docOptions.limit, 10)
+        docLimit: parseInt(docLimit, 10)
       }));
 
       this.crumbs = [
@@ -224,8 +235,14 @@ function(app, FauxtonAPI, Documents, Databases) {
 
     viewFn: function (databaseName, ddoc, view) {
       var params = app.getParams(),
-          decodeDdoc = decodeURIComponent(ddoc);
+          decodeDdoc = decodeURIComponent(ddoc),
+          docLimit;
+
+      if (params.limit) {
+        docLimit = params.limit;
+      } 
 
+      params.limit = 20; //default per page
       view = view.replace(/\?.*$/,'');
 
       this.data.indexedDocs = new Documents.IndexCollection(null, {
@@ -245,7 +262,7 @@ function(app, FauxtonAPI, Documents, Databases) {
         model: this.data.database,
         ddocs: this.data.designDocs,
         viewName: view,
-        params: params,
+        params: _.extend(params, {limit: docLimit}),
         newView: false,
         database: this.data.database,
         ddocInfo: ddocInfo
@@ -258,7 +275,8 @@ function(app, FauxtonAPI, Documents, Databases) {
         collection: this.data.indexedDocs,
         nestedView: Documents.Views.Row,
         viewList: true,
-        ddocInfo: ddocInfo
+        ddocInfo: ddocInfo,
+        docLimit: parseInt(docLimit, 10)
       }));
 
       this.sidebar.setSelectedTab(app.utils.removeSpecialCharacters(ddoc) + '_' + app.utils.removeSpecialCharacters(view));
@@ -296,14 +314,22 @@ function(app, FauxtonAPI, Documents, Databases) {
     updateAllDocsFromView: function (event) {
       var view = event.view,
           docOptions = app.getParams(),
-          ddoc = event.ddoc;
+          ddoc = event.ddoc,
+          docLimit;
+
+      if (docOptions.limit) {
+        docLimit = docOptions.limit;
+      }
 
+      docOptions.limit = this.documentsView.perPage();
       this.documentsView && this.documentsView.remove();
 
       if (event.allDocs) {
+        this.eventAllDocs = true; // this is horrible. But I cannot get the trigger not to fire the route!
         this.data.database.buildAllDocs(docOptions);
         this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
-          collection: this.data.database.allDocs
+          collection: this.data.database.allDocs,
+          docLimit: parseInt(docLimit, 10)
         }));
         return;
       }
@@ -319,7 +345,8 @@ function(app, FauxtonAPI, Documents, Databases) {
         database: this.data.database,
         collection: this.data.indexedDocs,
         nestedView: Documents.Views.Row,
-        viewList: true
+        viewList: true,
+        docLimit: parseInt(docLimit, 10)
       }));
 
       this.apiUrl = [this.data.indexedDocs.url("apiurl"), "docs"];
@@ -352,6 +379,7 @@ function(app, FauxtonAPI, Documents, Databases) {
 
     paginate: function (options) {
       this.documentsView.forceRender();
+
       if (options.direction === 'next') {
         this.documentsView.collection.skipFirstItem = true;
         this.documentsView.collection.nextPage(options.perPage);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33118afc/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 fb9ea11..0461a4b 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_number.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html
@@ -21,15 +21,15 @@ Showing <%=pageStart%> - <%= pageEnd %>
 <% } %>
 
 <div id="per-page">
-<label id="per-page" class="drop-down inline">
-  Per page:
-  <select id="select-per-page" name="per-page" class="input-small">
-    <option value="5">5</option>
-    <option value="10">10</option>
-    <option value="20">20</option>
-    <option value="30">30</option>
-    <option value="50">50</option>
-    <option value="100">100</option>
-  </select>
-</label>
+  <label id="per-page" class="drop-down inline">
+    Per page:
+    <select id="select-per-page" name="per-page" class="input-small">
+      <option value="5">5</option>
+      <option value="10">10</option>
+      <option value="20">20</option>
+      <option value="30">30</option>
+      <option value="50">50</option>
+      <option value="100">100</option>
+    </select>
+  </label>
 </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33118afc/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
index 7358960..750cd30 100644
--- a/src/fauxton/app/addons/documents/templates/sidebar.html
+++ b/src/fauxton/app/addons/documents/templates/sidebar.html
@@ -55,8 +55,8 @@ the License.
 
   <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>
+      <li class="active"><a id="all-docs" href="#<%= database.url('index') %>" class="toggle-view"> All documents</a></li>
+      <li><a id="design-docs" href='#<%= database.url("index") %>?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>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33118afc/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 41b375c..3b334cd 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -416,8 +416,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       this.newView = options.newView || false;
       this.pagination = options.pagination;
       
-      this.perPage = 20;
-      
+      this._perPage = 20;
 
       this.listenTo(this.collection, 'totalRows:decrement', this.render);
     },
@@ -427,13 +426,13 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     },
 
     updatePerPage: function (event) {
-      this.perPage = parseInt(this.$('#select-per-page :selected').val(), 10);
-      FauxtonAPI.triggerRouteEvent('perPageChange', this.perPage);
-      this.pagination.updatePerPage(this.perPage);
+      this._perPage = parseInt(this.$('#select-per-page :selected').val(), 10);
+      this.pagination.updatePerPage(this.perPage());
+      FauxtonAPI.triggerRouteEvent('perPageChange', this.pagination.documentsLeftToFetch());
     },
 
     afterRender: function () {
-      this.$('option[value="' + this.perPage + '"]').attr('selected', "selected");
+      this.$('option[value="' + this.perPage() + '"]').attr('selected', "selected");
     },
 
     serialize: function () {
@@ -463,6 +462,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         pageStart: pageStart,
         pageEnd: pageEnd
       };
+    },
+
+    perPage: function () {
+      return this._perPage;
     }
 
   });
@@ -496,19 +499,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         database: this.database,
         eventer: this.eventer
       }));
-
-      /*this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
-        hasReduce: false,
-        eventer:  this.eventer
-       }));*/
-
-      //this.$('#query').hide();
     },
 
     afterRender: function () {
       if (this.params) {
         this.advancedOptions.updateFromParams(this.params);
-        //this.advancedOptionsMenu.updateFromParams(this.params);
       }
 
     },
@@ -541,9 +536,12 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       }
 
       var fragment = window.location.hash.replace(/\?.*$/, '');
-      fragment = fragment + '?' + $.param(params);
-      FauxtonAPI.navigate(fragment, {trigger: false});
 
+      if (!_.isEmpty(params)) {
+        fragment = fragment + '?' + $.param(params);
+      }
+
+      FauxtonAPI.navigate(fragment, {trigger: false});
       FauxtonAPI.triggerRouteEvent('updateAllDocs', {allDocs: true});
     },
 
@@ -707,6 +705,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
 
     afterRender: function(){
       prettyPrint();
+    },
+
+    perPage: function () {
+      return this.allDocsNumber.perPage();
     }
   });
 
@@ -1143,10 +1145,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       var $form = this.$(".view-query-update");
       // Ignore params without a value
       var params = _.reduce($form.serializeArray(), function(params, param) {
-        if (!params.value) { return params; }
+        if (!param.value) { return params; }
         if (param.name === "limit" && param.value === 'None') { return params; }
 
-        params.push(param.value);
+        params.push(param);
         return params;
       }, []);
 
@@ -1210,6 +1212,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         switch (key) {
           case "limit":
           case "group_level":
+            if (!val) { return; }
             $form.find("select[name='"+key+"']").val(val);
           break;
           case "include_docs":
@@ -1470,9 +1473,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
             that.advancedOptions.renderOnUpdatehasReduce(that.hasReduce());
           }
 
-          //that.advancedOptionsMenu.setHasReduce(that.hasReduce());
-          //that.advancedOptionsMenu.render();
-
           FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: ddocName, view: viewName});
 
         }, function(xhr) {
@@ -1526,9 +1526,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       }
 
        var fragment = window.location.hash.replace(/\?.*$/, '');
-       fragment = fragment + '?' + $.param(params);
-       FauxtonAPI.navigate(fragment, {trigger: false});
+       if (!_.isEmpty(params)) {
+        fragment = fragment + '?' + $.param(params);
+       }
 
+       FauxtonAPI.navigate(fragment, {trigger: false});
        FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: this.ddocID, view: this.viewName});
     },
 
@@ -1713,11 +1715,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
           hasReduce: this.hasReduce(),
           eventer: this.eventer
         }));
-
-        /*this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({
-          hasReduce: this.hasReduce(),
-          eventer:  this.eventer
-         }));*/
       }
 
     },
@@ -1725,7 +1722,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     afterRender: function() {
       if (this.params && !this.newView) {
         this.advancedOptions.updateFromParams(this.params);
-        //this.advancedOptionsMenu.updateFromParams(this.params);
       }
 
       this.designDocSelector.updateDesignDoc();
@@ -1737,7 +1733,6 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         this.$('#index-nav').parent().removeClass('active');
       }
 
-
     },
 
     showEditors: function () {
@@ -1828,11 +1823,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       return {
         changes_url: '#' + this.database.url('changes'),
         permissions_url: '#' + this.database.url('app') + '/permissions',
-        db_url: '#' + this.database.url('index') + '?limit=' + Databases.DocLimit,
+        db_url: '#' + this.database.url('index'),
         database: this.collection.database,
         database_url: '#' + this.database.url('app'),
         docLinks: docLinks,
-        docLimit: Databases.DocLimit,
         addLinks: addLinks,
         newLinks: newLinks,
         extensionList: extensionList > 0

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33118afc/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 130d3c7..c363a96 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -71,15 +71,15 @@ function(app, FauxtonAPI, ace, spin) {
       this.nextUrlfn = options.nextUrlfn;
       this.scrollToSelector = options.scrollToSelector;
       _.bindAll(this);
-      this.pageNumber = 0;
+      this._pageNumber = [];
       this._pageStart = 1;
       this.perPage = 20;
-      this.docLimit = options.docLimit || 100;
+      this.docLimit = options.docLimit || 1000000;
       this.paramsHistory = [];
     },
 
     canShowPreviousfn: function () {
-      if (this.pageNumber <= 0) {
+      if (this._pageStart === 1) {
         return false;
       }
       return true;
@@ -102,8 +102,7 @@ function(app, FauxtonAPI, ace, spin) {
       event.stopPropagation();
       if (!this.canShowPreviousfn()) { return; }
 
-      this.pageNumber = this.pageNumber -1;
-      this.decPageStart();
+      this.decPageNumber();
 
       FauxtonAPI.triggerRouteEvent('paginate', {
        direction: 'previous',
@@ -112,25 +111,28 @@ function(app, FauxtonAPI, ace, spin) {
       });
     },
 
+    documentsLeftToFetch: function () {
+      var documentsLeftToFetch = this.docLimit - this.totalDocsViewed(),
+          limit = this.perPage;
+
+      if (documentsLeftToFetch < this.perPage ) {
+        limit = documentsLeftToFetch;
+      }
+
+      return limit;
+    },
+
     nextClicked: function (event) {
       event.preventDefault();
       event.stopPropagation();
       if (!this.canShowNextfn()) { return; }
 
       this.paramsHistory.push(_.clone(this.collection.params));
-      this.pageNumber = this.pageNumber + 1;
-      this.incPageStart();
-
-      var documentsLeftToFetch = this.docLimit - (this.pageNumber * this.perPage),
-          limit = this.perPage;
-
-      if (documentsLeftToFetch < this.perPage) {
-        limit = documentsLeftToFetch;
-      }
+      this.incPageNumber();
 
       FauxtonAPI.triggerRouteEvent('paginate', {
        direction: 'next',
-       perPage: limit
+       perPage: this.documentsLeftToFetch()
       });
 
     },
@@ -150,11 +152,19 @@ function(app, FauxtonAPI, ace, spin) {
       return this._pageStart - 1;
     },
 
-    incPageStart: function () {
+    incPageNumber: function () {
+      this._pageNumber.push({perPage: this.perPage});
       this._pageStart = this._pageStart + this.perPage;
     },
 
-    decPageStart: function () {
+    totalDocsViewed: function () {
+      return _.reduce(this._pageNumber, function (total, value) {
+        return total + value.perPage;
+      }, 0);
+    },
+
+    decPageNumber: function () {
+      this._pageNumber.pop();
       var val = this._pageStart - this.perPage;
       if (val < 1) {
         this._pageStart = 1;
@@ -175,7 +185,6 @@ function(app, FauxtonAPI, ace, spin) {
 
       return this.page() + this.perPage;
     }
-
   });
 
   //TODO allow more of the typeahead options.


[19/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
More working


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/144144b7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/144144b7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/144144b7

Branch: refs/heads/paginate-api-options
Commit: 144144b74fd63876809d968f124e3b2f2da68a25
Parents: 058fc3b
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Jan 29 17:44:49 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:25 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js |  2 ++
 src/fauxton/app/addons/fauxton/components.js  | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/144144b7/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 15d4d30..72cdb66 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -284,6 +284,8 @@ function(app, FauxtonAPI) {
       this.totalRowsToPaginate = 100;
       this.on("remove",this.decrementTotalRows , this);
       this.perPageLimit = options.perPageLimit || 20;
+
+      this.params.limit = this.perPageLimit; 
     },
 
     url: function(context) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/144144b7/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 ec10132..fd45aa2 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -89,7 +89,6 @@ function(app, FauxtonAPI, ace, spin) {
         return false;
       }
 
-      console.log(this.pageStart() + this.perPage, this.docLimit);
       if ((this.pageStart() + this.perPage) >= this.docLimit) {
         return false;
       }
@@ -119,9 +118,16 @@ function(app, FauxtonAPI, ace, spin) {
       this.pageNumber = this.pageNumber + 1;
       this.incPageStart();
 
+      var documentsLeftToFetch = this.docLimit - (this.pageNumber * this.perPage),
+          limit = this.perPage;
+
+      if (documentsLeftToFetch < this.perPage) {
+        limit = documentsLeftToFetch;
+      }
+
       FauxtonAPI.triggerRouteEvent('paginate', {
        direction: 'next',
-       perPage: this.perPage
+       perPage: limit
       });
     },
 
@@ -163,6 +169,7 @@ function(app, FauxtonAPI, ace, spin) {
         return this.page() + this.collection.length;
       }
 
+      return this.page() + this.perPage;
     }
 
   });


[02/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Merge branch 'added-documentation-fixes' of https://github.com/andywenk/couchdb


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/91856315
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/91856315
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/91856315

Branch: refs/heads/paginate-api-options
Commit: 918563154d5f93a7f979b0b344c031be761a89b2
Parents: b68eb17 be483fd
Author: Andy Wenk <an...@apache.org>
Authored: Mon Feb 3 13:08:46 2014 +0100
Committer: Andy Wenk <an...@apache.org>
Committed: Mon Feb 3 13:08:46 2014 +0100

----------------------------------------------------------------------
 share/doc/src/api/document/common.rst | 19 ++++---
 share/doc/src/json-structure.rst      | 84 +++++++++++++++---------------
 2 files changed, 54 insertions(+), 49 deletions(-)
----------------------------------------------------------------------



[03/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
fixed .css concat ordering in index.css

This change removes the loading of .css files
from /addons/**/assets/css/*.css. Putting those
back is an option, but since unused at present
I saw it as a separate case for adding back
if/when desired.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b8fe3cb1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b8fe3cb1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b8fe3cb1

Branch: refs/heads/paginate-api-options
Commit: b8fe3cb10299cbabf4274d6071368734c3880511
Parents: 8462b9d
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Feb 3 11:28:09 2014 -0500
Committer: BigBlueHat <by...@bigbluehat.com>
Committed: Mon Feb 3 11:29:00 2014 -0500

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8fe3cb1/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 2c5a249..554eccb 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -64,7 +64,10 @@ module.exports = function(grunt) {
           "dist/debug/css/fauxton.css": "assets/less/fauxton.less"
         }
       },
-      img: ["assets/img/**"]
+      img: ["assets/img/**"],
+      // used in concat:index_css to keep file ordering intact
+      // fauxton.css should load first
+      css: ["dist/debug/css/fauxton.css"]
     };
     helper.processAddons(function(addon){
       // Less files from addons
@@ -75,6 +78,7 @@ module.exports = function(grunt) {
         theAssets.less.paths.push(lessPath);
         theAssets.less.files["dist/debug/css/" + addon.name + ".css"] =
           lessPath + "/" + addon.name + ".less";
+        theAssets.css.push("dist/debug/css/" + addon.name + ".css");
       }
       // Images
       root = addon.path || "app/addons/" + addon.name;
@@ -210,7 +214,7 @@ module.exports = function(grunt) {
       },
 
       index_css: {
-        src: ["dist/debug/css/*.css", '!dist/debug/css/index.css', 'assets/css/*.css'],
+        src: assets.css,
         dest: 'dist/debug/css/index.css'
       },
 


[17/22] couchdb commit: updated refs/heads/paginate-api-options to 33118af

Posted by ga...@apache.org.
Working on doc limit


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/058fc3bb
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/058fc3bb
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/058fc3bb

Branch: refs/heads/paginate-api-options
Commit: 058fc3bb278e39965a36b143f3066c697528e940
Parents: 6a22501
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Jan 29 15:48:34 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Feb 11 10:14:25 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js | 5 ++++-
 src/fauxton/app/addons/documents/routes.js    | 3 ++-
 src/fauxton/app/addons/documents/views.js     | 4 +++-
 src/fauxton/app/addons/fauxton/components.js  | 7 +++++++
 4 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/058fc3bb/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 a1f43a5..15d4d30 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -279,10 +279,11 @@ function(app, FauxtonAPI) {
     },
     initialize: function(_models, options) {
       this.database = options.database;
-      this.params = options.params;
+      this.params = _.clone(options.params);
       this.skipFirstItem = false;
       this.totalRowsToPaginate = 100;
       this.on("remove",this.decrementTotalRows , this);
+      this.perPageLimit = options.perPageLimit || 20;
     },
 
     url: function(context) {
@@ -315,6 +316,8 @@ function(app, FauxtonAPI) {
     },
 
     updateLimit: function (limit) {
+      this.perPageLimit = limit;
+
       if (this.params.startkey_docid && this.params.startkey) {
         //we are paginating so set limit + 1
         this.params.limit = limit + 1;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/058fc3bb/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 4275006..f4700d4 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -211,7 +211,8 @@ function(app, FauxtonAPI, Documents, Databases) {
       }));
 
       this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
-        collection: this.data.database.allDocs
+        collection: this.data.database.allDocs,
+        docLimit: parseInt(docOptions.limit, 10)
       }));
 
       this.crumbs = [

http://git-wip-us.apache.org/repos/asf/couchdb/blob/058fc3bb/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 ee4d30b..265ffe2 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -583,6 +583,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         this.ddocID = options.ddocInfo.id;
       }
       this.newView = options.newView || false;
+      this.docLimit = options.docLimit;
       this.expandDocs = true;
     },
 
@@ -668,7 +669,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
 
       this.pagination = new Components.IndexPagination({
         collection: this.collection,
-        scrollToSelector: '#dashboard-content'
+        scrollToSelector: '#dashboard-content',
+        docLimit: this.docLimit
       });
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/058fc3bb/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 eb1142c..ec10132 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -74,6 +74,7 @@ function(app, FauxtonAPI, ace, spin) {
       this.pageNumber = 0;
       this._pageStart = 1;
       this.perPage = 20;
+      this.docLimit = options.docLimit || 100;
     },
 
     canShowPreviousfn: function () {
@@ -87,6 +88,12 @@ function(app, FauxtonAPI, ace, spin) {
       if (this.collection.length < (this.perPage -1)) {
         return false;
       }
+
+      console.log(this.pageStart() + this.perPage, this.docLimit);
+      if ((this.pageStart() + this.perPage) >= this.docLimit) {
+        return false;
+      }
+
       return true;
     },