You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by dc...@apache.org on 2014/03/16 17:57:41 UTC

[01/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Repository: couchdb
Updated Branches:
  refs/heads/2041-update-ibrowse 948e7d9a6 -> b63f393b8 (forced update)


Fauxton: Gruntfile fix more path.existsSync


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

Branch: refs/heads/2041-update-ibrowse
Commit: 18cf47aa36285b6f9c0ecfe5248db2c9acefa588
Parents: c59dab8
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Wed Mar 5 22:12:47 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 6 10:11:50 2014 -0500

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/18cf47aa/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index c087afa..348fa45 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -18,7 +18,7 @@
 module.exports = function(grunt) {
   var helper = require('./tasks/helper').init(grunt),
   _ = grunt.util._,
-  path = require('path');
+  fs = require('fs');
 
   var couch_config = function () {
 
@@ -73,7 +73,7 @@ module.exports = function(grunt) {
       // Less files from addons
       var root = addon.path || "app/addons/" + addon.name;
       var lessPath = root + "/assets/less";
-      if(path.existsSync(lessPath)){
+      if(fs.existsSync(lessPath)){
         // .less files exist for this addon
         theAssets.less.paths.push(lessPath);
         theAssets.less.files["dist/debug/css/" + addon.name + ".css"] =
@@ -83,7 +83,7 @@ module.exports = function(grunt) {
       // Images
       root = addon.path || "app/addons/" + addon.name;
       var imgPath = root + "/assets/img";
-      if(path.existsSync(imgPath)){
+      if(fs.existsSync(imgPath)){
         theAssets.img.push(imgPath + "/**");
       }
     });


[02/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: Fix placeholder for Username

The one for Password has no `:` so removing them makes the view
more consistent (and looks maybe better)


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

Branch: refs/heads/2041-update-ibrowse
Commit: c59dab8d508fd3871a145ef099fd349bb9bc7064
Parents: 4e60f0b
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Wed Mar 5 22:19:19 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 6 10:11:50 2014 -0500

----------------------------------------------------------------------
 src/fauxton/app/addons/auth/templates/create_admin.html | 2 +-
 src/fauxton/app/addons/auth/templates/login.html        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c59dab8d/src/fauxton/app/addons/auth/templates/create_admin.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/create_admin.html b/src/fauxton/app/addons/auth/templates/create_admin.html
index 8f4ed2c..48333df 100644
--- a/src/fauxton/app/addons/auth/templates/create_admin.html
+++ b/src/fauxton/app/addons/auth/templates/create_admin.html
@@ -24,7 +24,7 @@ the License.
     configuration.
   </p>
   <form id="create-admin-form">
-    <input id="username" type="text" name="name" placeholder= "Username:" size="24">
+    <input id="username" type="text" name="name" placeholder="Username" size="24">
     <br/>
     <input id="password" type="password" name="password" placeholder= "Password" size="24">
     <p class="help-block">Non-admin users have read and write access to all databases, which

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c59dab8d/src/fauxton/app/addons/auth/templates/login.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/login.html b/src/fauxton/app/addons/auth/templates/login.html
index a57f3f0..eb20825 100644
--- a/src/fauxton/app/addons/auth/templates/login.html
+++ b/src/fauxton/app/addons/auth/templates/login.html
@@ -16,7 +16,7 @@ the License.
     <p class="help-block">
       Login to CouchDB with your name and password.
     </p>
-    <input id="username" type="text" name="name" placeholder= "Username:" size="24">
+    <input id="username" type="text" name="name" placeholder="Username" size="24">
     <br/>
     <input id="password" type="password" name="password" placeholder= "Password" size="24">
     <br/>


[29/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
ibrowse: update to 4.1.0

- for COUCHDB-2041
- ibrowse tagged 4.1.0 sha#7871e2e


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

Branch: refs/heads/2041-update-ibrowse
Commit: b63f393b8fad85bd4fca022a86227e4540c48a6b
Parents: 510070c
Author: Dave Cottlehuber <dc...@apache.org>
Authored: Wed Jan 29 11:05:23 2014 +0100
Committer: Dave Cottlehuber <dc...@apache.org>
Committed: Sun Mar 16 17:52:41 2014 +0100

----------------------------------------------------------------------
 NOTICE                              |   2 +-
 src/ibrowse/ibrowse.app.in          |   2 +-
 src/ibrowse/ibrowse.erl             |  67 ++++--
 src/ibrowse/ibrowse_http_client.erl | 358 +++++++++++++++++++------------
 src/ibrowse/ibrowse_lb.erl          |  28 ++-
 src/ibrowse/ibrowse_lib.erl         |   7 +-
 src/ibrowse/ibrowse_socks5.erl      | 143 ++++--------
 7 files changed, 331 insertions(+), 276 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index fda3caf..aa39311 100644
--- a/NOTICE
+++ b/NOTICE
@@ -36,7 +36,7 @@ This product also includes the following third-party components:
 
  * ibrowse (http://github.com/cmullaparthi/ibrowse/tree/master)
 
-   Copyright 2005-2012, Chandrashekhar Mullaparthi
+   Copyright 2005-2014, Chandrashekhar Mullaparthi
 
  * Erlang OAuth (http://github.com/tim/erlang-oauth)
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/src/ibrowse/ibrowse.app.in
----------------------------------------------------------------------
diff --git a/src/ibrowse/ibrowse.app.in b/src/ibrowse/ibrowse.app.in
index 1d88084..f318aef 100644
--- a/src/ibrowse/ibrowse.app.in
+++ b/src/ibrowse/ibrowse.app.in
@@ -1,6 +1,6 @@
 {application, ibrowse,
         [{description, "Erlang HTTP client application"},
-         {vsn, "4.0.1"},
+         {vsn, "4.1.0"},
          {registered, [ibrowse_sup, ibrowse]},
          {applications, [kernel,stdlib]},
 	 {env, []},

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/src/ibrowse/ibrowse.erl
----------------------------------------------------------------------
diff --git a/src/ibrowse/ibrowse.erl b/src/ibrowse/ibrowse.erl
index 80a4282..fc90dc6 100644
--- a/src/ibrowse/ibrowse.erl
+++ b/src/ibrowse/ibrowse.erl
@@ -6,7 +6,7 @@
 %%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi <ch...@t-mobile.co.uk>
 %%%-------------------------------------------------------------------
 %% @author Chandrashekhar Mullaparthi <chandrashekhar dot mullaparthi at gmail dot com>
-%% @copyright 2005-2012 Chandrashekhar Mullaparthi
+%% @copyright 2005-2014 Chandrashekhar Mullaparthi
 %% @doc The ibrowse application implements an HTTP 1.1 client in erlang. This
 %% module implements the API of the HTTP client. There is one named
 %% process called 'ibrowse' which assists in load balancing and maintaining configuration. There is one load balancing process per unique webserver. There is
@@ -158,7 +158,7 @@ stop() ->
 %% respHeader() = {headerName(), headerValue()}
 %% headerName() = string()
 %% headerValue() = string()
-%% response() = {ok, Status, ResponseHeaders, ResponseBody} | {ibrowse_req_id, req_id() } | {error, Reason}
+%% response() = {ok, Status, ResponseHeaders, ResponseBody} | {ok, Status, ResponseHeaders, ResponseBody} | {ibrowse_req_id, req_id() } | {error, Reason}
 %% req_id() = term()
 %% ResponseBody = string() | {file, Filename}
 %% Reason = term()
@@ -175,9 +175,11 @@ send_req(Url, Headers, Method) ->
 send_req(Url, Headers, Method, Body) ->
     send_req(Url, Headers, Method, Body, []).
 
-%% @doc Same as send_req/4. 
-%% For a description of SSL Options, look in the <a href="http://www.erlang.org/doc/apps/ssl/index.html">ssl</a> manpage. If the
-%% HTTP Version to use is not specified, the default is 1.1.
+%% @doc Same as send_req/4.
+
+%% For a description of SSL Options, look in the <a href="http://www.erlang.org/doc/apps/ssl/index.html">ssl</a> manpage.
+%% For a description of Process Options, look in the <a href="http://www.erlang.org/doc/man/gen_server.html">gen_server</a> manpage.
+%% If the HTTP Version to use is not specified, the default is 1.1.
 %% <br/>
 %% <ul>
 %% <li>The <code>host_header</code> option is useful in the case where ibrowse is
@@ -254,6 +256,8 @@ send_req(Url, Headers, Method, Body) ->
 %% to receive the raw data stream when the Transfer-Encoding of the server
 %% response is Chunked.
 %% </li>
+%% <li> The <code>return_raw_request</code> option enables the caller to get the exact request which was sent by ibrowse to the server, along with the response. When this option is used, the response for synchronous requests is a 5-tuple instead of the usual 4-tuple. For asynchronous requests, the calling process gets a message <code>{ibrowse_async_raw_req, Raw_req}</code>. 
+%% </li>
 %% </ul>
 %%
 %% @spec send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response()
@@ -286,7 +290,9 @@ send_req(Url, Headers, Method, Body) ->
 %%          {headers_as_is, boolean()}         |
 %%          {give_raw_headers, boolean()}      |
 %%          {preserve_chunked_encoding,boolean()}     |
-%%          {workaround, head_response_with_body}
+%%          {workaround, head_response_with_body}     |
+%%          {worker_process_options, list()} |
+%%          {return_raw_request, true}
 %%
 %% stream_to() = process() | {process(), once}
 %% process() = pid() | atom()
@@ -340,10 +346,12 @@ try_routing_request(Lb_pid, Parsed_url,
                     Max_pipeline_size,
                     {SSLOptions, IsSSL}, 
                     Headers, Method, Body, Options_1, Timeout, Try_count) when Try_count < 3 ->
+    ProcessOptions = get_value(worker_process_options, Options_1, []),
     case ibrowse_lb:spawn_connection(Lb_pid, Parsed_url,
                                              Max_sessions, 
                                              Max_pipeline_size,
-                                             {SSLOptions, IsSSL}) of
+                                             {SSLOptions, IsSSL},
+                                             ProcessOptions) of
         {ok, Conn_Pid} ->
             case do_send_req(Conn_Pid, Parsed_url, Headers,
                              Method, Body, Options_1, Timeout) of
@@ -437,7 +445,9 @@ do_send_req(Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout) ->
         {'EXIT', {noproc, {gen_server, call, [Conn_Pid, _, _]}}} ->
             {error, sel_conn_closed};
         {'EXIT', {normal, _}} ->
-            {error, req_timedout};
+            {error, sel_conn_closed};
+        {'EXIT', {connection_closed, _}} ->
+            {error, sel_conn_closed};
         {error, connection_closed} ->
             {error, sel_conn_closed};
         {'EXIT', Reason} ->
@@ -449,6 +459,13 @@ do_send_req(Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout) ->
                 binary ->
                     Ret
             end;
+        {ok, St_code, Headers, Body, Req} = Ret when is_binary(Body) ->
+            case get_value(response_format, Options, list) of
+                list ->
+                    {ok, St_code, Headers, binary_to_list(Body), Req};
+                binary ->
+                    Ret
+            end;
         Ret ->
             Ret
     end.
@@ -470,28 +487,32 @@ ensure_bin({Fun, _} = Body) when is_function(Fun) -> Body.
 %% request is sent via any of the send_req_direct/4,5,6,7 functions.<br/>
 %% <b>Note:</b> It is the responsibility of the calling process to control
 %% pipeline size on such connections.
-%%
-%% @spec spawn_worker_process(Url::string()) -> {ok, pid()}
-spawn_worker_process(Url) ->
-    ibrowse_http_client:start(Url).
 
-%% @doc Same as spawn_worker_process/1 but takes as input a Host and Port
-%% instead of a URL.
+%% @spec spawn_worker_process(Url::string() | {Host::string(), Port::integer()}) -> {ok, pid()}
+spawn_worker_process(Args) ->
+    spawn_worker_process(Args, []).
+
+%% @doc Same as spawn_worker_process/1 except with Erlang process options.
 %% @spec spawn_worker_process(Host::string(), Port::integer()) -> {ok, pid()}
-spawn_worker_process(Host, Port) ->
-    ibrowse_http_client:start({Host, Port}).
+spawn_worker_process(Host, Port) when is_list(Host), is_integer(Port) ->
+    %% Convert old API calls to new API format.
+    spawn_worker_process({Host, Port}, []);
+spawn_worker_process(Args, Options) ->
+    ibrowse_http_client:start(Args, Options).
 
 %% @doc Same as spawn_worker_process/1 except the the calling process
 %% is linked to the worker process which is spawned.
-%% @spec spawn_link_worker_process(Url::string()) -> {ok, pid()}
-spawn_link_worker_process(Url) ->
-    ibrowse_http_client:start_link(Url).
+%% @spec spawn_link_worker_process(Url::string() | {Host::string(), Port::integer()}) -> {ok, pid()}
+spawn_link_worker_process(Args) ->
+    spawn_link_worker_process(Args, []).
 
-%% @doc Same as spawn_worker_process/2 except the the calling process
-%% is linked to the worker process which is spawned.
+%% @doc Same as spawn_link_worker_process/1 except with Erlang process options.
 %% @spec spawn_link_worker_process(Host::string(), Port::integer()) -> {ok, pid()}
-spawn_link_worker_process(Host, Port) ->
-    ibrowse_http_client:start_link({Host, Port}).
+spawn_link_worker_process(Host, Port) when is_list(Host), is_integer(Port) ->
+    %% Convert old API calls to new API format.
+    spawn_link_worker_process({Host, Port}, []);
+spawn_link_worker_process(Args, Options) ->
+    ibrowse_http_client:start_link(Args, Options).
 
 %% @doc Terminate a worker process spawned using
 %% spawn_worker_process/2 or spawn_link_worker_process/2. Requests in

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/src/ibrowse/ibrowse_http_client.erl
----------------------------------------------------------------------
diff --git a/src/ibrowse/ibrowse_http_client.erl b/src/ibrowse/ibrowse_http_client.erl
index a1cf6eb..64fc443 100644
--- a/src/ibrowse/ibrowse_http_client.erl
+++ b/src/ibrowse/ibrowse_http_client.erl
@@ -15,7 +15,9 @@
 %% External exports
 -export([
          start_link/1,
+         start_link/2,
          start/1,
+         start/2,
          stop/1,
          send_req/7
         ]).
@@ -39,8 +41,7 @@
 
 -record(state, {host, port, connect_timeout,
                 inactivity_timer_ref,
-                use_http_proxy = false, http_proxy_auth_digest,
-                socks5_host, socks5_port, socks5_user, socks5_password,
+                use_proxy = false, proxy_auth_digest,
                 ssl_options = [], is_ssl = false, socket,
                 proxy_tunnel_setup = false,
                 tunnel_setup_queue = [],
@@ -62,7 +63,7 @@
                   stream_chunk_size,
                   save_response_to_file = false,
                   tmp_file_name, tmp_file_fd, preserve_chunked_encoding,
-                  response_format, timer_ref}).
+                  response_format, timer_ref, raw_req}).
 
 -import(ibrowse_lib, [
                       get_value/2,
@@ -80,10 +81,16 @@
 %% Description: Starts the server
 %%--------------------------------------------------------------------
 start(Args) ->
-    gen_server:start(?MODULE, Args, []).
+    start(Args, []).
+
+start(Args, Options) ->
+    gen_server:start(?MODULE, Args, Options).
 
 start_link(Args) ->
-    gen_server:start_link(?MODULE, Args, []).
+    start_link(Args, []).
+
+start_link(Args, Options) ->
+    gen_server:start_link(?MODULE, Args, Options).
 
 stop(Conn_pid) ->
     case catch gen_server:call(Conn_pid, stop) of
@@ -187,7 +194,7 @@ handle_info({ssl, _Sock, Data}, State) ->
 
 handle_info({stream_next, Req_id}, #state{socket = Socket,
                                           cur_req = #request{req_id = Req_id}} = State) ->
-    do_setopts(Socket, [{active, once}], State),
+    _ = do_setopts(Socket, [{active, once}], State),
     {noreply, set_inac_timer(State)};
 
 handle_info({stream_next, _Req_id}, State) ->
@@ -226,12 +233,13 @@ handle_info({ssl_error, _Sock, Reason}, State) ->
     {stop, normal, State};
 
 handle_info({req_timedout, From}, State) ->
-    case lists:keymember(From, #request.from, queue:to_list(State#state.reqs)) of
+    case lists:keysearch(From, #request.from, queue:to_list(State#state.reqs)) of
         false ->
             {noreply, State};
-        true ->
+        {value, #request{stream_to = StreamTo, req_id = ReqId}} ->
+            catch StreamTo ! {ibrowse_async_response_timeout, ReqId},
             shutting_down(State),
-%%            do_error_reply(State, req_timedout),
+            do_error_reply(State, req_timedout),
             {stop, normal, State}
     end;
 
@@ -288,12 +296,12 @@ handle_sock_data(Data, #state{status = get_header}=State) ->
             shutting_down(State),
             {stop, normal, State};
         #state{socket = Socket, status = Status, cur_req = CurReq} = State_1 ->
-            case {Status, CurReq} of
-                {get_header, #request{caller_controls_socket = true}} ->
-                    do_setopts(Socket, [{active, once}], State_1);
-                _ ->
-                    active_once(State_1)
-            end,
+            _ = case {Status, CurReq} of
+		    {get_header, #request{caller_controls_socket = true}} ->
+			do_setopts(Socket, [{active, once}], State_1);
+		    _ ->
+			active_once(State_1)
+		end,
             {noreply, set_inac_timer(State_1)}
     end;
 
@@ -312,7 +320,7 @@ handle_sock_data(Data, #state{status           = get_body,
                                             {error, {Reason, {stat_code, StatCode}, Headers}}),
                     {stop, normal, State};
                 State_1 ->
-                    active_once(State_1),
+                    _ = active_once(State_1),
                     State_2 = set_inac_timer(State_1),
                     {noreply, State_2}
             end;
@@ -325,14 +333,14 @@ handle_sock_data(Data, #state{status           = get_body,
                     {stop, normal, State};
                 #state{cur_req = #request{caller_controls_socket = Ccs},
                        interim_reply_sent = Irs} = State_1 ->
-                    case Irs of
-                        true ->
-                            active_once(State_1);
-                        false when Ccs == true ->
-                            do_setopts(Socket, [{active, once}], State);
-                        false ->
-                            active_once(State_1)
-                    end,
+                    _ = case Irs of
+			    true ->
+				active_once(State_1);
+			    false when Ccs == true ->
+				do_setopts(Socket, [{active, once}], State);
+			    false ->
+				active_once(State_1)
+			end,
                     State_2 = State_1#state{interim_reply_sent = false},
                     case Ccs of
                     true ->
@@ -342,7 +350,7 @@ handle_sock_data(Data, #state{status           = get_body,
                         {noreply, set_inac_timer(State_2)}
                     end;
                 State_1 ->
-                    active_once(State_1),
+                    _ = active_once(State_1),
                     State_2 = set_inac_timer(State_1),
                     {noreply, State_2}
             end
@@ -464,7 +472,9 @@ handle_sock_closed(#state{reply_buffer = Buf, reqs = Reqs, http_status_code = SC
                          }=State) ->
     #request{from=From, stream_to=StreamTo, req_id=ReqId,
              response_format = Resp_format,
-             options = Options} = CurReq,
+             options = Options,
+             raw_req = Raw_req
+            } = CurReq,
     case IsClosing of
         true ->
             {_, Reqs_1} = queue:out(Reqs),
@@ -475,11 +485,16 @@ handle_sock_closed(#state{reply_buffer = Buf, reqs = Reqs, http_status_code = SC
                            ok = file:close(Fd),
                            {file, TmpFilename}
                    end,
+            Give_raw_req = get_value(return_raw_request, Options, false),
             Reply = case get_value(give_raw_headers, Options, false) of
-                          true ->
+                        true when Give_raw_req == false->
                             {ok, Status_line, Raw_headers, Body};
+                        true ->
+                            {ok, Status_line, Raw_headers, Body, Raw_req};
+                        false when Give_raw_req == false ->
+                            {ok, SC, Headers, Buf};
                         false ->
-                            {ok, SC, Headers, Buf}
+                            {ok, SC, Headers, Buf, Raw_req}
                     end,
             State_1 = do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
             ok = do_error_reply(State_1#state{reqs = Reqs_1}, connection_closed),
@@ -489,25 +504,19 @@ handle_sock_closed(#state{reply_buffer = Buf, reqs = Reqs, http_status_code = SC
             State
     end.
 
-do_connect(Host, Port, Options, #state{socks5_host = SocksHost}=State, Timeout)
-  when SocksHost /= undefined ->
-    ProxyOptions = [
-        {user,     State#state.socks5_user},
-        {password, State#state.socks5_password},
-        {host,     SocksHost},
-        {port,     State#state.socks5_port},
-        {is_ssl,   State#state.is_ssl},
-        {ssl_opts, State#state.ssl_options}],
-    ibrowse_socks5:connect(Host, Port, ProxyOptions,
-                           get_sock_options(SocksHost, Options, []),
-                           Timeout);
-do_connect(Host, Port, Options, #state{is_ssl         = true,
-                                       use_http_proxy = false,
-                                       ssl_options    = SSLOptions},
+do_connect(Host, Port, Options, #state{is_ssl      = true,
+                                       use_proxy   = false,
+                                       ssl_options = SSLOptions},
            Timeout) ->
     ssl:connect(Host, Port, get_sock_options(Host, Options, SSLOptions), Timeout);
 do_connect(Host, Port, Options, _State, Timeout) ->
-    gen_tcp:connect(Host, Port, get_sock_options(Host, Options, []), Timeout).
+    Socks5Host = get_value(socks5_host, Options, undefined),
+    case Socks5Host of
+      undefined ->
+        gen_tcp:connect(Host, Port, get_sock_options(Host, Options, []), Timeout);
+      _ ->
+        catch ibrowse_socks5:connect(Host, Port, Options)
+    end.
 
 get_sock_options(Host, Options, SSLOptions) ->
     Caller_socket_options = get_value(socket_options, Options, []),
@@ -554,42 +563,68 @@ filter_sock_options(Opts) ->
 
 do_send(Req, #state{socket = Sock,
                     is_ssl = true,
-                    use_http_proxy = true,
+                    use_proxy = true,
                     proxy_tunnel_setup = Pts}) when Pts /= done ->  gen_tcp:send(Sock, Req);
 do_send(Req, #state{socket = Sock, is_ssl = true})  ->  ssl:send(Sock, Req);
 do_send(Req, #state{socket = Sock, is_ssl = false}) ->  gen_tcp:send(Sock, Req).
 
-%% @spec do_send_body(Sock::socket_descriptor(), Source::source_descriptor(), IsSSL::boolean()) -> ok | error()
-%% source_descriptor() = fun_arity_0           |
-%%                       {fun_arity_0}         |
-%%                       {fun_arity_1, term()}
-%% error() = term()
 do_send_body(Source, State, TE) when is_function(Source) ->
     do_send_body({Source}, State, TE);
 do_send_body({Source}, State, TE) when is_function(Source) ->
-    do_send_body1(Source, Source(), State, TE);
+    do_send_body_1(generate_body(Source),
+                   State, TE, []);
 do_send_body({Source, Source_state}, State, TE) when is_function(Source) ->
-    do_send_body1(Source, Source(Source_state), State, TE);
+    do_send_body_1(generate_body({Source, Source_state}),
+                   State, TE, []);
 do_send_body(Body, State, _TE) ->
-    do_send(Body, State).
+    case do_send(Body, State) of
+        ok ->
+            {ok, Body};
+        Ret ->
+            Ret
+    end.
 
-do_send_body1(Source, Resp, State, TE) ->
+generate_body({Source, Source_state} = In) when is_function(Source) ->
+    case Source(Source_state) of
+        {ok, Data, Source_state_1} ->
+            {{ok, Data}, {Source, Source_state_1}};
+        Ret ->
+            {Ret, In}
+    end;
+generate_body(Source) when is_function(Source) ->
+    {Source(), Source}.
+
+do_send_body_1({Resp, Source}, State, TE, Acc) when is_function(Source) ->
     case Resp of
-                {ok, Data} when Data == []; Data == <<>> ->
-                        do_send_body({Source}, State, TE);
+        {ok, Data} when Data == []; Data == <<>> ->
+            do_send_body_1(generate_body(Source), State, TE, Acc);
         {ok, Data} ->
-            do_send(maybe_chunked_encode(Data, TE), State),
-            do_send_body({Source}, State, TE);
-                {ok, Data, New_source_state} when Data == []; Data == <<>> ->
-                        do_send_body({Source, New_source_state}, State, TE);
+            Acc_1 = case TE of
+                        true ->
+                            ok = do_send(maybe_chunked_encode(Data, TE), State),
+                            Acc;
+                        false ->
+                            [Data | Acc]
+                    end,
+            do_send_body_1(generate_body(Source), State, TE, Acc_1);
+        {ok, Data, New_source_state} when Data == []; Data == <<>> ->
+            do_send_body_1(generate_body({Source, New_source_state}), State, TE, Acc);
         {ok, Data, New_source_state} ->
-            do_send(maybe_chunked_encode(Data, TE), State),
-            do_send_body({Source, New_source_state}, State, TE);
+            Acc_1 = case TE of
+                        true ->
+                            ok = do_send(maybe_chunked_encode(Data, TE), State),
+                            Acc;
+                        false ->
+                            [Data | Acc]
+                    end,
+            do_send_body_1(generate_body({Source, New_source_state}), State, TE, Acc_1);
         eof when TE == true ->
-            do_send(<<"0\r\n\r\n">>, State),
-            ok;
+            ok = do_send(<<"0\r\n\r\n">>, State),
+            {ok, []};
         eof ->
-            ok;
+            Body = list_to_binary(lists:reverse(Acc)),
+            ok = do_send(Body, State),
+            {ok, Body};
         Err ->
             Err
     end.
@@ -602,7 +637,7 @@ maybe_chunked_encode(Data, true) ->
 do_close(#state{socket = undefined})            ->  ok;
 do_close(#state{socket = Sock,
                 is_ssl = true,
-                use_http_proxy = true,
+                use_proxy = true,
                 proxy_tunnel_setup = Pts
                }) when Pts /= done ->  catch gen_tcp:close(Sock);
 do_close(#state{socket = Sock, is_ssl = true})  ->  catch ssl:close(Sock);
@@ -611,11 +646,11 @@ do_close(#state{socket = Sock, is_ssl = false}) ->  catch gen_tcp:close(Sock).
 active_once(#state{cur_req = #request{caller_controls_socket = true}}) ->
     ok;
 active_once(#state{socket = Socket} = State) ->
-    do_setopts(Socket, [{active, once}], State).
+    _ = do_setopts(Socket, [{active, once}], State).
 
 do_setopts(_Sock, [],   _)    ->  ok;
 do_setopts(Sock, Opts, #state{is_ssl = true,
-                              use_http_proxy = true,
+                              use_proxy = true,
                               proxy_tunnel_setup = Pts}
                              ) when Pts /= done ->  inet:setopts(Sock, Opts);
 do_setopts(Sock, Opts, #state{is_ssl = true}) -> ssl:setopts(Sock, Opts);
@@ -634,28 +669,17 @@ send_req_1(From,
                 port = Port} = Url,
            Headers, Method, Body, Options, Timeout,
            #state{socket = undefined} = State) ->
-    ProxyHost = get_value(proxy_host, Options, false),
-    ProxyProtocol = get_value(proxy_protocol, Options, http),
     {Host_1, Port_1, State_1} =
-        case {ProxyHost, ProxyProtocol} of
-            {false, _} ->
+        case get_value(proxy_host, Options, false) of
+            false ->
                 {Host, Port, State};
-            {_, http} ->
+            PHost ->
                 ProxyUser     = get_value(proxy_user, Options, []),
                 ProxyPassword = get_value(proxy_password, Options, []),
                 Digest        = http_auth_digest(ProxyUser, ProxyPassword),
-                {ProxyHost, get_value(proxy_port, Options, 80),
-                 State#state{use_http_proxy = true,
-                             http_proxy_auth_digest = Digest}};
-            {_, socks5} ->
-                ProxyUser     = list_to_binary(get_value(proxy_user, Options, [])),
-                ProxyPassword = list_to_binary(get_value(proxy_password, Options, [])),
-                ProxyPort = get_value(proxy_port, Options, 1080),
-                {Host, Port,
-                 State#state{socks5_host = ProxyHost,
-                             socks5_port = ProxyPort,
-                             socks5_user = ProxyUser,
-                             socks5_password = ProxyPassword}}
+                {PHost, get_value(proxy_port, Options, 80),
+                 State#state{use_proxy = true,
+                             proxy_auth_digest = Digest}}
         end,
     State_2 = check_ssl_options(Options, State_1),
     do_trace("Connecting...~n", []),
@@ -686,7 +710,7 @@ send_req_1(From,
            Headers, Method, Body, Options, Timeout,
            #state{
                   proxy_tunnel_setup = false,
-                  use_http_proxy = true,
+                  use_proxy = true,
                   is_ssl    = true} = State) ->
     Ref = case Timeout of
               infinity ->
@@ -711,9 +735,9 @@ send_req_1(From,
     case do_send(Req, State) of
         ok ->
             case do_send_body(Body_1, State_1, TE) of
-                ok ->
+                {ok, _Sent_body} ->
                     trace_request_body(Body_1),
-                    active_once(State_1),
+                    _ = active_once(State_1),
                     State_1_1 = inc_pipeline_counter(State_1),
                     State_2 = State_1_1#state{status     = get_header,
                                               cur_req    = NewReq,
@@ -775,6 +799,11 @@ send_req_1(From,
               _ ->
                   erlang:send_after(Timeout, self(), {req_timedout, From})
           end,
+    Headers_1 = maybe_modify_headers(Url, Method, Options, Headers, State),
+    {Req, Body_1} = make_request(Method,
+                                 Headers_1,
+                                 AbsPath, RelPath, Body, Options, State,
+                                 ReqId),
     NewReq = #request{url                    = Url,
                       method                 = Method,
                       stream_to              = StreamTo,
@@ -789,26 +818,24 @@ send_req_1(From,
                       preserve_chunked_encoding = get_value(preserve_chunked_encoding, Options, false),
                       timer_ref              = Ref
                      },
-    State_1 = State#state{reqs=queue:in(NewReq, State#state.reqs)},
-    Headers_1 = maybe_modify_headers(Url, Method, Options, Headers, State_1),
-    {Req, Body_1} = make_request(Method,
-                                 Headers_1,
-                                 AbsPath, RelPath, Body, Options, State_1,
-                                 ReqId),
     trace_request(Req),
-    do_setopts(Socket, Caller_socket_options, State_1),
+    ok = do_setopts(Socket, Caller_socket_options, State),
     TE = is_chunked_encoding_specified(Options),
-    case do_send(Req, State_1) of
+    case do_send(Req, State) of
         ok ->
-            case do_send_body(Body_1, State_1, TE) of
-                ok ->
-                    trace_request_body(Body_1),
+            case do_send_body(Body_1, State, TE) of
+                {ok, Sent_body} ->
+                    trace_request_body(Sent_body),
+                    Raw_req = list_to_binary([Req, Sent_body]),
+                    NewReq_1 = NewReq#request{raw_req = Raw_req},
+                    State_1 = State#state{reqs=queue:in(NewReq_1, State#state.reqs)},
                     State_2 = inc_pipeline_counter(State_1),
-                    active_once(State_2),
+                    _ = active_once(State_2),
                     State_3 = case Status of
                                   idle ->
-                                      State_2#state{status     = get_header,
-                                                    cur_req    = NewReq};
+                                      State_2#state{
+                                        status     = get_header,
+                                        cur_req    = NewReq_1};
                                   _ ->
                                       State_2
                               end,
@@ -816,21 +843,27 @@ send_req_1(From,
                         undefined ->
                             ok;
                         _ ->
-                            gen_server:reply(From, {ibrowse_req_id, ReqId})
+                            gen_server:reply(From, {ibrowse_req_id, ReqId}),
+                            case get_value(return_raw_request, Options, false) of
+                                false ->
+                                    ok;
+                                true ->
+                                    catch StreamTo ! {ibrowse_async_raw_req, Raw_req}
+                            end
                     end,
                     State_4 = set_inac_timer(State_3),
                     {noreply, State_4};
                 Err ->
-                    shutting_down(State_1),
+                    shutting_down(State),
                     do_trace("Send failed... Reason: ~p~n", [Err]),
                     gen_server:reply(From, {error, {send_failed, Err}}),
-                    {stop, normal, State_1}
+                    {stop, normal, State}
             end;
         Err ->
-            shutting_down(State_1),
+            shutting_down(State),
             do_trace("Send failed... Reason: ~p~n", [Err]),
             gen_server:reply(From, {error, {send_failed, Err}}),
-            {stop, normal, State_1}
+            {stop, normal, State}
     end.
 
 maybe_modify_headers(#url{}, connect, _, Headers, State) ->
@@ -874,11 +907,11 @@ add_auth_headers(#url{username = User,
                 end,
     add_proxy_auth_headers(State, Headers_1).
 
-add_proxy_auth_headers(#state{use_http_proxy = false}, Headers) ->
+add_proxy_auth_headers(#state{use_proxy = false}, Headers) ->
     Headers;
-add_proxy_auth_headers(#state{http_proxy_auth_digest = []}, Headers) ->
+add_proxy_auth_headers(#state{proxy_auth_digest = []}, Headers) ->
     Headers;
-add_proxy_auth_headers(#state{http_proxy_auth_digest = Auth_digest}, Headers) ->
+add_proxy_auth_headers(#state{proxy_auth_digest = Auth_digest}, Headers) ->
     [{"Proxy-Authorization", ["Basic ", Auth_digest]} | Headers].
 
 http_auth_digest([], []) ->
@@ -887,7 +920,7 @@ http_auth_digest(Username, Password) ->
     ibrowse_lib:encode_base64(Username ++ [$: | Password]).
 
 make_request(Method, Headers, AbsPath, RelPath, Body, Options,
-             #state{use_http_proxy = UseHttpProxy, is_ssl = Is_ssl}, ReqId) ->
+             #state{use_proxy = UseProxy, is_ssl = Is_ssl}, ReqId) ->
     HttpVsn = http_vsn_string(get_value(http_vsn, Options, {1,1})),
     Fun1 = fun({X, Y}) when is_atom(X) ->
                    {to_lower(atom_to_list(X)), X, Y};
@@ -930,7 +963,7 @@ make_request(Method, Headers, AbsPath, RelPath, Body, Options,
                         Headers_2
                 end,
     Headers_4 = cons_headers(Headers_3),
-    Uri = case get_value(use_absolute_uri, Options, false) or UseHttpProxy of
+    Uri = case get_value(use_absolute_uri, Options, false) or UseProxy of
               true ->
                   case Is_ssl of
                       true ->
@@ -1028,7 +1061,8 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
                             cur_req = CurReq} = State) ->
     #request{from=From, stream_to=StreamTo, req_id=ReqId,
              method=Method, response_format = Resp_format,
-             options = Options, timer_ref = T_ref
+             options = Options, timer_ref = T_ref,
+             raw_req = Raw_req
             } = CurReq,
     MaxHeaderSize = ibrowse:get_config_value(max_headers_size, infinity),
     case scan_header(Acc, Data) of
@@ -1048,6 +1082,7 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
                               State
                       end,
             Give_raw_headers = get_value(give_raw_headers, Options, false),
+            Give_raw_req = get_value(return_raw_request, Options, false),
             State_1 = case Give_raw_headers of
                           true ->
                               State_0#state{recvd_headers=Headers_1, status=get_body,
@@ -1061,7 +1096,9 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
                                             http_status_code=StatCode}
                       end,
             put(conn_close, ConnClose),
-            TransferEncoding = to_lower(get_value("transfer-encoding", LCHeaders, "false")),
+            TransferEncodings = to_lower(get_value("transfer-encoding", LCHeaders, "false")),
+            IsChunked = lists:any(fun(Enc) -> string:strip(Enc) =:= "chunked" end,
+                                  string:tokens(TransferEncodings, ",")),
             Head_response_with_body = lists:member({workaround, head_response_with_body}, Options),
             case get_value("content-length", LCHeaders, undefined) of
                 _ when Method == connect,
@@ -1086,8 +1123,13 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
                     %% there was still a body.  Issue #67 on Github
                     {_, Reqs_1} = queue:out(Reqs),
                     send_async_headers(ReqId, StreamTo, Give_raw_headers, State_1),
-                    State_1_1 = do_reply(State_1, From, StreamTo, ReqId, Resp_format,
-                                         {ok, StatCode, Headers_1, []}),
+                    Reply = case Give_raw_req of
+                                false ->
+                                    {ok, StatCode, Headers_1, []};
+                                true ->
+                                    {ok, StatCode, Headers_1, [], Raw_req}
+                            end,
+                    State_1_1 = do_reply(State_1, From, StreamTo, ReqId, Resp_format, Reply),
                     cancel_timer(T_ref, {eat_message, {req_timedout, From}}),
                     State_2 = reset_state(State_1_1),
                     State_3 = set_cur_request(State_2#state{reqs = Reqs_1}),
@@ -1106,13 +1148,18 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
                     %% RFC2616 - Sec 4.4
                     {_, Reqs_1} = queue:out(Reqs),
                     send_async_headers(ReqId, StreamTo, Give_raw_headers, State_1),
-                    State_1_1 = do_reply(State_1, From, StreamTo, ReqId, Resp_format,
-                                         {ok, StatCode, Headers_1, []}),
+                    Reply = case Give_raw_req of
+                                true ->
+                                    {ok, StatCode, Headers_1, []};
+                                false ->
+                                    {ok, StatCode, Headers_1, [], Raw_req}
+                            end,
+                    State_1_1 = do_reply(State_1, From, StreamTo, ReqId, Resp_format, Reply),
                     cancel_timer(T_ref, {eat_message, {req_timedout, From}}),
                     State_2 = reset_state(State_1_1),
                     State_3 = set_cur_request(State_2#state{reqs = Reqs_1}),
                     parse_response(Data_1, State_3);
-                _ when TransferEncoding =:= "chunked" ->
+                _ when IsChunked ->
                     do_trace("Chunked encoding detected...~n",[]),
                     send_async_headers(ReqId, StreamTo, Give_raw_headers, State_1),
                     case parse_11_response(Data_1, State_1#state{transfer_encoding=chunked,
@@ -1130,6 +1177,25 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
                                ConnClose =:= "close" ->
                     send_async_headers(ReqId, StreamTo, Give_raw_headers, State_1),
                     State_1#state{reply_buffer = Data_1};
+                undefined when StatCode =:= "303" ->
+                    %% Some servers send 303 requests without a body.
+                    %% RFC2616 says that they SHOULD, but they dont.
+                    case ibrowse:get_config_value(allow_303_with_no_body, false) of
+                      false -> 
+                        fail_pipelined_requests(State_1,
+                                            {error, {content_length_undefined,
+                                                     {stat_code, StatCode}, Headers}}),
+                       {error, content_length_undefined};
+                      true -> 
+                        {_, Reqs_1} = queue:out(Reqs),
+                        send_async_headers(ReqId, StreamTo, Give_raw_headers, State_1),
+                        State_1_1 = do_reply(State_1, From, StreamTo, ReqId, Resp_format,
+                                             {ok, StatCode, Headers_1, []}),
+                        cancel_timer(T_ref, {eat_message, {req_timedout, From}}),
+                        State_2 = reset_state(State_1_1),
+                        State_3 = set_cur_request(State_2#state{reqs = Reqs_1}),
+                        parse_response(Data_1, State_3)
+                    end;
                 undefined ->
                     fail_pipelined_requests(State_1,
                                             {error, {content_length_undefined,
@@ -1335,7 +1401,8 @@ handle_response(#request{from=From, stream_to=StreamTo, req_id=ReqId,
                          tmp_file_name = TmpFilename,
                          tmp_file_fd = Fd,
                          options       = Options,
-                         timer_ref     = ReqTimer
+                         timer_ref     = ReqTimer,
+                         raw_req       = Raw_req
                         },
                 #state{http_status_code = SCode,
                        status_line   = Status_line,
@@ -1356,18 +1423,25 @@ handle_response(#request{from=From, stream_to=StreamTo, req_id=ReqId,
                            {file, TmpFilename}
                    end,
     {Resp_headers_1, Raw_headers_1} = maybe_add_custom_headers(RespHeaders, Raw_headers, Options),
+    Give_raw_req = get_value(return_raw_request, Options, false),
     Reply = case get_value(give_raw_headers, Options, false) of
-                true ->
+                true when Give_raw_req == false ->
                     {ok, Status_line, Raw_headers_1, ResponseBody};
+                true ->
+                    {ok, Status_line, Raw_headers_1, ResponseBody, Raw_req};
+                false when Give_raw_req == false ->
+                    {ok, SCode, Resp_headers_1, ResponseBody};
                 false ->
-                    {ok, SCode, Resp_headers_1, ResponseBody}
+                    {ok, SCode, Resp_headers_1, ResponseBody, Raw_req}
             end,
     State_1 = do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
     cancel_timer(ReqTimer, {eat_message, {req_timedout, From}}),
     set_cur_request(State_1);
 handle_response(#request{from=From, stream_to=StreamTo, req_id=ReqId,
                          response_format = Resp_format,
-                         options = Options, timer_ref = ReqTimer},
+                         options = Options, timer_ref = ReqTimer,
+                         raw_req  = Raw_req
+                        },
                 #state{http_status_code = SCode,
                        status_line      = Status_line,
                        raw_headers      = Raw_headers,
@@ -1376,11 +1450,16 @@ handle_response(#request{from=From, stream_to=StreamTo, req_id=ReqId,
                       } = State) ->
     Body = RepBuf,
     {Resp_headers_1, Raw_headers_1} = maybe_add_custom_headers(Resp_headers, Raw_headers, Options),
+    Give_raw_req = get_value(return_raw_request, Options, false),
     Reply = case get_value(give_raw_headers, Options, false) of
-                true ->
+                true when Give_raw_req == false ->
                     {ok, Status_line, Raw_headers_1, Body};
+                true ->
+                    {ok, Status_line, Raw_headers_1, Body, Raw_req};
+                false when Give_raw_req == false ->
+                    {ok, SCode, Resp_headers_1, Body};
                 false ->
-                    {ok, SCode, Resp_headers_1, Body}
+                    {ok, SCode, Resp_headers_1, Body, Raw_req}
             end,
     State_1 = do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
     cancel_timer(ReqTimer, {eat_message, {req_timedout, From}}),
@@ -1407,12 +1486,8 @@ set_cur_request(#state{reqs = Reqs, socket = Socket} = State) ->
         empty ->
             State#state{cur_req = undefined};
         {value, #request{caller_controls_socket = Ccs} = NextReq} ->
-            case Ccs of
-                true ->
-                    do_setopts(Socket, [{active, once}], State);
-                _ ->
-                    ok
-            end,
+            _ = Ccs =:= true
+		andalso do_setopts(Socket, [{active, once}], State),
             State#state{cur_req = NextReq}
     end.
 
@@ -1586,6 +1661,7 @@ get_crlf_pos(<<>>, _)                     -> no.
 fmt_val(L) when is_list(L)    -> L;
 fmt_val(I) when is_integer(I) -> integer_to_list(I);
 fmt_val(A) when is_atom(A)    -> atom_to_list(A);
+fmt_val(B) when is_binary(B)    -> B;
 fmt_val(Term)                 -> io_lib:format("~p", [Term]).
 
 crnl() -> "\r\n".
@@ -1863,13 +1939,13 @@ dec_pipeline_counter(#state{lb_ets_tid = undefined} = State) ->
     State;
 dec_pipeline_counter(#state{cur_pipeline_size = Pipe_sz,
                             lb_ets_tid = Tid} = State) ->
-    try
-        update_counter(Tid, self(), {2,-1,0,0}),
-        update_counter(Tid, self(), {3,-1,0,0})
-    catch
-        _:_ ->
-            ok
-    end,
+    _ = try
+	    update_counter(Tid, self(), {2,-1,0,0}),
+	    update_counter(Tid, self(), {3,-1,0,0})
+	catch
+	    _:_ ->
+		ok
+	end,
     State#state{cur_pipeline_size = Pipe_sz - 1}.
 
 flatten([H | _] = L) when is_integer(H) ->
@@ -1941,5 +2017,7 @@ trace_request_body(Body) ->
             ok
     end.
 
-to_binary(X) when is_list(X)   -> list_to_binary(X);
-to_binary(X) when is_binary(X) -> X.
+to_binary({X, _}) when is_function(X) -> to_binary(X);
+to_binary(X) when is_function(X)      -> <<"body generated by function">>;
+to_binary(X) when is_list(X)          -> list_to_binary(X);
+to_binary(X) when is_binary(X)        -> X.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/src/ibrowse/ibrowse_lb.erl
----------------------------------------------------------------------
diff --git a/src/ibrowse/ibrowse_lb.erl b/src/ibrowse/ibrowse_lb.erl
index d98cf32..f5a9aef 100644
--- a/src/ibrowse/ibrowse_lb.erl
+++ b/src/ibrowse/ibrowse_lb.erl
@@ -16,7 +16,7 @@
 %% External exports
 -export([
 	 start_link/1,
-	 spawn_connection/5,
+	 spawn_connection/6,
          stop/1
 	]).
 
@@ -81,13 +81,14 @@ init([Host, Port]) ->
 spawn_connection(Lb_pid, Url,
 		 Max_sessions,
 		 Max_pipeline_size,
-		 SSL_options)
+		 SSL_options,
+		 Process_options)
   when is_pid(Lb_pid),
        is_record(Url, url),
        is_integer(Max_pipeline_size),
        is_integer(Max_sessions) ->
     gen_server:call(Lb_pid,
-		    {spawn_connection, Url, Max_sessions, Max_pipeline_size, SSL_options}).
+		    {spawn_connection, Url, Max_sessions, Max_pipeline_size, SSL_options, Process_options}).
 
 stop(Lb_pid) ->
     case catch gen_server:call(Lb_pid, stop) of
@@ -123,19 +124,19 @@ handle_call(_, _From, #state{proc_state = shutting_down} = State) ->
     {reply, {error, shutting_down}, State};
 
 %% Update max_sessions in #state with supplied value
-handle_call({spawn_connection, _Url, Max_sess, Max_pipe, _}, _From,
-	    #state{num_cur_sessions = Num} = State) 
+handle_call({spawn_connection, _Url, Max_sess, Max_pipe, _, _}, _From,
+	    #state{num_cur_sessions = Num} = State)
     when Num >= Max_sess ->
     State_1 = maybe_create_ets(State),
     Reply = find_best_connection(State_1#state.ets_tid, Max_pipe),
     {reply, Reply, State_1#state{max_sessions = Max_sess,
                                  max_pipeline_size = Max_pipe}};
 
-handle_call({spawn_connection, Url, Max_sess, Max_pipe, SSL_options}, _From,
+handle_call({spawn_connection, Url, Max_sess, Max_pipe, SSL_options, Process_options}, _From,
 	    #state{num_cur_sessions = Cur} = State) ->
     State_1 = maybe_create_ets(State),
     Tid = State_1#state.ets_tid,
-    {ok, Pid} = ibrowse_http_client:start_link({Tid, Url, SSL_options}),
+    {ok, Pid} = ibrowse_http_client:start_link({Tid, Url, SSL_options}, Process_options),
     ets:insert(Tid, {Pid, 0, 0}),
     {reply, {ok, Pid}, State_1#state{num_cur_sessions = Cur + 1,
                                      max_sessions = Max_sess,
@@ -230,7 +231,9 @@ code_change(_OldVsn, State, _Extra) ->
 %%% Internal functions
 %%--------------------------------------------------------------------
 find_best_connection(Tid, Max_pipe) ->
+    ets:safe_fixtable(Tid, true),
     Res = find_best_connection(ets:first(Tid), Tid, Max_pipe),
+    ets:safe_fixtable(Tid, false),
     Res.
 
 find_best_connection('$end_of_table', _, _) ->
@@ -239,9 +242,14 @@ find_best_connection(Pid, Tid, Max_pipe) ->
     case ets:lookup(Tid, Pid) of
         [{Pid, Cur_sz, Speculative_sz}] when Cur_sz < Max_pipe,
                                              Speculative_sz < Max_pipe ->
-            ets:update_counter(Tid, Pid, {3, 1, 9999999, 9999999}),
-            {ok, Pid};
-        _ ->
+            case catch ets:update_counter(Tid, Pid, {3, 1, 9999999, 9999999}) of
+                {'EXIT', _} ->
+                    %% The selected process has shutdown
+                    find_best_connection(ets:next(Tid, Pid), Tid, Max_pipe);
+                _ ->
+                    {ok, Pid}
+            end;
+         _ ->
             find_best_connection(ets:next(Tid, Pid), Tid, Max_pipe)
     end.
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/src/ibrowse/ibrowse_lib.erl
----------------------------------------------------------------------
diff --git a/src/ibrowse/ibrowse_lib.erl b/src/ibrowse/ibrowse_lib.erl
index 7b12cb3..1ce6bd4 100644
--- a/src/ibrowse/ibrowse_lib.erl
+++ b/src/ibrowse/ibrowse_lib.erl
@@ -362,10 +362,9 @@ parse_url([], get_password, Url, TmpAcc) ->
 parse_url([], State, Url, TmpAcc) ->
     {invalid_uri_2, State, Url, TmpAcc}.
 
-default_port(socks5) -> 1080;
-default_port(http)   -> 80;
-default_port(https)  -> 443;
-default_port(ftp)    -> 21.
+default_port(http)  -> 80;
+default_port(https) -> 443;
+default_port(ftp)   -> 21.
 
 printable_date() ->
     {{Y,Mo,D},{H, M, S}} = calendar:local_time(),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63f393b/src/ibrowse/ibrowse_socks5.erl
----------------------------------------------------------------------
diff --git a/src/ibrowse/ibrowse_socks5.erl b/src/ibrowse/ibrowse_socks5.erl
index d00df44..e6d8913 100644
--- a/src/ibrowse/ibrowse_socks5.erl
+++ b/src/ibrowse/ibrowse_socks5.erl
@@ -1,109 +1,58 @@
-% 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.
-
 -module(ibrowse_socks5).
 
--define(VERSION, 5).
--define(CONNECT, 1).
+-include_lib("kernel/src/inet_dns.hrl").
 
--define(NO_AUTH, 0).
--define(USERPASS, 2).
--define(UNACCEPTABLE, 16#FF).
--define(RESERVED, 0).
+-export([connect/3]).
 
--define(ATYP_IPV4, 1).
--define(ATYP_DOMAINNAME, 3).
--define(ATYP_IPV6, 4).
+-define(TIMEOUT, 2000).
 
--define(SUCCEEDED, 0).
+-define(SOCKS5, 5).
+-define(AUTH_METHOD_NO, 0).
+-define(AUTH_METHOD_USERPASS, 2).
+-define(ADDRESS_TYPE_IP4, 1).
+-define(COMMAND_TYPE_TCPIP_STREAM, 1).
+-define(RESERVER, 0).
+-define(STATUS_GRANTED, 0).
 
--export([connect/5]).
+-define(DNS_IP, {8,8,8,8}).
 
--import(ibrowse_lib, [get_value/2, get_value/3]).
+connect(Host, Port, Options) ->
+    Socks5Host = proplists:get_value(socks5_host, Options),
+    Socks5Port = proplists:get_value(socks5_port, Options),
 
-connect(TargetHost, TargetPort, ProxyOptions, Options, Timeout) ->
-    case gen_tcp:connect(get_value(host, ProxyOptions),
-                         get_value(port, ProxyOptions),
-                         Options, Timeout) of
-        {ok, Socket} ->
-            case handshake(Socket, Options) of
-                ok ->
-                    case connect(TargetHost, TargetPort, Socket) of
-                        ok ->
-                            maybe_ssl(Socket, ProxyOptions, Timeout);
-                        Else ->
-                            gen_tcp:close(Socket),
-                            Else
-                    end;
-                Else ->
-                    gen_tcp:close(Socket),
-                    Else
-            end;
-        Else ->
-            Else
-    end.
+    {ok, Socket} = gen_tcp:connect(Socks5Host, Socks5Port, [binary, {packet, 0}, {keepalive, true}, {active, false}]),
 
-handshake(Socket, ProxyOptions) when is_port(Socket) ->
-    {Handshake, Success} = case get_value(user, ProxyOptions, <<>>) of
-        <<>> ->
-            {<<?VERSION, 1, ?NO_AUTH>>, ?NO_AUTH};
-        User ->
-            Password = get_value(password, ProxyOptions, <<>>),
-            {<<?VERSION, 1, ?USERPASS, (byte_size(User)), User,
-               (byte_size(Password)), Password>>, ?USERPASS}
-    end,
-    ok = gen_tcp:send(Socket, Handshake),
-    case gen_tcp:recv(Socket, 0) of
-        {ok, <<?VERSION, Success>>} ->
-            ok;
-        {ok, <<?VERSION, ?UNACCEPTABLE>>} ->
-            {error, unacceptable};
-        {error, Reason} ->
-            {error, Reason}
-    end.
+    {ok, _Bin} =
+    case proplists:get_value(socks5_user, Options, undefined) of
+        undefined ->
+            ok = gen_tcp:send(Socket, <<?SOCKS5, 1, ?AUTH_METHOD_NO>>),
+            {ok, <<?SOCKS5, ?AUTH_METHOD_NO>>} = gen_tcp:recv(Socket, 2, ?TIMEOUT);
+        _Else ->
+            Socks5User = list_to_binary(proplists:get_value(socks5_user, Options)),
+            Socks5Pass = list_to_binary(proplists:get_value(socks5_pass, Options)),
+
+            ok = gen_tcp:send(Socket, <<?SOCKS5, 1, ?AUTH_METHOD_USERPASS>>),
+            {ok, <<?SOCKS5, ?AUTH_METHOD_USERPASS>>} = gen_tcp:recv(Socket, 2, ?TIMEOUT),
 
-connect(Host, Port, Via) when is_list(Host) ->
-    connect(list_to_binary(Host), Port, Via);
-connect(Host, Port, Via) when is_binary(Host), is_integer(Port),
-                              is_port(Via) ->
-    ok = gen_tcp:send(Via,
-        <<?VERSION, ?CONNECT, ?RESERVED, ?ATYP_DOMAINNAME,
-          (byte_size(Host)), Host/binary,
-          (Port):16>>),
-    case gen_tcp:recv(Via, 0) of
-        {ok, <<?VERSION, ?SUCCEEDED, ?RESERVED, _/binary>>} ->
-            ok;
-        {ok, <<?VERSION, Rep, ?RESERVED, _/binary>>} ->
-            {error, rep(Rep)};
-        {error, Reason} ->
-            {error, Reason}
-    end.
+            UserLength = byte_size(Socks5User),
 
-maybe_ssl(Socket, ProxyOptions, Timeout) ->
-    IsSsl = get_value(is_ssl, ProxyOptions, false),
-    SslOpts = get_value(ssl_opts, ProxyOptions, []),
-    case IsSsl of
-        false ->
-            {ok, Socket};
-        true ->
-            ssl:connect(Socket, SslOpts, Timeout)
-    end.
+            ok = gen_tcp:send(Socket, << 1, UserLength >>),
+            ok = gen_tcp:send(Socket, Socks5User),
+            PassLength = byte_size(Socks5Pass),
+            ok = gen_tcp:send(Socket, << PassLength >>),
+            ok = gen_tcp:send(Socket, Socks5Pass),
+            {ok, <<1, 0>>} = gen_tcp:recv(Socket, 2, ?TIMEOUT)
+    end,
+
+    {IP1,IP2,IP3,IP4} = case inet_parse:address(Host) of
+        {ok, IP} ->
+            IP;
+        _Other ->
+            {ok, NsData} = inet_res:nslookup(Host, in, a, [{?DNS_IP, 53}]),
+            [Addr | _NewAnList] = [D || #dns_rr{data=D, type=a} <- NsData#dns_rec.anlist],
+            Addr
+    end,
 
-rep(0) -> succeeded;
-rep(1) -> server_fail;
-rep(2) -> disallowed_by_ruleset;
-rep(3) -> network_unreachable;
-rep(4) -> host_unreachable;
-rep(5) -> connection_refused;
-rep(6) -> ttl_expired;
-rep(7) -> command_not_supported;
-rep(8) -> address_type_not_supported.
+    ok = gen_tcp:send(Socket, <<?SOCKS5, ?COMMAND_TYPE_TCPIP_STREAM, ?RESERVER, ?ADDRESS_TYPE_IP4, IP1, IP2, IP3, IP4, Port:16>>),
+    {ok, << ?SOCKS5, ?STATUS_GRANTED, ?RESERVER, ?ADDRESS_TYPE_IP4, IP1, IP2, IP3, IP4, Port:16 >>} = gen_tcp:recv(Socket, 10, ?TIMEOUT),
+    {ok, Socket}.


[14/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Changed the typeahead to not make a call to _all_dbs and instead use the existing fetched collection.


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

Branch: refs/heads/2041-update-ibrowse
Commit: 8276adffd56afad57c210f90459fb9016af30fe5
Parents: 160f826
Author: suelockwood <de...@apache.org>
Authored: Tue Mar 11 11:50:57 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Wed Mar 12 09:55:55 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/views.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/8276adff/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 a56267f..ef52b2f 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -124,15 +124,18 @@ function(app, Components, FauxtonAPI, Databases) {
     },
 
     afterRender: function() {
-      var that = this;
-      this.dbSearchTypeahead = new Components.DbSearchTypeahead({
-        dbLimit: this.dbLimit,
+      var that = this,
+          AllDBsArray = _.map(this.collection.toJSON(), function(item, key){ 
+            return item.name; 
+          });
+
+      this.dbSearchTypeahead = new Components.Typeahead({
         el: "input.search-autocomplete",
+        source: AllDBsArray,
         onUpdate: function (item) {
           that.switchDatabase(null, item);
         }
       });
-
       this.dbSearchTypeahead.render();
     },
 


[05/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: dry up promise error callbacks
Fauxton: Fix error if anon. user tries to create Admins

Fixes #COUCHDB-2170


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

Branch: refs/heads/2041-update-ibrowse
Commit: b63ff1b50b7bde0c8f1f95988d076dda63f41fed
Parents: fb4e845
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Thu Mar 6 11:37:17 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 6 11:40:30 2014 -0500

----------------------------------------------------------------------
 src/fauxton/app/addons/auth/resources.js | 44 +++++++++------------------
 1 file changed, 15 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63ff1b5/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
index 2e359c9..71744e3 100644
--- a/src/fauxton/app/addons/auth/resources.js
+++ b/src/fauxton/app/addons/auth/resources.js
@@ -20,6 +20,18 @@ function (app, FauxtonAPI, CouchdbSession) {
 
   var Auth = new FauxtonAPI.addon();
 
+  var promiseErrorHandler = function (xhr, type, msg) {
+    msg = xhr;
+    if (arguments.length === 3) {
+      msg = xhr.responseJSON.reason;
+    }
+
+    FauxtonAPI.addNotification({
+      msg: msg,
+      type: 'error'
+    });
+  };
+
   var Admin = Backbone.Model.extend({
 
     url: function () {
@@ -58,7 +70,6 @@ function (app, FauxtonAPI, CouchdbSession) {
       this.messages = _.extend({},  {
           missingCredentials: 'Username or password cannot be blank.',
           passwordsNotMatch:  'Passwords do not match.',
-          incorrectCredentials: 'Incorrect username or password.',
           loggedIn: 'You have been logged in.',
           adminCreated: 'CouchDB admin created',
           changePassword: 'Your password has been updated.'
@@ -234,12 +245,7 @@ function (app, FauxtonAPI, CouchdbSession) {
         }
       });
 
-      promise.fail(function (rsp) {
-        FauxtonAPI.addNotification({
-          msg: 'Could not create admin. Reason' + rsp + '.',
-          type: 'error'
-        });
-      });
+      promise.fail(promiseErrorHandler);
     }
 
   });
@@ -264,18 +270,7 @@ function (app, FauxtonAPI, CouchdbSession) {
         FauxtonAPI.navigate('/');
       });
 
-      promise.fail(function (xhr, type, msg) {
-        if (arguments.length === 3) {
-          msg = FauxtonAPI.session.messages.incorrectCredentials;
-        } else {
-          msg = xhr;
-        }
-
-        FauxtonAPI.addNotification({
-          msg: msg,
-          type: 'error'
-        });
-      });
+      promise.fail(promiseErrorHandler);
     }
 
   });
@@ -302,16 +297,7 @@ function (app, FauxtonAPI, CouchdbSession) {
         that.$('#password-confirm').val('');
       });
 
-      promise.fail(function (xhr, error, msg) {
-        if (arguments.length < 3) {
-          msg = xhr;
-        }
-
-        FauxtonAPI.addNotification({
-          msg: xhr,
-          type: 'error'
-        });
-      });
+      promise.fail(promiseErrorHandler);
     }
   });
 


[24/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: Adding an info file for contributors


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

Branch: refs/heads/2041-update-ibrowse
Commit: a3559974f539ebf0ca44e849fc161c3f8fb7e3b0
Parents: d2a3c3c
Author: suelockwood <de...@apache.org>
Authored: Fri Mar 14 10:02:10 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Fri Mar 14 10:02:22 2014 -0400

----------------------------------------------------------------------
 src/fauxton/CONTRIBUTING.md | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a3559974/src/fauxton/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/src/fauxton/CONTRIBUTING.md b/src/fauxton/CONTRIBUTING.md
new file mode 100644
index 0000000..3b3b623
--- /dev/null
+++ b/src/fauxton/CONTRIBUTING.md
@@ -0,0 +1,22 @@
+Contributing to Fauxton
+=======================
+
+Couchdb is an apache project, which is why we keep all our issues in Jira.  You can find or submit issues for fauxton [here](https://issues.apache.org/jira/issues/?filter=12326543).
+
+We try to keep all tickets up to date with Skill level for you to have an idea of the level of effort or comfortability with the framework you'd need to complete the task.
+
+To fix an issue in Fauxton, fork the Couchdb project to your github account. The [Readme file](https://github.com/apache/couchdb/blob/master/src/fauxton/readme.md) has information about how to get the project running.  To start working on a specific ticket, create a branch with the Jira ID # followed by a traincase description of the issue. 
+
+> e.g.   1234-Added-support-for-list-functions
+
+If there is no Jira ticket for the issue you have, please create one. 
+
+When you're ready for a review, submit a Pull Request. We regularly check the PR list for fauxton and should get back to you with a code review.  If no one has responded to you yet, you can find us on IRC in #couchdb-dev.  Ping **Garren** or **Deathbear**, though anyone in the room should be able to help you.
+
+We appreciate constructive feedback from people who use couchdb, so don't be shy. We know there are bugs and we know there is room for improvement. 
+
+ʕ´•ᴥ•`ʔ Thanks! 
+
+-- Fauxton team
+
+PS - If you are new to contributing to open source, or using github reach out to us on irc (#couchdb-dev)! We will happily help you.


[26/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
COUCHDB-2166 Rename duplicate document to "copy ..." or "clone ..."


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

Branch: refs/heads/2041-update-ibrowse
Commit: a17bf86af27a2eb52e552360fecb5e74b6e5f582
Parents: 33b6e35
Author: suelockwood <de...@apache.org>
Authored: Fri Mar 14 11:17:26 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Fri Mar 14 11:17:26 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/templates/doc.html              | 2 +-
 .../app/addons/documents/templates/duplicate_doc_modal.html      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a17bf86a/src/fauxton/app/addons/documents/templates/doc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/doc.html b/src/fauxton/app/addons/documents/templates/doc.html
index 5ef70fe..9433868 100644
--- a/src/fauxton/app/addons/documents/templates/doc.html
+++ b/src/fauxton/app/addons/documents/templates/doc.html
@@ -40,7 +40,7 @@ the License.
     </div>
     <% } %> 
     <button class="btn upload"><i class="icon icon-circle-arrow-up"></i> Upload Attachment</button>
-    <button class="btn duplicate"><i class="icon icon-repeat"></i> Duplicate document</button>
+    <button class="btn duplicate"><i class="icon icon-repeat"></i> Clone document</button>
   </div>
 
   <button class="btn btn-danger delete"><i class="icon icon-trash"></i></button>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a17bf86a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
index 7616300..54be01f 100644
--- a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
+++ b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
@@ -15,7 +15,7 @@ the License.
 <div class="modal hide fade">
   <div class="modal-header">
     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-    <h3>Duplicate Document</h3>
+    <h3>Clone Document</h3>
   </div>
   <div class="modal-body">
     <div id="modal-error" class="hide alert alert-error"/>
@@ -29,7 +29,7 @@ the License.
   </div>
   <div class="modal-footer">
     <button data-dismiss="modal" class="btn cancel-button"><i class="icon fonticon-circle-x"></i> Cancel</button>
-    <button id="duplicate-btn" class="btn btn-success save"><i class="fonticon-circle-check"></i> Duplicate</button>
+    <button id="duplicate-btn" class="btn btn-success save"><i class="fonticon-circle-check"></i> Clone</button>
   </div>
 </div>
 


[21/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Config refactor-  Move views into their own file and out of resources.


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

Branch: refs/heads/2041-update-ibrowse
Commit: e01079ccbeb01f6fa702af239f9af8969ffbce4a
Parents: 4913c6e
Author: suelockwood <de...@apache.org>
Authored: Thu Mar 13 12:01:39 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 12:01:39 2014 -0400

----------------------------------------------------------------------
 src/Makefile.am                                 |   1 +
 src/fauxton/app/addons/config/base.js           |   6 +-
 src/fauxton/app/addons/config/resources.js      | 120 ----------------
 src/fauxton/app/addons/config/routes.js         |   7 +-
 .../app/addons/config/tests/resourcesSpec.js    |   7 +-
 src/fauxton/app/addons/config/views.js          | 144 +++++++++++++++++++
 6 files changed, 157 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e01079cc/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index a213baa..a5eea39 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,6 +68,7 @@ FAUXTON_FILES = \
     fauxton/app/addons/compaction/views.js \
     fauxton/app/addons/config/base.js \
     fauxton/app/addons/config/resources.js \
+    fauxton/app/addons/config/views.js \
     fauxton/app/addons/config/routes.js \
     fauxton/app/addons/config/templates/dashboard.html \
     fauxton/app/addons/config/templates/item.html \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e01079cc/src/fauxton/app/addons/config/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/base.js b/src/fauxton/app/addons/config/base.js
index 8362cb5..589cb14 100644
--- a/src/fauxton/app/addons/config/base.js
+++ b/src/fauxton/app/addons/config/base.js
@@ -16,10 +16,12 @@ define([
   "api",
 
   // Modules
-  "addons/config/routes"
+  "addons/config/routes",
+  "addons/config/views"
 ],
 
-function(app, FauxtonAPI, Config) {
+function(app, FauxtonAPI, Config, Views) {
+	Config.Views = Views;
   Config.initialize = function() {
     FauxtonAPI.addHeaderLink({title: "Config", href: "#_config", icon:"fonticon-cog", className: 'config'});
   };

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e01079cc/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index c0e103a..ec8cc98 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -75,125 +75,5 @@ function (app, FauxtonAPI) {
     }
   });
 
-  Config.ViewItem = FauxtonAPI.View.extend({
-    tagName: "tr",
-    className: "config-item",
-    template: "addons/config/templates/item",
-
-    events: {
-      "dblclick .js-edit-value": "editValue",
-      "click .js-delete-value": "deleteValue",
-      "click .js-cancel-value": "cancelEdit",
-      "click .js-save-value": "saveAndRender",
-      "keyup .js-value-input": "processKeyEvents"
-    },
-
-    deleteValue: function (event) {
-      var result = confirm("Are you sure you want to delete this configuration value?");
-
-      if (!result) { return; }
-
-      this.model.destroy();
-      this.remove();
-    },
-
-    editValue: function (event) {
-      this.$(".js-show-value").addClass("js-hidden");
-      this.$(".js-edit-value-form").removeClass("js-hidden");
-      this.$(".js-value-input").focus();
-    },
-
-    processKeyEvents: function (event) {
-      // Enter key
-      if (event.keyCode === 13) {
-        return this.saveAndRender();
-      }
-      // Esc key
-      if (event.keyCode === 27) {
-        return this.discardValue();
-      }
-    },
-
-
-    discardValue: function (event) {
-      this.$(".js-edit-value-form").addClass("js-hidden");
-      this.$(".js-show-value").removeClass("js-hidden");
-    },
-
-    cancelEdit: function (event) {
-      this.discardValue();
-    },
-
-    serialize: function () {
-      return {option: this.model.toJSON()};
-    },
-
-    saveAndRender: function () {
-      this.model.save({value: this.$(".js-value-input").val()});
-      this.render();
-    }
-
-  });
-
-  Config.View = FauxtonAPI.View.extend({
-    template: "addons/config/templates/dashboard",
-
-    events: {
-      "click #add-section": "addSection",
-      "submit #add-section-form": "submitForm"
-    },
-
-    submitForm: function (event) {
-      event.preventDefault();
-      var option = new Config.OptionModel({
-        section: this.$('input[name="section"]').val(),
-        name: this.$('input[name="name"]').val(),
-        value: this.$('input[name="value"]').val()
-      });
-
-      option.save();
-
-      var section = this.collection.find(function (section) {
-        return section.get("section") === option.get("section");
-      });
-
-      if (section) {
-        section.get("options").push(option.attributes);
-      } else {
-        this.collection.add({
-          section: option.get("section"),
-          options: [option.attributes]
-        });
-      }
-
-      this.$("#add-section-modal").modal('hide');
-      this.render();
-    },
-
-    addSection: function (event) {
-      event.preventDefault();
-      this.$("#add-section-modal").modal({show:true});
-    },
-
-    beforeRender: function() {
-      this.collection.each(function(config) {
-        _.each(config.get("options"), function (option, index) {
-          this.insertView("table.config tbody", new Config.ViewItem({
-            model: new Config.OptionModel({
-              section: config.get("section"),
-              name: option.name,
-              value: option.value,
-              index: index
-            })
-          }));
-        }, this);
-      }, this);
-    },
-
-    establish: function() {
-      return [this.collection.fetch()];
-    }
-  });
-
   return Config;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e01079cc/src/fauxton/app/addons/config/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js
index 6af8157..519e25f 100644
--- a/src/fauxton/app/addons/config/routes.js
+++ b/src/fauxton/app/addons/config/routes.js
@@ -16,10 +16,11 @@ define([
        "api",
 
        // Modules
-       "addons/config/resources"
+       "addons/config/resources",
+       "addons/config/views"
 ],
 
-function(app, FauxtonAPI, Config) {
+function(app, FauxtonAPI, Config, Views) {
 
   var ConfigRouteObject = FauxtonAPI.RouteObject.extend({
     layout: "one_pane",
@@ -45,7 +46,7 @@ function(app, FauxtonAPI, Config) {
     },
 
     config: function () {
-      this.setView("#dashboard-content", new Config.View({collection: this.configs}));
+      this.setView("#dashboard-content", new Views.Table({collection: this.configs}));
     },
 
     establish: function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e01079cc/src/fauxton/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/tests/resourcesSpec.js b/src/fauxton/app/addons/config/tests/resourcesSpec.js
index b9b8d09..c78bc85 100644
--- a/src/fauxton/app/addons/config/tests/resourcesSpec.js
+++ b/src/fauxton/app/addons/config/tests/resourcesSpec.js
@@ -12,12 +12,13 @@
 define([
       'api',
       'addons/config/resources',
+      'addons/config/views',
       'testUtils'
-], function (FauxtonAPI, Resources, testUtils) {
+], function (FauxtonAPI, Resources, Views, testUtils) {
   var assert = testUtils.assert,
       ViewSandbox = testUtils.ViewSandbox;
 
-  describe("Config: ViewItem", function () {
+  describe("Config: TableRow", function () {
     var tabMenu, optionModel;
 
     beforeEach(function () {
@@ -26,7 +27,7 @@ define([
         name: "bar"
       });
 
-      tabMenu = new Resources.ViewItem({
+      tabMenu = new Views.TableRow({
         model: optionModel
       });
     });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e01079cc/src/fauxton/app/addons/config/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/views.js b/src/fauxton/app/addons/config/views.js
new file mode 100644
index 0000000..bd05652
--- /dev/null
+++ b/src/fauxton/app/addons/config/views.js
@@ -0,0 +1,144 @@
+ // Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+  "app",
+  "api",
+  "addons/config/resources",
+],
+
+function (app, FauxtonAPI, Config) {
+
+  var Views = {};
+
+  Views.TableRow = FauxtonAPI.View.extend({
+    tagName: "tr",
+    className: "config-item",
+    template: "addons/config/templates/item",
+
+    events: {
+      "dblclick .js-edit-value": "editValue",
+      "click .js-delete-value": "deleteValue",
+      "click .js-cancel-value": "cancelEdit",
+      "click .js-save-value": "saveAndRender",
+      "keyup .js-value-input": "processKeyEvents"
+    },
+
+    deleteValue: function (event) {
+      var result = confirm("Are you sure you want to delete this configuration value?");
+
+      if (!result) { return; }
+
+      this.model.destroy();
+      this.remove();
+    },
+
+    editValue: function (event) {
+      this.$(".js-show-value").addClass("js-hidden");
+      this.$(".js-edit-value-form").removeClass("js-hidden");
+      this.$(".js-value-input").focus();
+    },
+
+    processKeyEvents: function (event) {
+      // Enter key
+      if (event.keyCode === 13) {
+        return this.saveAndRender();
+      }
+      // Esc key
+      if (event.keyCode === 27) {
+        return this.discardValue();
+      }
+    },
+
+
+    discardValue: function (event) {
+      this.$(".js-edit-value-form").addClass("js-hidden");
+      this.$(".js-show-value").removeClass("js-hidden");
+    },
+
+    cancelEdit: function (event) {
+      this.discardValue();
+    },
+
+    serialize: function () {
+      return {option: this.model.toJSON()};
+    },
+
+    saveAndRender: function () {
+      this.model.save({value: this.$(".js-value-input").val()});
+      this.render();
+    }
+
+  });
+
+  Views.Table = FauxtonAPI.View.extend({
+    template: "addons/config/templates/dashboard",
+
+    events: {
+      "click #add-section": "addSection",
+      "submit #add-section-form": "submitForm"
+    },
+
+    submitForm: function (event) {
+      event.preventDefault();
+      var option = new Config.OptionModel({
+        section: this.$('input[name="section"]').val(),
+        name: this.$('input[name="name"]').val(),
+        value: this.$('input[name="value"]').val()
+      });
+
+      option.save();
+
+      var section = this.collection.find(function (section) {
+        return section.get("section") === option.get("section");
+      });
+
+      if (section) {
+        section.get("options").push(option.attributes);
+      } else {
+        this.collection.add({
+          section: option.get("section"),
+          options: [option.attributes]
+        });
+      }
+
+      this.$("#add-section-modal").modal('hide');
+      this.render();
+    },
+
+    addSection: function (event) {
+      event.preventDefault();
+      this.$("#add-section-modal").modal({show:true});
+    },
+
+    beforeRender: function() {
+      this.collection.each(function(config) {
+        _.each(config.get("options"), function (option, index) {
+          this.insertView("table.config tbody", new Views.TableRow({
+            model: new Config.OptionModel({
+              section: config.get("section"),
+              name: option.name,
+              value: option.value,
+              index: index
+            })
+          }));
+        }, this);
+      }, this);
+    },
+
+    establish: function() {
+      return [this.collection.fetch()];
+    }
+  });
+
+  return Views;
+});


[20/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: Config removed redundant method.


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

Branch: refs/heads/2041-update-ibrowse
Commit: 4913c6e07b47755b7116aabcfec3d529f8ad32c4
Parents: e671933
Author: suelockwood <de...@apache.org>
Authored: Thu Mar 13 10:45:27 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:45:27 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/config/resources.js | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4913c6e0/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index e5ebe65..c0e103a 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -84,7 +84,7 @@ function (app, FauxtonAPI) {
       "dblclick .js-edit-value": "editValue",
       "click .js-delete-value": "deleteValue",
       "click .js-cancel-value": "cancelEdit",
-      "click .js-save-value": "saveValue",
+      "click .js-save-value": "saveAndRender",
       "keyup .js-value-input": "processKeyEvents"
     },
 
@@ -114,9 +114,6 @@ function (app, FauxtonAPI) {
       }
     },
 
-    saveValue: function (event) {
-      this.saveAndRender();
-    },
 
     discardValue: function (event) {
       this.$(".js-edit-value-form").addClass("js-hidden");


[17/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: add tests for config


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

Branch: refs/heads/2041-update-ibrowse
Commit: f3ca96026a8da409756e30c8cf8efd05968feeab
Parents: a07924d
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Mar 11 19:48:57 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:43:23 2014 -0400

----------------------------------------------------------------------
 src/Makefile.am                                 |  1 +
 .../app/addons/config/tests/resourcesSpec.js    | 57 ++++++++++++++++++++
 2 files changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3ca9602/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 59aa6bf..a213baa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,6 +71,7 @@ FAUXTON_FILES = \
     fauxton/app/addons/config/routes.js \
     fauxton/app/addons/config/templates/dashboard.html \
     fauxton/app/addons/config/templates/item.html \
+    fauxton/app/addons/config/tests/resourcesSpec.js \
     fauxton/app/addons/contribute/base.js \
     fauxton/app/addons/exampleAuth/base.js \
     fauxton/app/addons/exampleAuth/templates/noAccess.html \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3ca9602/src/fauxton/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/tests/resourcesSpec.js b/src/fauxton/app/addons/config/tests/resourcesSpec.js
new file mode 100644
index 0000000..98f6569
--- /dev/null
+++ b/src/fauxton/app/addons/config/tests/resourcesSpec.js
@@ -0,0 +1,57 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+      'api',
+      'addons/config/resources',
+      'testUtils'
+], function (FauxtonAPI, Resources, testUtils) {
+  var assert = testUtils.assert,
+      ViewSandbox = testUtils.ViewSandbox;
+
+  describe("ViewItem", function () {
+    var tabMenu, optionModel;
+
+    beforeEach(function () {
+      optionModel = new Resources.OptionModel({
+        section: "foo",
+        name: "bar"
+      });
+
+      tabMenu = new Resources.ViewItem({
+        model: optionModel
+      });
+    });
+
+    describe("editing Items", function () {
+      var viewSandbox;
+      beforeEach(function () {
+        viewSandbox = new ViewSandbox();
+        viewSandbox.renderView(tabMenu);
+      });
+
+      afterEach(function () {
+        viewSandbox.remove();
+      });
+
+      it("click on save should save the model and render", function () {
+        var renderSpy = sinon.stub(tabMenu, 'render');
+        var saveSpy = sinon.stub(optionModel, 'save');
+
+        tabMenu.$('.js-edit-value').trigger('dblclick');
+        tabMenu.$('.js-save-value').trigger('click');
+
+        assert.ok(renderSpy.calledOnce);
+        assert.ok(saveSpy.calledOnce);
+      });
+    });
+  });
+});


[18/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: focus input on doubleclick
Fauxton: hide field if Esc if pressed
Fauxton: fix small typo
Fauxton: save value, when I press Enter


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

Branch: refs/heads/2041-update-ibrowse
Commit: e671933c2f4d83735ce918d00d8dfe5c1130f727
Parents: f3ca960
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Wed Mar 12 22:49:35 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:43:23 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/config/resources.js      | 31 ++++++++++++++++----
 .../app/addons/config/tests/resourcesSpec.js    | 29 +++++++++++++++++-
 src/fauxton/app/core/tests/layoutSpec.js        |  2 +-
 3 files changed, 55 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e671933c/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index 8f9ab08..e5ebe65 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -22,7 +22,7 @@ function (app, FauxtonAPI) {
   Config.Model = Backbone.Model.extend({});
   Config.OptionModel = Backbone.Model.extend({
     documentation: "config",
-    
+
     url: function () {
       return app.host + '/_config/' + this.get("section") + '/' + this.get("name");
     },
@@ -84,7 +84,8 @@ function (app, FauxtonAPI) {
       "dblclick .js-edit-value": "editValue",
       "click .js-delete-value": "deleteValue",
       "click .js-cancel-value": "cancelEdit",
-      "click .js-save-value": "saveValue"
+      "click .js-save-value": "saveValue",
+      "keyup .js-value-input": "processKeyEvents"
     },
 
     deleteValue: function (event) {
@@ -99,20 +100,40 @@ function (app, FauxtonAPI) {
     editValue: function (event) {
       this.$(".js-show-value").addClass("js-hidden");
       this.$(".js-edit-value-form").removeClass("js-hidden");
+      this.$(".js-value-input").focus();
+    },
+
+    processKeyEvents: function (event) {
+      // Enter key
+      if (event.keyCode === 13) {
+        return this.saveAndRender();
+      }
+      // Esc key
+      if (event.keyCode === 27) {
+        return this.discardValue();
+      }
     },
 
     saveValue: function (event) {
-      this.model.save({value: this.$(".js-value-input").val()});
-      this.render();
+      this.saveAndRender();
     },
 
-    cancelEdit: function (event) {
+    discardValue: function (event) {
       this.$(".js-edit-value-form").addClass("js-hidden");
       this.$(".js-show-value").removeClass("js-hidden");
     },
 
+    cancelEdit: function (event) {
+      this.discardValue();
+    },
+
     serialize: function () {
       return {option: this.model.toJSON()};
+    },
+
+    saveAndRender: function () {
+      this.model.save({value: this.$(".js-value-input").val()});
+      this.render();
     }
 
   });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e671933c/src/fauxton/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/tests/resourcesSpec.js b/src/fauxton/app/addons/config/tests/resourcesSpec.js
index 98f6569..b9b8d09 100644
--- a/src/fauxton/app/addons/config/tests/resourcesSpec.js
+++ b/src/fauxton/app/addons/config/tests/resourcesSpec.js
@@ -17,7 +17,7 @@ define([
   var assert = testUtils.assert,
       ViewSandbox = testUtils.ViewSandbox;
 
-  describe("ViewItem", function () {
+  describe("Config: ViewItem", function () {
     var tabMenu, optionModel;
 
     beforeEach(function () {
@@ -52,6 +52,33 @@ define([
         assert.ok(renderSpy.calledOnce);
         assert.ok(saveSpy.calledOnce);
       });
+
+      it("pressing enter should save the model and render", function () {
+        var renderSpy = sinon.stub(tabMenu, 'render');
+        var saveSpy = sinon.stub(optionModel, 'save');
+
+        var e = $.Event("keyup");
+        e.keyCode = 13;
+        tabMenu.$('.js-value-input').trigger(e);
+
+        assert.ok(renderSpy.calledOnce);
+        assert.ok(saveSpy.calledOnce);
+      });
+
+      it("pressing Esc hides the field", function () {
+        var e = $.Event("keyup");
+        e.keyCode = 27;
+        tabMenu.$('.js-value-input').trigger(e);
+
+        assert.ok(tabMenu.$('.js-edit-value-form').hasClass('js-hidden'));
+      });
+
+      it("pressing Cancel hides the field", function () {
+        tabMenu.$('.js-edit-value').trigger('dblclick');
+        tabMenu.$('.js-cancel-value').trigger('click');
+
+        assert.ok(tabMenu.$('.js-edit-value-form').hasClass('js-hidden'));
+      });
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/e671933c/src/fauxton/app/core/tests/layoutSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/tests/layoutSpec.js b/src/fauxton/app/core/tests/layoutSpec.js
index b58966b..40b1947 100644
--- a/src/fauxton/app/core/tests/layoutSpec.js
+++ b/src/fauxton/app/core/tests/layoutSpec.js
@@ -15,7 +15,7 @@ define([
 ], function (FauxtonAPI, testUtils) {
   var assert = testUtils.assert;
 
-  describe("Faxuton Layout", function () {
+  describe("Fauxton Layout", function () {
     var layout;
 
     beforeEach(function () {


[03/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: Fix status messages in Active Tasks

Show Progress, current Sequence and Changes. Fix the display
of `undefined` if value is undefined.

Fixes #COUCHDB-2123


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

Branch: refs/heads/2041-update-ibrowse
Commit: abe96eb2c8f2a6fc2d8c6aec91af0676854ea598
Parents: 18cf47a
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Wed Mar 5 21:33:25 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 6 10:19:18 2014 -0500

----------------------------------------------------------------------
 src/fauxton/app/addons/activetasks/views.js | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/abe96eb2/src/fauxton/app/addons/activetasks/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/views.js b/src/fauxton/app/addons/activetasks/views.js
index 2b2effc..8a305f1 100644
--- a/src/fauxton/app/addons/activetasks/views.js
+++ b/src/fauxton/app/addons/activetasks/views.js
@@ -165,10 +165,20 @@ function (app, FauxtonAPI, activetasks) {
         progress = "Processed " +this.model.get('changes_done')+ " of "+this.model.get('total_changes')+ ' changes.';
       } else if (this.type === "replication"){
         progress = this.model.get('docs_written')+ " docs written. ";
-        if (this.model.get('changes_pending') !== null) { 
-          progress += this.model.get('changes_pending')+' pending changes.';
+        if (this.model.get('changes_pending') !== undefined) {
+          progress += this.model.get('changes_pending') + ' pending changes. ';
         }
       }
+      if (this.model.get('source_seq') !== undefined) {
+        progress += "Current source sequence: " + this.model.get('source_seq') + ". "
+      }
+      if (this.model.get('changes_done') !== undefined) {
+        progress += this.model.get('changes_done') + " Changes done. "
+      }
+      if (this.model.get('progress') !== undefined) {
+        progress += "Progress: " + this.model.get('progress') + "% "
+      }
+
       return progress;
     },
     serialize: function(){


[04/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Adding semicolons back to activetasks to make the compiler happy.


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

Branch: refs/heads/2041-update-ibrowse
Commit: fb4e845229bf192439eb88a875d9e879784e5711
Parents: abe96eb
Author: suelockwood <de...@apache.org>
Authored: Thu Mar 6 11:37:17 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 6 11:37:17 2014 -0500

----------------------------------------------------------------------
 src/fauxton/app/addons/activetasks/views.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/fb4e8452/src/fauxton/app/addons/activetasks/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/views.js b/src/fauxton/app/addons/activetasks/views.js
index 8a305f1..1da8f52 100644
--- a/src/fauxton/app/addons/activetasks/views.js
+++ b/src/fauxton/app/addons/activetasks/views.js
@@ -170,13 +170,13 @@ function (app, FauxtonAPI, activetasks) {
         }
       }
       if (this.model.get('source_seq') !== undefined) {
-        progress += "Current source sequence: " + this.model.get('source_seq') + ". "
+        progress += "Current source sequence: " + this.model.get('source_seq') + ". ";
       }
       if (this.model.get('changes_done') !== undefined) {
-        progress += this.model.get('changes_done') + " Changes done. "
+        progress += this.model.get('changes_done') + " Changes done. ";
       }
       if (this.model.get('progress') !== undefined) {
-        progress += "Progress: " + this.model.get('progress') + "% "
+        progress += "Progress: " + this.model.get('progress') + "% ";
       }
 
       return progress;


[06/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Store the initial collection parameters to allow a safe reset to the first page.

When adjusting page size, the desired behaviour is to navigate back to the
first page of the collection. This was previously done using the browser
URL but that does not capture additional defaults that are set in JavaScript.

This commit adds 2 new methods to the document collections:

saveDefaultParameters()
restoreDefaultParameters()

When each collection is initialized, we save the parameters (which represent the
initial state) - these can then be correctly restored when the page size is changed.

Fixes COUCHDB-2187.


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

Branch: refs/heads/2041-update-ibrowse
Commit: adf9ae25c6be1c654fededfc72350b48abfda1de
Parents: b63ff1b
Author: Will Holley <wi...@gmail.com>
Authored: Fri Mar 7 10:16:19 2014 +0000
Committer: Will Holley <wi...@gmail.com>
Committed: Fri Mar 7 10:23:54 2014 +0000

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/resources.js | 42 +++++++++++++++++-----
 src/fauxton/app/addons/documents/routes.js    |  7 ++--
 2 files changed, 37 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/adf9ae25/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 c0b736f..6f4323a 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -358,7 +358,23 @@ function(app, FauxtonAPI) {
 
   });
 
-  Documents.AllDocs = FauxtonAPI.Collection.extend({
+  var DefaultParametersMixin = function() {
+    // keep this variable private
+    var defaultParams;
+
+    return {
+      saveDefaultParameters: function() {
+        // store the default parameters so we can reset to the first page
+        defaultParams = _.clone(this.params);
+      },
+
+      restoreDefaultParameters: function() {
+        this.params = _.clone(defaultParams);
+      }
+    };
+  };
+
+  Documents.AllDocs = FauxtonAPI.Collection.extend(_.extend({}, DefaultParametersMixin(), {
     model: Documents.Doc,
     isAllDocs: true,
     documentation: function(){
@@ -367,12 +383,15 @@ function(app, FauxtonAPI) {
     initialize: function(_models, options) {
       this.database = options.database;
       this.params = _.clone(options.params);
+
       this.on("remove",this.decrementTotalRows , this);
       this.perPageLimit = options.perPageLimit || 20;
 
       if (!this.params.limit) {
-        this.params.limit = this.perPageLimit; 
+        this.params.limit = this.perPageLimit;
       }
+
+      this.saveDefaultParameters();
     },
 
     url: function(context, params) {
@@ -459,9 +478,9 @@ function(app, FauxtonAPI) {
         };
       });
     }
-  });
+  }));
 
-  Documents.IndexCollection = FauxtonAPI.Collection.extend({
+  Documents.IndexCollection = FauxtonAPI.Collection.extend(_.extend({}, DefaultParametersMixin(), {
     model: Documents.ViewRow,
     documentation: function(){
       return "docs";
@@ -469,6 +488,7 @@ function(app, FauxtonAPI) {
     initialize: function(_models, options) {
       this.database = options.database;
       this.params = _.extend({limit: 20, reduce: false}, options.params);
+
       this.idxType = "_view";
       this.view = options.view;
       this.design = options.design.replace('_design/','');
@@ -476,9 +496,10 @@ function(app, FauxtonAPI) {
       this.perPageLimit = options.perPageLimit || 20;
 
       if (!this.params.limit) {
-        this.params.limit = this.perPageLimit; 
+        this.params.limit = this.perPageLimit;
       }
-
+      
+      this.saveDefaultParameters();
     },
 
     url: function(context, params) {
@@ -618,10 +639,10 @@ function(app, FauxtonAPI) {
       return timeString;
     }
 
-  });
+  }));
 
   
-  Documents.PouchIndexCollection = FauxtonAPI.Collection.extend({
+  Documents.PouchIndexCollection = FauxtonAPI.Collection.extend(_.extend({}, DefaultParametersMixin(), {
     model: Documents.ViewRow,
     documentation: function(){
       return "docs";
@@ -632,7 +653,10 @@ function(app, FauxtonAPI) {
       this.view = options.view;
       this.design = options.design.replace('_design/','');
       this.params = _.extend({limit: 20, reduce: false}, options.params);
+
       this.idxType = "_view";
+
+      this.saveDefaultParameters();
     },
 
     url: function () {
@@ -687,7 +711,7 @@ function(app, FauxtonAPI) {
     allDocs: function(){
       return this.models;
     }
-  });
+  }));
 
 
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/adf9ae25/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 f340195..ff518e4 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -377,12 +377,13 @@ function(app, FauxtonAPI, Documents, Databases) {
     },
 
     perPageChange: function (perPage) {
-      var params = app.getParams();
+      // We need to restore the collection parameters to the defaults (1st page)
+      // and update the page size
+      var params = this.documentsView.collection.restoreDefaultParameters();
       this.perPage = perPage;
       this.documentsView.updatePerPage(perPage);
       this.documentsView.forceRender();
-      params.limit = perPage;
-      this.documentsView.collection.params = params;
+      this.documentsView.collection.params.limit = perPage;
       this.setDocPerPageLimit(perPage);
     },
 


[22/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: remove template files we no longer use


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

Branch: refs/heads/2041-update-ibrowse
Commit: 4f7cb15959898e202fa3780d3bcf35a78e297fbc
Parents: e01079c
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Mar 13 13:24:49 2014 -0400
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Mar 13 13:25:12 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/fauxton/base.js          | 10 +--
 src/fauxton/app/addons/fauxton/components.js    |  4 +-
 src/fauxton/app/templates/fauxton/api_bar.html  | 30 --------
 .../app/templates/fauxton/breadcrumbs.html      | 24 -------
 src/fauxton/app/templates/fauxton/footer.html   | 15 ----
 .../app/templates/fauxton/index_pagination.html | 24 -------
 src/fauxton/app/templates/fauxton/nav_bar.html  | 75 --------------------
 .../app/templates/fauxton/notification.html     | 18 -----
 .../app/templates/fauxton/pagination.html       | 31 --------
 9 files changed, 7 insertions(+), 224 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js
index a6e462a..7c50211 100644
--- a/src/fauxton/app/addons/fauxton/base.js
+++ b/src/fauxton/app/addons/fauxton/base.js
@@ -93,7 +93,7 @@ function(app, FauxtonAPI, resizeColumns) {
   };
 
   Fauxton.Breadcrumbs = FauxtonAPI.View.extend({
-    template: "templates/fauxton/breadcrumbs",
+    template: "addons/fauxton/templates/breadcrumbs",
 
     serialize: function() {
       var crumbs = _.clone(this.crumbs);
@@ -114,7 +114,7 @@ function(app, FauxtonAPI, resizeColumns) {
   });
 
   Fauxton.Footer = FauxtonAPI.View.extend({
-    template: "templates/fauxton/footer",
+    template: "addons/fauxton/templates/footer",
 
     initialize: function() {
       this.versionInfo = new Fauxton.VersionInfo();
@@ -133,7 +133,7 @@ function(app, FauxtonAPI, resizeColumns) {
 
   Fauxton.NavBar = FauxtonAPI.View.extend({
     className:"navbar",
-    template: "templates/fauxton/nav_bar",
+    template: "addons/fauxton/templates/nav_bar",
     // TODO: can we generate this list from the router?
     navLinks: [
       {href:"#/_all_dbs", title:"Databases", icon: "fonticon-database", className: 'databases'}
@@ -257,7 +257,7 @@ function(app, FauxtonAPI, resizeColumns) {
   });
 
   Fauxton.ApiBar = FauxtonAPI.View.extend({
-    template: "templates/fauxton/api_bar",
+    template: "addons/fauxton/templates/api_bar",
     endpoint: '_all_docs',
 
     documentation: 'docs',
@@ -310,7 +310,7 @@ function(app, FauxtonAPI, resizeColumns) {
       this.fade = options.fade === undefined ? true : options.fade;
       this.clear = options.clear;
       this.data = options.data || "";
-      this.template = options.template || "templates/fauxton/notification";
+      this.template = options.template || "addons/fauxton/templates/notification";
     },
 
     serialize: function() {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/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 7dcf2d7..96af169 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -32,7 +32,7 @@ function(app, FauxtonAPI, ace, spin) {
   var Components = FauxtonAPI.addon();
 
   Components.Pagination = FauxtonAPI.View.extend({
-    template: "templates/fauxton/pagination",
+    template: "addons/fauxton/templates/pagination",
 
     initialize: function(options) {
       this.page = parseInt(options.page, 10);
@@ -54,7 +54,7 @@ function(app, FauxtonAPI, ace, spin) {
   });
 
   Components.IndexPagination = FauxtonAPI.View.extend({
-    template: "templates/fauxton/index_pagination",
+    template: "addons/fauxton/templates/index_pagination",
     events: {
       "click a": 'scrollTo',
       "click a#next": 'nextClicked',

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/api_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/api_bar.html b/src/fauxton/app/templates/fauxton/api_bar.html
deleted file mode 100644
index 4fb5971..0000000
--- a/src/fauxton/app/templates/fauxton/api_bar.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<button class="btn btn-primary pull-right api-url-btn">
-  API URL 
-  <i class="fonticon-plus icon"></i>
-</button>
-<div class="api-navbar" style="display: none">
-    <div class="input-prepend input-append">
-      <span class="add-on">
-        API reference
-        <a href="<%=getDocUrl(documentation)%>" target="_blank">
-          <i class="icon-question-sign"></i>
-        </a>
-      </span>
-      <input type="text" class="input-xxlarge" value="<%= endpoint %>">
-      <a href="<%= endpoint %>" target="_blank" class="btn">Show me</a>
-    </div>
-</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/breadcrumbs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/breadcrumbs.html b/src/fauxton/app/templates/fauxton/breadcrumbs.html
deleted file mode 100644
index 34c4136..0000000
--- a/src/fauxton/app/templates/fauxton/breadcrumbs.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<ul class="breadcrumb">
-  <% _.each(_.initial(crumbs), function(crumb) { %>
-    <li>
-      <a href="#<%= crumb.link %>"><%= crumb.name %></a>
-      <i class="divider fonticon fonticon-carrot"> </i>
-    </li>
-  <% }); %>
-  <% var last = _.last(crumbs) || {name: ''} %>
-  <li class="active"><%= last.name %></li>
-</ul>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/footer.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/footer.html b/src/fauxton/app/templates/fauxton/footer.html
deleted file mode 100644
index 593c11f..0000000
--- a/src/fauxton/app/templates/fauxton/footer.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<p>Fauxton on <a href="http://couchdb.apache.org/">Apache CouchDB</a> <%=version%></p>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/index_pagination.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/index_pagination.html b/src/fauxton/app/templates/fauxton/index_pagination.html
deleted file mode 100644
index f445377..0000000
--- a/src/fauxton/app/templates/fauxton/index_pagination.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="pagination pagination-centered">
-  <ul>
-    <li <% if (!canShowPreviousfn()) {%> class="disabled" <% } %>>
-       <a id="previous" href="#"> Previous </a>
-     </li>
-     <li <% if (!canShowNextfn()) {%> class="disabled" <% } %>>
-       <a id="next" href="#"> Next </a></li>
-  </ul>
-</div>
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/nav_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/nav_bar.html b/src/fauxton/app/templates/fauxton/nav_bar.html
deleted file mode 100644
index 9ba24f4..0000000
--- a/src/fauxton/app/templates/fauxton/nav_bar.html
+++ /dev/null
@@ -1,75 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="brand">
-  <div class="burger">
-    <div><!-- * --></div>
-    <div><!-- * --></div>
-    <div><!-- * --></div>
-  </div>
-  <div class="icon">Apache Fauxton</div>
-</div>
-
-<nav id="main_navigation">
-  <ul id="nav-links" class="nav pull-right">
-    <% _.each(navLinks, function(link) { %>
-    <% if (link.view) {return;}  %>
-        <li data-nav-name= "<%= link.title %>" >
-          <a href="<%= link.href %>">
-            <i class="<%= link.icon %> fonticon"></i>
-            <%= link.title %>
-          </a>
-        </li>
-    <% }); %>
-  </ul>
-
-  <div id="footer-links">
-
-    <ul id="bottom-nav-links" class="nav">
-        <li data-nav-name= "Documentation">
-            <a href="<%=getDocUrl('docs')%>" target="_blank">
-              <i class="fonticon-bookmark fonticon"></i>
-                Documentation
-            </a>
-        </li>
-
-
-      <% _.each(bottomNavLinks, function(link) { %>
-      <% if (link.view) {return;}  %>
-        <li data-nav-name= "<%= link.title %>">
-            <a href="<%= link.href %>">
-              <i class="<%= link.icon %> fonticon"></i>
-              <%= link.title %>
-            </a>
-        </li>
-      <% }); %>
-    </ul>
-
-    <ul id="footer-nav-links" class="nav">
-      <% _.each(footerNavLinks, function(link) { %>
-      <% if (link.view) {return;}  %>
-        <li data-nav-name= "<%= link.title %>">
-            <a href="<%= link.href %>">
-              <i class="<%= link.icon %> fonticon"></i>
-              <%= link.title %>
-            </a>
-        </li>
-      <% }); %>
-    </ul>
-
-  </div>
-</nav>
-
-
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/notification.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/notification.html b/src/fauxton/app/templates/fauxton/notification.html
deleted file mode 100644
index ca8a903..0000000
--- a/src/fauxton/app/templates/fauxton/notification.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="alert alert-<%= type %>">
-  <button type="button" class="close" data-dismiss="alert">×</button>
-  <%= msg %>
-</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f7cb159/src/fauxton/app/templates/fauxton/pagination.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/pagination.html b/src/fauxton/app/templates/fauxton/pagination.html
deleted file mode 100644
index 19dfc8c..0000000
--- a/src/fauxton/app/templates/fauxton/pagination.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="pagination pagination-centered">
-  <ul>
-    <% if (page > 1) { %>
-    <li> <a href="<%= urlFun(page-1) %>">&laquo;</a></li>
-    <% } else { %>
-      <li class="disabled"> <a href="<%= urlFun(page) %>">&laquo;</a></li>
-    <% } %>
-    <% _.each(_.range(1, totalPages+1), function(i) { %>
-      <li <% if (page == i) { %>class="active"<% } %>> <a href="<%= urlFun(i) %>"><%= i %></a></li>
-    <% }) %>
-    <% if (page < totalPages) { %>
-      <li><a href="<%= urlFun(page+1) %>">&raquo;</a></li>
-    <% } else { %>
-      <li class="disabled"> <a href="<%= urlFun(page) %>">&raquo;</a></li>
-    <% } %>
-  </ul>
-</div>


[23/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton new view creation fix

Fixes issue COUCHDB-2201


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

Branch: refs/heads/2041-update-ibrowse
Commit: d2a3c3c09869954dbb3cabbd4543c036e55412f0
Parents: 4f7cb15
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Mar 13 10:01:31 2014 -0400
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Mar 13 14:04:00 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/routes.js | 58 ++++++++++++++++++-------
 src/fauxton/app/addons/documents/views.js  |  2 +
 2 files changed, 44 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a3c3c0/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 ff518e4..699a496 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -259,13 +259,7 @@ function(app, FauxtonAPI, Documents, Databases) {
         view: view,
         params: docParams
       });
-
-      var ddocInfo = {
-        id: "_design/" + decodeDdoc,
-        currView: view,
-        designDocs: this.data.designDocs
-      };
-
+     
       this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({
         model: this.data.database,
         ddocs: this.data.designDocs,
@@ -273,20 +267,20 @@ function(app, FauxtonAPI, Documents, Databases) {
         params: urlParams,
         newView: false,
         database: this.data.database,
-        ddocInfo: ddocInfo
+        ddocInfo: this.ddocInfo(decodeDdoc, this.data.designDocs, view)
       }));
 
       if (this.toolsView) { this.toolsView.remove(); }
 
-      this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
+      this.documentsView = this.createViewDocumentsView({
+        designDoc: decodeDdoc,
+        docParams: docParams, 
+        urlParams: urlParams,
         database: this.data.database,
-        collection: this.data.indexedDocs,
-        nestedView: Documents.Views.Row,
-        viewList: true,
-        ddocInfo: ddocInfo,
-        docParams: docParams,
-        params: urlParams
-      }));
+        indexedDocs: this.data.indexedDocs,
+        designDocs: this.data.designDocs,
+        view: view
+      });
 
       this.sidebar.setSelectedTab(app.utils.removeSpecialCharacters(ddoc) + '_' + app.utils.removeSpecialCharacters(view));
 
@@ -300,6 +294,27 @@ function(app, FauxtonAPI, Documents, Databases) {
       Documents.paginate.reset();
     },
 
+    ddocInfo: function (designDoc, designDocs, view) {
+      return {
+        id: "_design/" + designDoc,
+        currView: view,
+        designDocs: designDocs
+      };
+    },
+
+    createViewDocumentsView: function (options) { 
+
+      return this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
+        database: options.database,
+        collection: options.indexedDocs,
+        nestedView: Documents.Views.Row,
+        viewList: true,
+        ddocInfo: this.ddocInfo(options.designDoc, options.designDocs, options.view),
+        docParams: options.docParams,
+        params: options.urlParams
+      }));
+    },
+
     newViewEditor: function () {
       var params = app.getParams();
 
@@ -347,6 +362,17 @@ function(app, FauxtonAPI, Documents, Databases) {
           params: docParams
         });
 
+        if (!this.documentsView) {
+          this.documentsView = this.createViewDocumentsView({
+            designDoc: ddoc,
+            docParams: docParams, 
+            urlParams: urlParams,
+            database: this.data.database,
+            indexedDocs: this.indexedDocs,
+            designDocs: this.data.designDocs,
+            view: view
+          });
+        }
       }
 
       this.documentsView.setCollection(collection);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d2a3c3c0/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 48075e8..56e9911 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1639,6 +1639,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       if(this.ddocInfoView){
         this.ddocInfoView.remove();
       } 
+
+      if (this.newView) { return; }
       this.ddocInfoView = this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
       this.ddocInfoView.render();
 


[16/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
s/MVC/MVCC in replication protocol docs


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

Branch: refs/heads/2041-update-ibrowse
Commit: b4332e437f12de4c65de7484d2d1cd0b52bd4d32
Parents: 0e33059
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Oct 21 10:02:11 2013 -0400
Committer: BigBlueHat <by...@bigbluehat.com>
Committed: Thu Mar 13 09:38:24 2014 -0400

----------------------------------------------------------------------
 share/doc/src/replication/protocol.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b4332e43/share/doc/src/replication/protocol.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/replication/protocol.rst b/share/doc/src/replication/protocol.rst
index c5a8181..0f6fdfd 100644
--- a/share/doc/src/replication/protocol.rst
+++ b/share/doc/src/replication/protocol.rst
@@ -40,7 +40,7 @@ provided by the couch_replicator_ module available in Apache CouchDB.
 
 The CouchDB_ replication protocol is using the `CouchDB REST API
 <http://wiki.apache.org/couchdb/Reference>`_ and so is based on HTTP and
-the Apache CouchDB MVC Data model. The primary goal of this
+the Apache CouchDB MVCC Data model. The primary goal of this
 specification is to describe the CouchDB replication algorithm.
 
 


[12/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
More deferred support to jquery.couch.js

COUCHDB-1180

Signed-off-by: Alexander Shorin <kx...@apache.org>


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

Branch: refs/heads/2041-update-ibrowse
Commit: 160f826e5f61f52bd7830e47f45738bedde11137
Parents: e7548b2
Author: Dale Harvey <da...@arandomurl.com>
Authored: Tue Mar 11 15:16:13 2014 +0400
Committer: Alexander Shorin <kx...@apache.org>
Committed: Tue Mar 11 15:17:39 2014 +0400

----------------------------------------------------------------------
 share/www/script/jquery.couch.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/160f826e/share/www/script/jquery.couch.js
----------------------------------------------------------------------
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index facaf9c..ffbad34 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -160,7 +160,7 @@
      * @private
      */
     userDb : function(callback) {
-      $.couch.session({
+      return $.couch.session({
         success : function(resp) {
           var userDb = $.couch.db(resp.info.authentication_db);
           callback(userDb);
@@ -187,7 +187,7 @@
       var user_prefix = "org.couchdb.user:";
       user_doc._id = user_doc._id || user_prefix + user_doc.name;
 
-      $.couch.userDb(function(db) {
+      return $.couch.userDb(function(db) {
         db.saveDoc(user_doc, options);
       });
     },


[27/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: highlight databases with more deleted docs than existing

Fixes COUCHDB-2110


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

Branch: refs/heads/2041-update-ibrowse
Commit: b8accb4eb7c46e3888416afc4aff407487f2f21c
Parents: a17bf86
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Fri Mar 14 20:45:31 2014 +0100
Committer: Robert Kowalski <ro...@kowalski.gd>
Committed: Fri Mar 14 20:45:43 2014 +0100

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/resources.js   |  8 ++++
 .../app/addons/databases/templates/item.html    |  8 +++-
 .../app/addons/databases/tests/resourcesSpec.js | 39 ++++++++++++++++++++
 src/fauxton/app/addons/databases/views.js       |  1 +
 4 files changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/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 80cd533..f8aab96 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -123,6 +123,14 @@ function(app, FauxtonAPI, Documents) {
       return this.get("doc_count");
     },
 
+    numDeletedDocs: function() {
+      return this.get("doc_del_count");
+    },
+
+    isGraveYard: function() {
+      return this.numDeletedDocs() > this.numDocs();
+    },
+
     updateSeq: function(full) {
       var updateSeq = this.get("update_seq");
       if (full || (typeof(updateSeq) === 'number')) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/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 549f421..304ab78 100644
--- a/src/fauxton/app/addons/databases/templates/item.html
+++ b/src/fauxton/app/addons/databases/templates/item.html
@@ -16,7 +16,13 @@ the License.
   <a href="#/database/<%=encoded%>/_all_docs"><%= database.get("name") %></a>
 </td>
 <td><%= database.status.humanSize() %></td>
-<td><%= database.status.numDocs() %></td>
+<td>
+  <%= database.status.numDocs() %>
+  <% if (database.status.isGraveYard()) { %>
+    <i class="js-db-graveyard icon icon-exclamation-sign" data-toggle="tooltip"
+      title="This database has just <%= database.status.numDocs() %> docs and <%= database.status.numDeletedDocs() %> deleted docs"></i>
+  <% } %>
+</td>
 <td><%= database.status.updateSeq() %></td>
 <td>
   <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/src/fauxton/app/addons/databases/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/tests/resourcesSpec.js b/src/fauxton/app/addons/databases/tests/resourcesSpec.js
new file mode 100644
index 0000000..8e3fee4
--- /dev/null
+++ b/src/fauxton/app/addons/databases/tests/resourcesSpec.js
@@ -0,0 +1,39 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+      'api',
+      'addons/databases/resources',
+      'addons/databases/views',
+      'testUtils'
+], function (FauxtonAPI, Resources, Views, testUtils) {
+  var assert = testUtils.assert,
+      ViewSandbox = testUtils.ViewSandbox;
+
+  describe("Databases: List", function () {
+
+    describe("List items", function () {
+
+      it("detects graveyards", function () {
+        var modelWithGraveYard = new Resources.Status({
+          doc_count: 5,
+          doc_del_count: 6
+        });
+        var modelWithoutGraveYard = new Resources.Status({
+          doc_count: 6,
+          doc_del_count: 5
+        });
+        assert.ok(modelWithGraveYard.isGraveYard());
+        assert.ok(!modelWithoutGraveYard.isGraveYard());
+      });
+    });
+  });
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/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 ef52b2f..d632486 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -137,6 +137,7 @@ function(app, Components, FauxtonAPI, Databases) {
         }
       });
       this.dbSearchTypeahead.render();
+      this.$el.find(".js-db-graveyard").tooltip();
     },
 
     selectAll: function(evt){


[25/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Added Autocomplete for config sections
Form Validation
Updating selectors with the js-prefix
Added modal to makefile.
Removed debugging alert.
Cleaned up error messaging to be consistent.


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

Branch: refs/heads/2041-update-ibrowse
Commit: 33b6e3509880ac271be26d75e1094e2296c139f6
Parents: a355997
Author: suelockwood <de...@apache.org>
Authored: Fri Mar 14 11:04:26 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Fri Mar 14 11:08:50 2014 -0400

----------------------------------------------------------------------
 src/Makefile.am                                 |   2 +
 .../app/addons/config/assets/less/config.less   |   2 +-
 src/fauxton/app/addons/config/resources.js      |   4 +
 src/fauxton/app/addons/config/routes.js         |   1 -
 .../app/addons/config/templates/dashboard.html  |  29 +---
 .../app/addons/config/templates/modal.html      |  33 +++++
 src/fauxton/app/addons/config/views.js          | 136 +++++++++++++++----
 src/fauxton/app/addons/fauxton/components.js    |  53 ++++----
 8 files changed, 179 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index a5eea39..89a6afd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,6 +70,8 @@ FAUXTON_FILES = \
     fauxton/app/addons/config/resources.js \
     fauxton/app/addons/config/views.js \
     fauxton/app/addons/config/routes.js \
+    fauxton/app/addons/config/views.js \
+    fauxton/app/addons/config/templates/modal.html \
     fauxton/app/addons/config/templates/dashboard.html \
     fauxton/app/addons/config/templates/item.html \
     fauxton/app/addons/config/tests/resourcesSpec.js \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 44311de..2807708 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -27,7 +27,7 @@
   button {width: 7%;}
 }
 
-#add-section-modal {
+#add-section-modal .modal {
   width: 400px;
 }
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index ec8cc98..317e355 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -13,12 +13,14 @@
 define([
   "app",
   "api"
+
 ],
 
 function (app, FauxtonAPI) {
 
   var Config = FauxtonAPI.addon();
 
+
   Config.Model = Backbone.Model.extend({});
   Config.OptionModel = Backbone.Model.extend({
     documentation: "config",
@@ -75,5 +77,7 @@ function (app, FauxtonAPI) {
     }
   });
 
+ 
+
   return Config;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/fauxton/app/addons/config/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js
index 519e25f..affb453 100644
--- a/src/fauxton/app/addons/config/routes.js
+++ b/src/fauxton/app/addons/config/routes.js
@@ -12,7 +12,6 @@
 
 define([
        "app",
-
        "api",
 
        // Modules

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/fauxton/app/addons/config/templates/dashboard.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/dashboard.html b/src/fauxton/app/addons/config/templates/dashboard.html
index c14402c..37ae634 100644
--- a/src/fauxton/app/addons/config/templates/dashboard.html
+++ b/src/fauxton/app/addons/config/templates/dashboard.html
@@ -13,10 +13,10 @@ the License.
 -->
 
 <div class="row">
-    <button id="add-section" href="#" class="btn btn-primary pull-right">
-      <i class="icon icon-plus icon-white"> </i>
-      Add Section
-    </button>
+  <button id="js-add-section" href="#" class="btn btn-primary pull-right">
+    <i class="icon icon-plus icon-white"> </i>
+    Add Section
+  </button>
 </div>
 <table class="config table table-striped table-bordered">
   <thead>
@@ -28,23 +28,4 @@ the License.
   <tbody>
   </tbody>
 </table>
-<div id="add-section-modal" class="modal hide fade">
-  <div class="modal-header">
-    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-    <h3>Create Config Option</h3>
-  </div>
-  <div class="modal-body">
-    <form id="add-section-form" class="form well">
-      <label>Section</label>
-      <input type="text" name="section" placeholder="Section">
-      <span class="help-block">Enter an existing section name to add to it.</span>
-      <input type="text" name="name" placeholder="Name">
-      <br/>
-      <input type="text" name="value" placeholder="Value">
-      <div class="modal-footer">
-        <button type="button" class="btn" data-dismiss="modal">Cancel</button>
-        <button type="submit" class="btn btn-primary"> Save </button>
-      </div>
-    </form>
-  </div>
-</div>
+<div id="add-section-modal"></div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/fauxton/app/addons/config/templates/modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/modal.html b/src/fauxton/app/addons/config/templates/modal.html
new file mode 100644
index 0000000..f32bd10
--- /dev/null
+++ b/src/fauxton/app/addons/config/templates/modal.html
@@ -0,0 +1,33 @@
+  <!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+
+<div class="modal-header">
+  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+  <h3>Create Config Option</h3>
+</div>
+<div class="modal-body">
+  <div class="js-form-error-config"></div>
+  <form id="js-add-section-form" class="form well">
+    <label>Section</label>
+    <input type="text" name="section" placeholder="Section" >
+    <span class="help-block">Enter an existing section name to add to it.</span>
+    <input type="text" name="name" placeholder="Name">
+    <br/>
+    <input type="text" name="value" placeholder="Value">
+    <div class="modal-footer">
+      <button type="button" class="btn" data-dismiss="modal">Cancel</button>
+      <button type="submit" class="btn btn-primary"> Save </button>
+    </div>
+  </form>
+</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/src/fauxton/app/addons/config/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/views.js b/src/fauxton/app/addons/config/views.js
index bd05652..0468cd1 100644
--- a/src/fauxton/app/addons/config/views.js
+++ b/src/fauxton/app/addons/config/views.js
@@ -1,4 +1,4 @@
- // Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// 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
 //
@@ -14,11 +14,13 @@ define([
   "app",
   "api",
   "addons/config/resources",
+  "addons/fauxton/components"
 ],
+function(app, FauxtonAPI, Config, Components) {
+  var Views ={},
+      Events = {};
 
-function (app, FauxtonAPI, Config) {
-
-  var Views = {};
+  Views.Events = _.extend(Events, Backbone.Events);
 
   Views.TableRow = FauxtonAPI.View.extend({
     tagName: "tr",
@@ -59,7 +61,6 @@ function (app, FauxtonAPI, Config) {
       }
     },
 
-
     discardValue: function (event) {
       this.$(".js-edit-value-form").addClass("js-hidden");
       this.$(".js-show-value").removeClass("js-hidden");
@@ -84,12 +85,63 @@ function (app, FauxtonAPI, Config) {
     template: "addons/config/templates/dashboard",
 
     events: {
-      "click #add-section": "addSection",
-      "submit #add-section-form": "submitForm"
+      "click #js-add-section": "addSection"
     },
 
-    submitForm: function (event) {
+    initialize: function(){
+      this.listenTo(Views.Events, "newSection", this.render);
+    },
+
+    addSection: function (event) {
       event.preventDefault();
+      this.modal.show();
+    },
+
+    beforeRender: function() {
+      this.modal = this.insertView("#add-section-modal", new Views.Modal({
+                      collection: this.collection
+                    }));
+
+      this.modal.render();
+
+      this.collection.each(function(config) {
+        _.each(config.get("options"), function (option, index) {
+          this.insertView("table.config tbody", new Views.TableRow({
+            model: new Config.OptionModel({
+              section: config.get("section"),
+              name: option.name,
+              value: option.value,
+              index: index
+            })
+          }));
+        }, this);
+      }, this);
+    },
+
+    establish: function() {
+      return [this.collection.fetch()];
+    }
+  });
+
+  Views.Modal = FauxtonAPI.View.extend({
+    className: "modal hide fade",
+    template:  "addons/config/templates/modal",
+    events: {
+      "submit #js-add-section-form": "validate"
+    },
+    initialize: function(){
+      this.sourceArray = _.map(this.collection.toJSON(), function(item, key){ 
+        return item.section; 
+      });
+    },
+    afterRender: function(){
+      this.sectionTypeAhead = new Components.Typeahead({
+        source: this.sourceArray,
+        el: 'input[name="section"]'
+      });
+      this.sectionTypeAhead.render();
+    },
+    submitForm: function (event) {
       var option = new Config.OptionModel({
         section: this.$('input[name="section"]').val(),
         name: this.$('input[name="name"]').val(),
@@ -111,34 +163,58 @@ function (app, FauxtonAPI, Config) {
         });
       }
 
-      this.$("#add-section-modal").modal('hide');
-      this.render();
-    },
+      this.hide();
+      Views.Events.trigger("newSection");
 
-    addSection: function (event) {
+    },
+    isNew: function(collection){
+      var sectionName = this.$('input[name="section"]').val(),
+          name = this.$('input[name="name"]').val();
+          var section = _.findWhere(collection.toJSON(), {"section":sectionName});
+          var options = _.findWhere(section.options, {name: name});
+          
+          return options;
+    },
+    isSection: function(){
+      var section = this.$('input[name="section"]').val();
+      return _.find(this.sourceArray, function(item){ return item === section; });
+    },
+    validate: function (event){
       event.preventDefault();
-      this.$("#add-section-modal").modal({show:true});
+      var section = this.$('input[name="section"]').val(),
+          name = this.$('input[name="name"]').val(),
+          value = this.$('input[name="value"]').val(),
+          collection = this.collection;
+
+      if(!this.isSection()){
+         this.errorMessage("You need to use an existing section");
+      } else if (!name) {
+        this.errorMessage("Add a name");
+      } else if (!value) {
+        this.errorMessage("Add a value");
+      } else if (this.isNew(collection)){
+        this.errorMessage("Must have a unique name");
+      } else {
+        this.submitForm();
+      }
     },
-
-    beforeRender: function() {
-      this.collection.each(function(config) {
-        _.each(config.get("options"), function (option, index) {
-          this.insertView("table.config tbody", new Views.TableRow({
-            model: new Config.OptionModel({
-              section: config.get("section"),
-              name: option.name,
-              value: option.value,
-              index: index
-            })
-          }));
-        }, this);
-      }, this);
+    errorMessage: function(msg){
+      this.error = FauxtonAPI.addNotification({
+          msg: msg,
+          type: "error",
+          clear: true,
+          selector: ".js-form-error-config"
+      });
     },
-
-    establish: function() {
-      return [this.collection.fetch()];
+    show: function(){
+      this.$el.modal({show:true});
+    },
+    hide: function(){
+      this.$el.modal('hide');
     }
+
   });
 
   return Views;
+
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/33b6e350/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 96af169..25f623c 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -210,32 +210,7 @@ function(app, FauxtonAPI, ace, spin) {
 
   });
 
-  //TODO allow more of the typeahead options.
-  //Current this just does what we need but we
-  //need to support the other typeahead options.
-  Components.Typeahead = FauxtonAPI.View.extend({
-
-    initialize: function (options) {
-      this.source = options.source;
-      _.bindAll(this);
-    },
 
-    afterRender: function () {
-      var onUpdate = this.onUpdate;
-
-      this.$el.typeahead({
-        source: this.source,
-        updater: function (item) {
-          if (onUpdate) {
-            onUpdate(item);
-          }
-
-          return item;
-        }
-      });
-    }
-
-  });
 
   Components.ModalView = FauxtonAPI.View.extend({
 
@@ -279,6 +254,34 @@ function(app, FauxtonAPI, ace, spin) {
     }
   });
 
+  //TODO allow more of the typeahead options.
+  //Current this just does what we need but we
+  //need to support the other typeahead options.
+  Components.Typeahead = FauxtonAPI.View.extend({
+
+    initialize: function (options) {
+      this.source = options.source;
+      this.onUpdate = options.onUpdate;
+      _.bindAll(this);
+    },
+
+    afterRender: function () {
+      var onUpdate = this.onUpdate;
+
+      this.$el.typeahead({
+        source: this.source,
+        updater: function (item) {
+          if (onUpdate) {
+            onUpdate(item);
+          }
+
+          return item;
+        }
+      });
+    }
+
+  });
+
   Components.DbSearchTypeahead = Components.Typeahead.extend({
     initialize: function (options) {
       this.dbLimit = options.dbLimit || 30;


[13/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Add deferred support to jquery.couch.js

COUCHDB-1036 COUCHDB-1180

This closes #169

Signed-off-by: Alexander Shorin <kx...@apache.org>


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

Branch: refs/heads/2041-update-ibrowse
Commit: e7548b2e51ffed71b8a770207a5dd33d7ed49049
Parents: fffc5b7
Author: telis94 <do...@hotmail.com>
Authored: Tue Mar 11 15:15:48 2014 +0400
Committer: Alexander Shorin <kx...@apache.org>
Committed: Tue Mar 11 15:17:39 2014 +0400

----------------------------------------------------------------------
 share/www/script/jquery.couch.js | 57 ++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e7548b2e/share/www/script/jquery.couch.js
----------------------------------------------------------------------
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index e78b67e..facaf9c 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -70,7 +70,7 @@
      * /#jQuery-ajax-settings">jQuery ajax settings</a>
      */
     activeTasks: function(options) {
-      ajax(
+      return ajax(
         {url: this.urlPrefix + "/_active_tasks"},
         options,
         "Active task status could not be retrieved"
@@ -85,7 +85,7 @@
      * /#jQuery-ajax-settings">jQuery ajax settings</a>
      */
     allDbs: function(options) {
-      ajax(
+      return ajax(
         {url: this.urlPrefix + "/_all_dbs"},
         options,
         "An error occurred retrieving the list of all databases"
@@ -123,7 +123,7 @@
         req.processData = false
       }
 
-      ajax(req, options,
+      return ajax(req, options,
         "An error occurred retrieving/updating the server configuration"
       );
     },
@@ -138,7 +138,7 @@
      */
     session: function(options) {
       options = options || {};
-      ajax({
+      return ajax({
         type: "GET", url: this.urlPrefix + "/_session",
         beforeSend: function(xhr) {
             xhr.setRequestHeader('Accept', 'application/json');
@@ -203,7 +203,7 @@
      */
     login: function(options) {
       options = options || {};
-      $.ajax({
+      return $.ajax({
         type: "POST", url: this.urlPrefix + "/_session", dataType: "json",
         data: {name: options.name, password: options.password},
         beforeSend: function(xhr) {
@@ -233,7 +233,7 @@
      */
     logout: function(options) {
       options = options || {};
-      $.ajax({
+      return $.ajax({
         type: "DELETE", url: this.urlPrefix + "/_session", dataType: "json",
         username : "_", password : "_",
         beforeSend: function(xhr) {
@@ -296,7 +296,7 @@
          */
         compact: function(options) {
           $.extend(options, {successStatus: 202});
-          ajax({
+          return ajax({
               type: "POST", url: this.uri + "_compact",
               data: "", processData: false
             },
@@ -314,7 +314,7 @@
          */
         viewCleanup: function(options) {
           $.extend(options, {successStatus: 202});
-          ajax({
+          return ajax({
               type: "POST", url: this.uri + "_view_cleanup",
               data: "", processData: false
             },
@@ -337,7 +337,7 @@
          */
         compactView: function(groupname, options) {
           $.extend(options, {successStatus: 202});
-          ajax({
+          return ajax({
               type: "POST", url: this.uri + "_compact/" + groupname,
               data: "", processData: false
             },
@@ -355,7 +355,7 @@
          */
         create: function(options) {
           $.extend(options, {successStatus: 201});
-          ajax({
+          return ajax({
               type: "PUT", url: this.uri, contentType: "application/json",
               data: "", processData: false
             },
@@ -373,7 +373,7 @@
          * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
          */
         drop: function(options) {
-          ajax(
+          return ajax(
             {type: "DELETE", url: this.uri},
             options,
             "The database could not be deleted"
@@ -388,7 +388,7 @@
          * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
          */
         info: function(options) {
-          ajax(
+          return ajax(
             {url: this.uri},
             options,
             "Database information could not be retrieved"
@@ -501,7 +501,7 @@
             delete options["keys"];
             data = toJSON({ "keys": keys });
           }
-          ajax({
+          return ajax({
               type: type,
               data: data,
               url: this.uri + "_all_docs" + encodeOptions(options)
@@ -517,7 +517,7 @@
          * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
          */
         allDesignDocs: function(options) {
-          this.allDocs($.extend(
+          return this.allDocs($.extend(
             {startkey:"_design", endkey:"_design0"}, options));
         },
 
@@ -532,7 +532,7 @@
           options = options || {};
           var self = this;
           if (options.eachApp) {
-            this.allDesignDocs({
+            return this.allDesignDocs({
               success: function(resp) {
                 $.each(resp.rows, function() {
                   self.openDoc(this.id, {
@@ -591,7 +591,8 @@
               }
             });
           }
-          ajax({url: this.uri + encodeDocId(docId) + encodeOptions(options)},
+          return ajax(
+            {url: this.uri + encodeDocId(docId) + encodeOptions(options)},
             options,
             "The document could not be retrieved",
             ajaxOptions
@@ -622,7 +623,7 @@
             var uri = this.uri + encodeDocId(doc._id);
           }
           var versioned = maybeApplyVersion(doc);
-          $.ajax({
+          return $.ajax({
             type: method, url: uri + encodeOptions(options),
             contentType: "application/json",
             dataType: "json", data: toJSON(doc),
@@ -663,7 +664,7 @@
         bulkSave: function(docs, options) {
           var beforeSend = fullCommit(options);
           $.extend(options, {successStatus: 201, beforeSend : beforeSend});
-          ajax({
+          return ajax({
               type: "POST",
               url: this.uri + "_bulk_docs" + encodeOptions(options),
               contentType: "application/json", data: toJSON(docs)
@@ -684,7 +685,7 @@
          * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
          */
         removeDoc: function(doc, options) {
-          ajax({
+          return ajax({
               type: "DELETE",
               url: this.uri +
                    encodeDocId(doc._id) +
@@ -710,7 +711,7 @@
             }
           );
           $.extend(options, {successStatus: 201});
-          ajax({
+          return ajax({
               type: "POST",
               url: this.uri + "_bulk_docs" + encodeOptions(options),
               data: toJSON(docs)
@@ -744,7 +745,7 @@
               }
             }
           });
-          ajax({
+          return ajax({
               type: "COPY",
               url: this.uri + encodeDocId(docId)
             },
@@ -779,7 +780,7 @@
                 : "(" + reduceFun.toString() + ")";
             body.reduce = reduceFun;
           }
-          ajax({
+          return ajax({
               type: "POST",
               url: this.uri + "_temp_view" + encodeOptions(options),
               contentType: "application/json", data: toJSON(body)
@@ -814,7 +815,7 @@
             delete options['keys'];
             data = toJSON({'keys': keys });
           }
-          ajax({
+          return ajax({
               type: type,
               data: data,
               url: this.uri + '_design/' + list[0] +
@@ -847,7 +848,7 @@
             delete options["keys"];
             data = toJSON({ "keys": keys });
           }
-          ajax({
+          return ajax({
               type: type,
               data: data,
               url: this.uri + "_design/" + name[0] +
@@ -866,7 +867,7 @@
          * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
          */
         getDbProperty: function(propName, options, ajaxOptions) {
-          ajax({url: this.uri + propName + encodeOptions(options)},
+          return ajax({url: this.uri + propName + encodeOptions(options)},
             options,
             "The property could not be retrieved",
             ajaxOptions
@@ -883,7 +884,7 @@
          * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
          */
         setDbProperty: function(propName, propValue, options, ajaxOptions) {
-          ajax({
+          return ajax({
             type: "PUT",
             url: this.uri + propName + encodeOptions(options),
             data : JSON.stringify(propValue)
@@ -910,7 +911,7 @@
      * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a>
      */
     info: function(options) {
-      ajax(
+      return ajax(
         {url: this.urlPrefix + "/"},
         options,
         "Server information could not be retrieved"
@@ -932,7 +933,7 @@
       if (repOpts.continuous && !repOpts.cancel) {
         ajaxOptions.successStatus = 202;
       }
-      ajax({
+      return ajax({
           type: "POST", url: this.urlPrefix + "/_replicate",
           data: JSON.stringify(repOpts),
           contentType: "application/json"


[11/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
COUCHDB-2189 - fix for polling bug


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

Branch: refs/heads/2041-update-ibrowse
Commit: fffc5b73d6714076b60ff5a2434d4bfaa8264183
Parents: ce91d81
Author: suelockwood <de...@apache.org>
Authored: Mon Mar 10 16:34:10 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Mon Mar 10 16:34:10 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/views.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/fffc5b73/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 b51ea08..48075e8 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1588,7 +1588,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
            that.showEditors();
         });
       } else if ($targetId === "meta-nav"){
-        if ($previousTab.attr('id') !== "metadata"){
+        if (!$("#ddoc-info").is(":visible")){
           this.ddocInfoView.startRefreshInterval();
         } 
         $targetTab.toggle('slow'); 


[09/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Quick doc edit for clarity.

This closes #170

Signed-off-by: Alexander Shorin <kx...@apache.org>


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

Branch: refs/heads/2041-update-ibrowse
Commit: 023da37ca4ec3020bb7355059285c9ec2f6de786
Parents: 0af1b09
Author: Michael Wheeler <mp...@gmail.com>
Authored: Fri Mar 7 11:26:54 2014 -0500
Committer: Alexander Shorin <kx...@apache.org>
Committed: Mon Mar 10 22:51:07 2014 +0400

----------------------------------------------------------------------
 share/doc/src/api/ddoc/common.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/023da37c/share/doc/src/api/ddoc/common.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/api/ddoc/common.rst b/share/doc/src/api/ddoc/common.rst
index 8ff571b..9f76e3a 100644
--- a/share/doc/src/api/ddoc/common.rst
+++ b/share/doc/src/api/ddoc/common.rst
@@ -46,7 +46,7 @@
   a new revision of the existing design document.
 
   The design documents have some agreement upon their fields and structure.
-  Currently it is the next:
+  Currently it is the following:
 
   * **language** (*string*): Defines :ref:`Query Server <query-server>`
     :config:section:`key <query_servers>` to process design document functions


[19/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: use class instead of inline-style


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

Branch: refs/heads/2041-update-ibrowse
Commit: a07924df35f9bc9c555f2a49b1b84d174896e5b1
Parents: b4332e4
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Mar 11 19:24:10 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:43:23 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/config/assets/less/config.less | 3 +++
 src/fauxton/app/addons/config/resources.js            | 8 ++++----
 src/fauxton/app/addons/config/templates/item.html     | 4 ++--
 3 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a07924df/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 651cbe3..44311de 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -21,6 +21,9 @@
   .js-delete-value {
     cursor: pointer;
   }
+  .js-hidden {
+    display: none;
+  }
   button {width: 7%;}
 }
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a07924df/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index b5c0b6c..8f9ab08 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -97,8 +97,8 @@ function (app, FauxtonAPI) {
     },
 
     editValue: function (event) {
-      this.$(".js-show-value").hide();
-      this.$(".js-edit-value-form").show();
+      this.$(".js-show-value").addClass("js-hidden");
+      this.$(".js-edit-value-form").removeClass("js-hidden");
     },
 
     saveValue: function (event) {
@@ -107,8 +107,8 @@ function (app, FauxtonAPI) {
     },
 
     cancelEdit: function (event) {
-      this.$(".js-edit-value-form").hide();
-      this.$(".js-show-value").show();
+      this.$(".js-edit-value-form").addClass("js-hidden");
+      this.$(".js-show-value").removeClass("js-hidden");
     },
 
     serialize: function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a07924df/src/fauxton/app/addons/config/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html
index a628fe6..108fa58 100644
--- a/src/fauxton/app/addons/config/templates/item.html
+++ b/src/fauxton/app/addons/config/templates/item.html
@@ -20,9 +20,9 @@ the License.
 <td > <%= option.name %> </td>
 <td class="js-edit-value">
   <div class="js-show-value">
-    <%= option.value %> 
+    <%= option.value %>
   </div>
-  <div class="js-edit-value-form" style="display:none">
+  <div class="js-edit-value-form js-hidden">
     <input class="js-value-input" type="text" value="<%- option.value %>" />
     <button class="js-save-value btn btn-success fonticon-circle-check btn-small"> </button>
     <button class="js-cancel-value btn btn-small fonticon-circle-x"> </button>


[15/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fauxton: do not redirect after removing a filter

Fixes #COUCHDB-2196


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

Branch: refs/heads/2041-update-ibrowse
Commit: 0e33059e929e2f9ee41bcd743768daa3dae716e2
Parents: 8276adf
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Mar 11 22:41:54 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Wed Mar 12 10:47:04 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/logs/templates/filterItem.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0e33059e/src/fauxton/app/addons/logs/templates/filterItem.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/templates/filterItem.html b/src/fauxton/app/addons/logs/templates/filterItem.html
index c4e885a..e3872d8 100644
--- a/src/fauxton/app/addons/logs/templates/filterItem.html
+++ b/src/fauxton/app/addons/logs/templates/filterItem.html
@@ -13,4 +13,4 @@ the License.
 -->
 
 <span class="label label-info"> <%= filter %>  </span>
-<a class="label label-info remove-filter" href="#">&times;</a>
+<a class="label label-info remove-filter" data-bypass="true" href="#">&times;</a>


[08/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fixed the configs to be double click to edit.

Fixed the templates to not use IDs as selectors (BAD)

Fixed the underscore values for inputs to be HTML-escaped

Centered the table rows


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

Branch: refs/heads/2041-update-ibrowse
Commit: 0af1b0959d13641c1e0d9c7e032098914581735e
Parents: 8d37ee3
Author: suelockwood <de...@apache.org>
Authored: Mon Mar 10 13:24:50 2014 -0400
Committer: suelockwood <de...@apache.org>
Committed: Mon Mar 10 13:26:23 2014 -0400

----------------------------------------------------------------------
 .../app/addons/config/assets/less/config.less   | 24 ++++++++++++--------
 src/fauxton/app/addons/config/resources.js      | 18 +++++++--------
 .../app/addons/config/templates/dashboard.html  |  4 ++--
 .../app/addons/config/templates/item.html       | 18 +++++++--------
 4 files changed, 35 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0af1b095/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 88bbc66..651cbe3 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -11,19 +11,17 @@
  *  the License.
  */
 .config-item {
-  height: 41px;
+  height: 65px;
 
-  td:hover .edit-button {
-    display: block;
+  .js-value-input {
+    width: 80%;
+    margin: 0;
   }
-
-  .value-input {
-    width: 98%;
-  }
-
-  #delete-value {
+  .js-show-value,
+  .js-delete-value {
     cursor: pointer;
   }
+  button {width: 7%;}
 }
 
 #add-section-modal {
@@ -33,3 +31,11 @@
 #config-trash {
   width: 5%;
 }
+
+table.config {
+  tr {
+    th, td {
+      vertical-align: middle;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0af1b095/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index 227e80d..b5c0b6c 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -81,10 +81,10 @@ function (app, FauxtonAPI) {
     template: "addons/config/templates/item",
 
     events: {
-      "click .edit-button": "editValue",
-      "click #delete-value": "deleteValue",
-      "click #cancel-value": "cancelEdit",
-      "click #save-value": "saveValue"
+      "dblclick .js-edit-value": "editValue",
+      "click .js-delete-value": "deleteValue",
+      "click .js-cancel-value": "cancelEdit",
+      "click .js-save-value": "saveValue"
     },
 
     deleteValue: function (event) {
@@ -97,18 +97,18 @@ function (app, FauxtonAPI) {
     },
 
     editValue: function (event) {
-      this.$("#show-value").hide();
-      this.$("#edit-value-form").show();
+      this.$(".js-show-value").hide();
+      this.$(".js-edit-value-form").show();
     },
 
     saveValue: function (event) {
-      this.model.save({value: this.$(".value-input").val()});
+      this.model.save({value: this.$(".js-value-input").val()});
       this.render();
     },
 
     cancelEdit: function (event) {
-      this.$("#edit-value-form").hide();
-      this.$("#show-value").show();
+      this.$(".js-edit-value-form").hide();
+      this.$(".js-show-value").show();
     },
 
     serialize: function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0af1b095/src/fauxton/app/addons/config/templates/dashboard.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/dashboard.html b/src/fauxton/app/addons/config/templates/dashboard.html
index b7dbc55..c14402c 100644
--- a/src/fauxton/app/addons/config/templates/dashboard.html
+++ b/src/fauxton/app/addons/config/templates/dashboard.html
@@ -20,8 +20,8 @@ the License.
 </div>
 <table class="config table table-striped table-bordered">
   <thead>
-    <th id="config-section"> Section </th>
-    <th id="config-option"> Option </th>
+    <th id="config-section" width="20%"> Section </th>
+    <th id="config-option" width="20%"> Option </th>
     <th id="config-value"> Value </th>
     <th id="config-trash"></th>
   </thead>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0af1b095/src/fauxton/app/addons/config/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html
index 502c9b3..a628fe6 100644
--- a/src/fauxton/app/addons/config/templates/item.html
+++ b/src/fauxton/app/addons/config/templates/item.html
@@ -17,15 +17,15 @@ the License.
 <% } else { %>
 <td></td>
 <% } %>
-<td> <%= option.name %> </td>
-<td>
-  <div id="show-value">
-    <%= option.value %> <button class="btn btn-mini pull-right hide edit-button"> Edit </button>
+<td > <%= option.name %> </td>
+<td class="js-edit-value">
+  <div class="js-show-value">
+    <%= option.value %> 
   </div>
-  <div id="edit-value-form" style="display:none">
-    <input class="value-input" type="text" value="<%= option.value %>" />
-    <button id="save-value" class="btn btn-success btn-small"> Save </button>
-    <button id="cancel-value" class="btn btn-small"> Cancel </button>
+  <div class="js-edit-value-form" style="display:none">
+    <input class="js-value-input" type="text" value="<%- option.value %>" />
+    <button class="js-save-value btn btn-success fonticon-circle-check btn-small"> </button>
+    <button class="js-cancel-value btn btn-small fonticon-circle-x"> </button>
   </div>
 </td>
-<td id="delete-value" class="text-center"> <i class="icon-trash"> </i> </td>
+<td class="js-delete-value" class="text-center"> <i class="icon-trash"> </i> </td>


[10/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Set the triggering of the call to poll or stop polling ddoc metadata in the tab toggling


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

Branch: refs/heads/2041-update-ibrowse
Commit: ce91d81bb71fff5ac4e89e38e372822204ac717e
Parents: 023da37
Author: suelockwood <de...@apache.org>
Authored: Mon Mar 10 13:08:43 2014 -0400
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Mar 10 16:04:25 2014 -0400

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/views.js | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ce91d81b/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 54ec261..b51ea08 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1577,6 +1577,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       if ($targetTab.attr('id') !== $previousTab.attr('id')) {
         $previousTab.removeAttr('style');
       }
+      //stop polling
+      this.ddocInfoView.stopRefreshInterval(); 
 
       if ($targetId === 'index-nav') {
         if (this.newView) { return; }
@@ -1585,6 +1587,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         $targetTab.toggle('slow', function(){
            that.showEditors();
         });
+      } else if ($targetId === "meta-nav"){
+        if ($previousTab.attr('id') !== "metadata"){
+          this.ddocInfoView.startRefreshInterval();
+        } 
+        $targetTab.toggle('slow'); 
       } else {
         $targetTab.toggle('slow');
       }
@@ -1628,7 +1635,14 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         $('.beautify-tooltip').tooltip();
       }
     },
+    renderDdocInfo: function(){
+      if(this.ddocInfoView){
+        this.ddocInfoView.remove();
+      } 
+      this.ddocInfoView = this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
+      this.ddocInfoView.render();
 
+    },
     beforeRender: function () {
 
       if (this.newView) {
@@ -1643,7 +1657,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
         var ddocDecode = decodeURIComponent(this.ddocID);
         this.model = this.ddocs.get(ddocDecode).dDocModel();
         this.reduceFunStr = this.model.viewHasReduce(this.viewName);
-        this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
+        
       }
 
       this.designDocSelector = this.setView('.design-doc-group', new Views.DesignDocSelector({
@@ -1670,6 +1684,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
     },
 
     afterRender: function() {
+      this.renderDdocInfo();
+
       if (this.params && !this.newView) {
         this.advancedOptions.updateFromParams(this.params);
       }
@@ -1872,15 +1888,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       };
     },
 
-    afterRender: function () {
-      this.startRefreshInterval();
-    },
-
     startRefreshInterval: function () {
       var model = this.model;
 
       // Interval already set
-      if (this.intervalId) { return ; }
+      if (this.intervalId) { this.stopRefreshInterval(); }
 
       this.intervalId = setInterval(function () {
         model.fetch();


[07/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Update pagination docs - COUCHDB-1076 is old now

As far as I'm aware, skip is equivalently fast to a startkey search
because whole subtrees are skipped when their document count does
not exceed the remaining skip.


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

Branch: refs/heads/2041-update-ibrowse
Commit: 8d37ee36f23e5aea09f1fd17fd783b74a45d2e7e
Parents: adf9ae2
Author: Randall Leeds <ra...@apache.org>
Authored: Sun Mar 9 20:40:55 2014 -0700
Committer: Randall Leeds <ra...@apache.org>
Committed: Sun Mar 9 20:43:37 2014 -0700

----------------------------------------------------------------------
 share/doc/src/couchapp/views/pagination.rst | 48 ++++++++----------------
 1 file changed, 15 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/8d37ee36/share/doc/src/couchapp/views/pagination.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/couchapp/views/pagination.rst b/share/doc/src/couchapp/views/pagination.rst
index b40f988..6f3b34e 100644
--- a/share/doc/src/couchapp/views/pagination.rst
+++ b/share/doc/src/couchapp/views/pagination.rst
@@ -125,12 +125,11 @@ Or in a pseudo-JavaScript snippet:
     page.display_link('next');
   }
 
-Slow Paging (Do Not Use)
-========================
+Paging
+======
 
-**Don’t use this method!** We just show it because it might seem natural to use,
-and you need to know why it is a bad idea. To get the first five rows from
-the view result, you use the ``?limit=5`` query parameter::
+To get the first five rows from the view result, you use the ``?limit=5``
+query parameter::
 
   curl -X GET http://127.0.0.1:5984/artists/_design/artists/_view/by-name?limit=5
 
@@ -194,34 +193,17 @@ straightforward:
     return page != last_page;
   }
 
-The dealbreaker
----------------
-
-This all looks easy and straightforward, but it has one fatal flaw. Remember
-how view results are generated from the underlying B-tree index: CouchDB
-jumps to the first row (or the first row that matches ``startkey``,
-if provided) and reads one row after the other from the index until there are
-no more rows (or ``limit`` or ``endkey`` match, if provided).
-
-The ``skip`` argument works like this: in addition to going to the first row and
-starting to read, skip will skip as many rows as specified, but CouchDB will
-still read from the first row; it just won’t return any values for the skipped
-rows. If you specify ``skip=100``, CouchDB will read 100 rows and not create
-output for them. This doesn’t sound too bad, but it is very bad, when you use
-1000 or even 10000 as skip values. CouchDB will have to look at a lot of rows
-unnecessarily.
-
-As a rule of thumb, skip should be used only with single digit values. While
-it’s possible that there are legitimate use cases where you specify a larger
-value, they are a good indicator for potential problems with your solution.
-Finally, for the calculations to work, you need to add a reduce function and
-make two calls to the view per page to get all the numbering right,
-and there’s still a potential for error.
-
-Fast Paging (Do Use)
-====================
-
-The correct solution is not much harder. Instead of slicing the result set
+Paging (Alternate Method)
+=========================
+
+The method described above performed poorly with large skip values until
+CouchDB 1.2. Additionally, some use cases may call for the following
+alternate method even with newer versions of CouchDB. One such case is when
+duplicate results should be prevented. Using skip alone it is possible for
+new documents to be inserted during pagination which could change the offset
+of the start of the subsequent page.
+
+A correct solution is not much harder. Instead of slicing the result set
 into equally sized pages, we look at 10 rows at a time and use ``startkey`` to
 jump to the next 10 rows. We even use skip, but only with the value 1.
 


[28/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393

Posted by dc...@apache.org.
Fix missing file in Makefile.am

This closes #183

Signed-off-by: Alexander Shorin <kx...@apache.org>


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

Branch: refs/heads/2041-update-ibrowse
Commit: 510070c0979b72a111ba865a421a221250fc9350
Parents: b8accb4
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Sat Mar 15 16:00:22 2014 +0100
Committer: Alexander Shorin <kx...@apache.org>
Committed: Sat Mar 15 19:47:02 2014 +0400

----------------------------------------------------------------------
 src/Makefile.am | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/510070c0/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 89a6afd..43afcf5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -147,6 +147,7 @@ FAUXTON_FILES = \
     fauxton/app/addons/databases/resources.js \
     fauxton/app/addons/databases/routes.js \
     fauxton/app/addons/databases/views.js \
+    fauxton/app/addons/databases/tests/resourcesSpec.js \
     fauxton/app/addons/documents/base.js \
     fauxton/app/addons/documents/resources.js \
     fauxton/app/addons/documents/routes.js \