You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2013/10/03 16:13:14 UTC

[01/42] git commit: updated refs/heads/master to a4d6cd4

Updated Branches:
  refs/heads/master 964324b51 -> a4d6cd439


add docs/debug output


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

Branch: refs/heads/master
Commit: 26875db74b190de1482cdaacee16f9756819d9b6
Parents: 27bf560
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 18:48:19 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:50 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins.erl       |  8 +++----
 src/couch_plugins/src/couch_plugins_httpd.erl | 25 +++++++++++++++++++---
 2 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/26875db7/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 0a65bf7..7dd3bd2 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -1,13 +1,10 @@
 -module(couch_plugins).
 -include("couch_db.hrl").
-%% Application callbacks
 -export([install/1]).
 
-
 % couch_plugins:install({"geocouch", "http://127.0.0.1:8000", "1.0.0", [{"R15B03", "+XOJP6GSzmuO2qKdnjO+mWckXVs="}]}).
 % couch_plugins:install({"geocouch", "http://people.apache.org/~jan/", "couchdb1.2.x_v0.3.0-11-gd83ba22", [{"R15B03", "ZetgdHj2bY2w37buulWVf3USOZs="}]}).
 
-
 -define(PLUGIN_DIR, "/tmp/couchdb_plugins").
 
 log(T) -> 
@@ -79,6 +76,7 @@ add_code_path(Name, Version) ->
       Else
   end.
 
+-spec load_plugin(string()) -> ok | {error, atom()}.
 load_plugin(NameList) ->
   Name = list_to_atom(NameList),
   application:load(Name).
@@ -126,6 +124,7 @@ download({Name, _BaseUrl, Version, _Checksums}=Plugin) ->
 
 -spec verify_checksum(string(), list()) -> ok | {error, string()}.
 verify_checksum(Filename, Checksums) ->
+
   OTPRelease = erlang:system_info(otp_release),
   case proplists:get_value(OTPRelease, Checksums) of
   undefined ->
@@ -137,6 +136,7 @@ verify_checksum(Filename, Checksums) ->
 
 -spec do_verify_checksum(string(), string()) -> ok | {error, string()}.
 do_verify_checksum(Filename, Checksum) ->
+  ?LOG_DEBUG("Filename: ~s", [Filename]),
   case file:read_file(Filename) of
   {ok, Data} ->
     ComputedChecksum = binary_to_list(base64:encode(crypto:sha(Data))),
@@ -150,7 +150,7 @@ do_verify_checksum(Filename, Checksum) ->
   end.
 
 
-
+%% utils
 
 -spec get_url(plugin()) -> string().
 get_url({Name, BaseUrl, Version, _Checksums}) ->

http://git-wip-us.apache.org/repos/asf/couchdb/blob/26875db7/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
index 1e61aa2..6d987ae 100644
--- a/src/couch_plugins/src/couch_plugins_httpd.erl
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -4,7 +4,26 @@
 
 -include_lib("couch_db.hrl").
 
-handle_req(#httpd{method='PUT'}=Req) ->
-    couch_httpd:send_json(Req, 202, {[{ok, true}]});
+handle_req(#httpd{method='POST'}=Req) ->
+    ok = couch_httpd:verify_is_server_admin(Req),
+    couch_httpd:validate_ctype(Req, "application/json"),
+
+    {PluginSpec} = couch_httpd:json_body_obj(Req),
+  ?LOG_DEBUG("Plugin Spec: ~p", [PluginSpec]),
+    Url = binary_to_list(couch_util:get_value(<<"url">>, PluginSpec)),
+    Name = binary_to_list(couch_util:get_value(<<"name">>, PluginSpec)),
+    Version = binary_to_list(couch_util:get_value(<<"version">>, PluginSpec)),
+    {Checksums0} = couch_util:get_value(<<"checksums">>, PluginSpec),
+    Checksums = lists:map(fun({K, V}) ->
+      {binary_to_list(K), binary_to_list(V)}
+    end, Checksums0),
+
+    case couch_plugins:install({Name, Url, Version, Checksums}}) of
+    ok ->
+        couch_httpd:send_json(Req, 202, {[{ok, true}]});
+    Error ->
+        ?LOG_DEBUG("Plugin Spec: ~p", [PluginSpec]),
+        couch_httpd:send_error(Req, {bad_request, Error})
+    end;
 handle_req(Req) ->
-    couch_httpd:send_method_not_allowed(Req, "PUT").
+    couch_httpd:send_method_not_allowed(Req, "POST").


[42/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
[docs] re-add plugins dir config section


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

Branch: refs/heads/master
Commit: a4d6cd439919ccd38bce340339ee4c8363dc1f58
Parents: 95d6e35
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Oct 3 16:12:32 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:12:32 2013 +0200

----------------------------------------------------------------------
 share/doc/src/config/intro.rst | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a4d6cd43/share/doc/src/config/intro.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/config/intro.rst b/share/doc/src/config/intro.rst
index 0198af2..f662b8f 100644
--- a/share/doc/src/config/intro.rst
+++ b/share/doc/src/config/intro.rst
@@ -28,11 +28,13 @@ in the following order:
 
 #. ``LOCALCONFDIR/default.ini``
 
-#. ``LOCALCONFDIR/default.d/*``
+#. ``LOCALCONFDIR/default.d/*.ini``
+
+#. ``PLUGINS_DIR/*/priv/default.d/*.ini``
 
 #. ``LOCALCONFDIR/local.ini``
 
-#. ``LOCALCONFDIR/local.d/*``
+#. ``LOCALCONFDIR/local.d/*.ini``
 
 The ``LOCALCONFDIR`` points to the directory that contains configuration files
 (``/usr/local/etc/couchdb`` by default). This variable may vary from the


[40/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
fix formatting


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

Branch: refs/heads/master
Commit: a0cba304e4e29d9fe507d78bc2f85a4fe937abc7
Parents: 492c989
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 11:34:24 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:09:17 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a0cba304/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index b1d6fb7..0093e1d 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -30,7 +30,7 @@ first iteration of a plugins system:
 4. Complete trust-based system. You trust me to not do any nasty things
    when you click on the install button. No crypto, no nothing. Only
    people who can commit to Futon can release new versions of plugins.
-5. Minimal user-friendlyness: won’t install plugins that don’t match 
+5. Minimal user-friendlyness: won’t install plugins that don’t match
    the current Erlang version, gives semi-sensible error messages
    (wrapped in a HTTP 500 response :)
 6. Require a pretty strict format for binary releases.
@@ -61,7 +61,7 @@ hang of it.
 Here is a rough list of features squared against future milestones:
 
 Milestone 2: Be creator friendly
- - Make it easy to build a CouchDB plugin by providing one or more easy 
+ - Make it easy to build a CouchDB plugin by providing one or more easy
    to start templates.
  - Make it easy to publish new plugins and new versions of existing plugins.
  - Make it easy to supply packages for multiple Erlang & CouchDB versions.
@@ -100,7 +100,7 @@ module.
 It exposes one new API endpoint `/_plugins` that an admin user can
 POST to.
 
-The additional Futon page lives at /_utils/plugins.html it is
+The additional Futon page lives at `/_utils/plugins.html` it is
 hardcoded.
 
 Futon (or you) post an object to `/_plugins` with four properties:
@@ -183,4 +183,4 @@ to improve this, thanks!
 
 Best,
 Jan
--- 
+--


[05/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
remove rebar reference


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

Branch: refs/heads/master
Commit: 963aee4e29fea1edaee1bf86b2808f9019410f04
Parents: 9de76f2
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 20:06:16 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/963aee4e/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 6f3bd3b..09a0a71 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -161,9 +161,16 @@ that shows how a binary package is built:
 
     https://github.com/janl/geocouch/compare/couchbase:couchdb1.3.x...couchdb1.3.x-plugins
 
-## Build this with
 
-   rebar compile
+## Build
+
+Build CouchDB as usual:
+
+    ./bootstrap
+    ./configure
+    make
+    make dev
+    ./utils/run
 
 * * *
 


[21/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add `uninstall()`, removed unneeded aplication:load() cruft


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

Branch: refs/heads/master
Commit: c877e61404f5a511038aad1c7ffd2c22bbfcd818
Parents: f090382
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 22:06:02 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 share/www/plugins.html                        | 16 +++++++-----
 src/couch_plugins/src/couch_plugins.erl       | 29 +++-------------------
 src/couch_plugins/src/couch_plugins_httpd.erl | 13 +++++++---
 3 files changed, 23 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c877e614/share/www/plugins.html
----------------------------------------------------------------------
diff --git a/share/www/plugins.html b/share/www/plugins.html
index b42ed2e..e7ffc26 100644
--- a/share/www/plugins.html
+++ b/share/www/plugins.html
@@ -69,21 +69,24 @@ specific language governing permissions and limitations under the License.
       $.get("/_config/plugins/" + name + "/", function(body, textStatus) {
         body = JSON.parse(body);
         if(body == version) {
-          button.html("Already Installed");
+          button.html('Already Installed. Click to Uninstall');
+          button.data('delete', true);
         } else {
-          button.html("Other Version Installed: " + body);
+          button.html('Other Version Installed: ' + body);
+          button.attr('disabled', true);
         }
-        button.attr("disabled", true);
       });
     });
 
     $('.install-plugin').click(function(event) {
       var button = $(this);
+      var delete_plugin = button.data('delete') || false;
       var plugin_spec = JSON.stringify({
         name: button.data('name'),
         url: button.data('url'),
         version: button.data('version'),
-        checksums: button.data('checksums')
+        checksums: button.data('checksums'),
+        "delete": delete_plugin
       });
       var url = '/_plugins'
       $.ajax({
@@ -95,8 +98,9 @@ specific language governing permissions and limitations under the License.
         processData: false, // keep our precious JSON
         success: function(data, textStatus, jqXhr) {
           if(textStatus == "success") {
-            button.html("Sucessfully Installed");
-            button.attr("disabled", true);
+            var action = delete_plugin ? 'Uninstalled' : 'Installed';
+            button.html('Sucessfully ' + action);
+            button.attr('disabled', true);
           } else {
             button.html(textStatus);
           }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c877e614/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 8b4a22a..3463d3d 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -43,9 +43,6 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
   ok = register_plugin(Name, Version),
   log("registered plugin"),
 
-  ok = load_plugin(Name),
-  log("loaded plugin"),
-
   load_config(Name, Version),
   log("loaded config"),
 
@@ -55,10 +52,6 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
 % plugin, you get an `ok`.
 -spec uninstall(plugin()) -> ok | {error, string()}.
 uninstall({Name, _BaseUrl, Version, _Checksums}) ->
-  % unload app
-  ok = unload_plugin(Name),
-  log("plugin unloaded"),
-
   % unload config
   ok = unload_config(Name, Version),
   log("config unloaded"),
@@ -125,7 +118,7 @@ set_config({{Section, Key}, Value}) ->
     ok = couch_config:set(Section, Key, Value).
 
 -spec delete_config({{string(), string()}, _Value}) -> ok.
-delete_config({Section, Key}) ->
+delete_config({{Section, Key}, _Value}) ->
     ok = couch_config:delete(Section, Key).
 
 -spec file_names(string(), string()) -> string().
@@ -166,23 +159,6 @@ del_code_path(Name, Version) ->
 %% * * *
 
 
-%% Load Plugin
-%% This uses `appliction:load(<plugnname>)` to load the plugin
-%% and `appliction:unload(<plugnname>)` to unload the plugin.
-
--spec load_plugin(string()) -> ok | {error, atom()}.
-load_plugin(NameList) ->
-  Name = list_to_atom(NameList),
-  application:load(Name).
-
--spec unload_plugin(string()) -> ok | {error, atom()}.
-unload_plugin(NameList) ->
-  Name = list_to_atom(NameList),
-  application:unload(Name).
-
-%% * * *
-
-
 -spec untargz(string()) -> {ok, string()} | {error, string()}.
 untargz(Filename) ->
   % read .gz file
@@ -197,7 +173,8 @@ untargz(Filename) ->
 -spec delete_files(string(), string()) -> ok | {error, atom()}.
 delete_files(Name, Version) ->
   PluginPath = plugin_dir() ++ "/" ++ get_file_slug(Name, Version),
-  file:del_dir(PluginPath).
+  mochitemp:rmtempdir(PluginPath).
+
 
 % downloads a pluygin .tar.gz into a local plugins directory
 -spec download(string()) -> ok | {error, string()}.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c877e614/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
index 7a450f4..7a99cd1 100644
--- a/src/couch_plugins/src/couch_plugins_httpd.erl
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -20,16 +20,18 @@ handle_req(#httpd{method='POST'}=Req) ->
     couch_httpd:validate_ctype(Req, "application/json"),
 
     {PluginSpec} = couch_httpd:json_body_obj(Req),
-  ?LOG_DEBUG("Plugin Spec: ~p", [PluginSpec]),
     Url = binary_to_list(couch_util:get_value(<<"url">>, PluginSpec)),
     Name = binary_to_list(couch_util:get_value(<<"name">>, PluginSpec)),
     Version = binary_to_list(couch_util:get_value(<<"version">>, PluginSpec)),
+    Delete = couch_util:get_value(<<"delete">>, PluginSpec),
     {Checksums0} = couch_util:get_value(<<"checksums">>, PluginSpec),
     Checksums = lists:map(fun({K, V}) ->
       {binary_to_list(K), binary_to_list(V)}
     end, Checksums0),
-
-    case couch_plugins:install({Name, Url, Version, Checksums}) of
+    Plugin = {Name, Url, Version, Checksums},
+    ?LOG_DEBUG("~p", [Plugin]),
+    ?LOG_DEBUG("~p", [Delete]),
+    case do_install(Delete, Plugin) of
     ok ->
         couch_httpd:send_json(Req, 202, {[{ok, true}]});
     Error ->
@@ -38,3 +40,8 @@ handle_req(#httpd{method='POST'}=Req) ->
     end;
 handle_req(Req) ->
     couch_httpd:send_method_not_allowed(Req, "POST").
+
+do_install(false, Plugin)->
+    couch_plugins:install(Plugin);
+do_install(true, Plugin)->
+    couch_plugins:uninstall(Plugin).


[22/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
check if plugins are already installed& better install feedback


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

Branch: refs/heads/master
Commit: f9f10fe292fed3a203ad44a15d0a46177c0f752b
Parents: 21e839a
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 18:56:07 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 share/www/plugins.html | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f9f10fe2/share/www/plugins.html
----------------------------------------------------------------------
diff --git a/share/www/plugins.html b/share/www/plugins.html
index 473531d..b42ed2e 100644
--- a/share/www/plugins.html
+++ b/share/www/plugins.html
@@ -42,7 +42,7 @@ specific language governing permissions and limitations under the License.
           </ul>
         </p>
         <p>
-          <button href="#" class="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
+          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
         </p>
       </div>
       <div class="row">
@@ -56,13 +56,28 @@ specific language governing permissions and limitations under the License.
           </ul>
         </p>
         <p>
-          <button href="#" class="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"2IvVuihCBAE4SIN3qgjofx23wJs="}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
+          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"2IvVuihCBAE4SIN3qgjofx23wJs="}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
         </p>
       </div>
     </div>
   </div></body>
   <script>
-    $('.install_plugin').click(function(event) {
+    $('.install-plugin').each(function() {
+      var button = $(this);
+      var name = button.data('name');
+      var version = button.data('version');
+      $.get("/_config/plugins/" + name + "/", function(body, textStatus) {
+        body = JSON.parse(body);
+        if(body == version) {
+          button.html("Already Installed");
+        } else {
+          button.html("Other Version Installed: " + body);
+        }
+        button.attr("disabled", true);
+      });
+    });
+
+    $('.install-plugin').click(function(event) {
       var button = $(this);
       var plugin_spec = JSON.stringify({
         name: button.data('name'),
@@ -79,7 +94,12 @@ specific language governing permissions and limitations under the License.
         dataType: 'json', // expected from the server
         processData: false, // keep our precious JSON
         success: function(data, textStatus, jqXhr) {
-          button.html(textStatus);
+          if(textStatus == "success") {
+            button.html("Sucessfully Installed");
+            button.attr("disabled", true);
+          } else {
+            button.html(textStatus);
+          }
         },
         beforeSend: function(xhr) {
           xhr.setRequestHeader('Accept', 'application/json');


[32/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
only install plugins if their CouchDB version matches the target couch


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

Branch: refs/heads/master
Commit: 075c8117fe7e77156d7261421f86d6d9bda6897c
Parents: e575751
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 23:09:01 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 share/www/plugins.html                        | 10 ++++----
 src/couch_plugins/src/couch_plugins.erl       | 29 ++++++++++++++++------
 src/couch_plugins/src/couch_plugins_httpd.erl | 18 ++++++++------
 3 files changed, 37 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/075c8117/share/www/plugins.html
----------------------------------------------------------------------
diff --git a/share/www/plugins.html b/share/www/plugins.html
index e7ffc26..7f8da53 100644
--- a/share/www/plugins.html
+++ b/share/www/plugins.html
@@ -33,16 +33,16 @@ specific language governing permissions and limitations under the License.
     <div id="content">
       <div class="row">
         <h2>GeoCouch</h2>
-        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g4ea0bea</strong></p>
+        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g66e6219</strong></p>
         <p>Author: Volker Mische</p>
         <p>
           Available Erlang Versions:
           <ul>
-            <li>R15B01</li>
+            <li>CouchDB 1.4.0-XXX R15B01</li>
           </ul>
         </p>
         <p>
-          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
+          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"D5QPhrJTAifM42DXqAj4RxzfEtI="}}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-16-g66e6219">Install GeoCouch Now</button>
         </p>
       </div>
       <div class="row">
@@ -52,11 +52,11 @@ specific language governing permissions and limitations under the License.
         <p>
           Available Erlang Versions:
           <ul>
-            <li>R15B01</li>
+            <li>CouchDB 1.4.0-XXX R15B01</li>
           </ul>
         </p>
         <p>
-          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"2IvVuihCBAE4SIN3qgjofx23wJs="}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
+          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"Aj3mjC6M75NA62q5/xkP0tl8Hws="}}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
         </p>
       </div>
     </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/075c8117/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 3463d3d..507f114 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -207,18 +207,25 @@ download({Name, _BaseUrl, Version, _Checksums}=Plugin) ->
 -spec verify_checksum(string(), list()) -> ok | {error, string()}.
 verify_checksum(Filename, Checksums) ->
 
-  OTPRelease = erlang:system_info(otp_release),
-  case proplists:get_value(OTPRelease, Checksums) of
+  CouchDBVersion = couchdb_version(),
+  case proplists:get_value(CouchDBVersion, Checksums) of
   undefined ->
-    ?LOG_ERROR("[couch_plugins] Can't find checksum for OTP Release '~s'", [OTPRelease]),
-    {error, no_checksum};
-  Checksum ->
-    do_verify_checksum(Filename, Checksum)
+    ?LOG_ERROR("[couch_plugins] Can't find checksum for CouchDB Version '~s'", [CouchDBVersion]),
+    {error, no_couchdb_checksum};
+  OTPChecksum ->
+    OTPRelease = erlang:system_info(otp_release),
+    case proplists:get_value(OTPRelease, OTPChecksum) of
+    undefined ->
+      ?LOG_ERROR("[couch_plugins] Can't find checksum for Erlang Version '~s'", [OTPRelease]),
+      {error, no_erlang_checksum};
+    Checksum ->
+      do_verify_checksum(Filename, Checksum)
+    end
   end.
 
 -spec do_verify_checksum(string(), string()) -> ok | {error, string()}.
 do_verify_checksum(Filename, Checksum) ->
-  ?LOG_DEBUG("Filename: ~s", [Filename]),
+  ?LOG_DEBUG("Checking Filename: ~s", [Filename]),
   case file:read_file(Filename) of
   {ok, Data} ->
     ComputedChecksum = binary_to_list(base64:encode(crypto:sha(Data))),
@@ -246,7 +253,8 @@ get_filename(Name, Version) ->
 get_file_slug(Name, Version) ->
   % OtpRelease does not include patch levels like the -1 in R15B03-1
   OTPRelease = erlang:system_info(otp_release),
-  Name ++ "-" ++ Version ++ "-" ++ OTPRelease.
+  CouchDBVersion = couchdb_version(),
+  string:join([Name, Version, OTPRelease, CouchDBVersion], "-").
 
 -spec file_exists(string()) -> boolean().
 file_exists(Filename) ->
@@ -255,6 +263,11 @@ file_exists(Filename) ->
 does_file_exist({error, enoent}) -> false;
 does_file_exist(_Else) -> true.
 
+couchdb_version() ->
+  %% strip git hash from version string
+  [Version|_Rest] = string:tokens(couch_server:get_version(), "+"),
+  Version.
+
 % installing a plugin:
 %  - POST /_plugins -d {plugin-def}
 %  - get plugin definition

http://git-wip-us.apache.org/repos/asf/couchdb/blob/075c8117/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
index 7a99cd1..d292ec6 100644
--- a/src/couch_plugins/src/couch_plugins_httpd.erl
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -25,12 +25,9 @@ handle_req(#httpd{method='POST'}=Req) ->
     Version = binary_to_list(couch_util:get_value(<<"version">>, PluginSpec)),
     Delete = couch_util:get_value(<<"delete">>, PluginSpec),
     {Checksums0} = couch_util:get_value(<<"checksums">>, PluginSpec),
-    Checksums = lists:map(fun({K, V}) ->
-      {binary_to_list(K), binary_to_list(V)}
-    end, Checksums0),
+    Checksums = parse_checksums(Checksums0),
+
     Plugin = {Name, Url, Version, Checksums},
-    ?LOG_DEBUG("~p", [Plugin]),
-    ?LOG_DEBUG("~p", [Delete]),
     case do_install(Delete, Plugin) of
     ok ->
         couch_httpd:send_json(Req, 202, {[{ok, true}]});
@@ -41,7 +38,14 @@ handle_req(#httpd{method='POST'}=Req) ->
 handle_req(Req) ->
     couch_httpd:send_method_not_allowed(Req, "POST").
 
-do_install(false, Plugin)->
+do_install(false, Plugin) ->
     couch_plugins:install(Plugin);
-do_install(true, Plugin)->
+do_install(true, Plugin) ->
     couch_plugins:uninstall(Plugin).
+
+parse_checksums(Checksums) ->
+    lists:map(fun({K, {V}}) ->
+        {binary_to_list(K), parse_checksums(V)};
+      ({K, V}) ->
+         {binary_to_list(K), binary_to_list(V)}
+    end, Checksums).
\ No newline at end of file


[30/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
A handler for 'couch_plugin' events'


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

Branch: refs/heads/master
Commit: 9504301d851acf963472d9d2c46d179d571ca22d
Parents: b539426
Author: Jason Smith (work) <ja...@gmail.com>
Authored: Mon Aug 19 13:07:23 2013 +0000
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 src/couchdb/couch_secondary_sup.erl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/9504301d/src/couchdb/couch_secondary_sup.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_secondary_sup.erl b/src/couchdb/couch_secondary_sup.erl
index 6320fd9..6dd5604 100644
--- a/src/couchdb/couch_secondary_sup.erl
+++ b/src/couchdb/couch_secondary_sup.erl
@@ -24,7 +24,14 @@ init([]) ->
             permanent,
             infinity,
             supervisor,
-            [couch_db_update_notifier_sup]}
+            [couch_db_update_notifier_sup]},
+
+        {couch_plugin_event,
+            {gen_event, start_link, [{local, couch_plugin}]},
+            permanent,
+            brutal_kill,
+            worker,
+            dynamic}
     ],
     Children = SecondarySupervisors ++ [
         begin


[28/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
more comments, add uninstall()


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

Branch: refs/heads/master
Commit: f090382de56b57aaa452ecfd3b9f5ef9aacd0ee4
Parents: dd83609
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 21:16:59 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins.erl | 113 +++++++++++++++++++--------
 1 file changed, 80 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f090382d/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 9c2c58f..8b4a22a 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -11,7 +11,7 @@
 % the License.
 -module(couch_plugins).
 -include("couch_db.hrl").
--export([install/1]).
+-export([install/1, uninstall/1]).
 
 % couch_plugins:install({"geocouch", "http://127.0.0.1:8000", "1.0.0", [{"R15B03", "+XOJP6GSzmuO2qKdnjO+mWckXVs="}]}).
 % couch_plugins:install({"geocouch", "http://people.apache.org/~jan/", "couchdb1.2.x_v0.3.0-11-gd83ba22", [{"R15B03", "ZetgdHj2bY2w37buulWVf3USOZs="}]}).
@@ -53,30 +53,30 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
 
 % Idempotent uninstall, if you uninstall a non-existant
 % plugin, you get an `ok`.
-% -spec uninstall(string()) -> ok | {error, string()}.
-% uninstall(Name) ->
-%   % unload app
-%   ok = unload_plugin(Name),
-%   log("plugin unloaded"),
+-spec uninstall(plugin()) -> ok | {error, string()}.
+uninstall({Name, _BaseUrl, Version, _Checksums}) ->
+  % unload app
+  ok = unload_plugin(Name),
+  log("plugin unloaded"),
 
-%   % unload config
-%   ok = unload_config(Name),
-%   log("config unloaded"),
+  % unload config
+  ok = unload_config(Name, Version),
+  log("config unloaded"),
 
-%   % delete files
-%   ok = delete_files(Name),
-%   log("files deleted"),
+  % delete files
+  ok = delete_files(Name, Version),
+  log("files deleted"),
 
-%   % remove code path
-%   ok = remove_code_path(Name),
-%   log("removed code path"),
+  % delete code path
+  ok = del_code_path(Name, Version),
+  log("deleted code path"),
 
-%   % unregister plugin
-%   ok = unregister_plugin(Name),
-%   log("unregistered plugin"),
+  % unregister plugin
+  ok = unregister_plugin(Name),
+  log("unregistered plugin"),
 
-%   % done
-%   ok.
+  % done
+  ok.
 
 %% * * *
 
@@ -99,30 +99,49 @@ unregister_plugin(Name) ->
 
 
 %% Load Config
-%% Pareses <plugindir>/priv/default.d/<pluginname.ini> and applies
-%% the contents to the config system.
+%% Parses <plugindir>/priv/default.d/<pluginname.ini> and applies
+%% the contents to the config system, or removes them on uninstall
 
 -spec load_config(string(), string()) -> ok.
 load_config(Name, Version) ->
-    lists:foreach(
-      fun load_config_file/1,
-      filelib:wildcard(
-        filename:join(
-          [plugin_dir(), get_file_slug(Name, Version),
-           "priv", "default.d", "*.ini"]))).
-
--spec load_config_file(string()) -> ok.
-load_config_file(File) ->
+    loop_config(Name, Version, fun set_config/1).
+
+-spec unload_config(string(), string()) -> ok.
+unload_config(Name, Version) ->
+    loop_config(Name, Version, fun delete_config/1).
+
+-spec loop_config(string(), string(), function()) -> ok.
+loop_config(Name, Version, Fun) ->
+    lists:foreach(fun(File) -> load_config_file(File, Fun) end,
+      filelib:wildcard(file_names(Name, Version))).
+
+-spec load_config_file(string(), function()) -> ok.
+load_config_file(File, Fun) ->
     {ok, Config} = couch_config:parse_ini_file(File),
-    lists:foreach(fun set_config/1, Config).
+    lists:foreach(Fun, Config).
 
 -spec set_config({{string(), string()}, string()}) -> ok.
 set_config({{Section, Key}, Value}) ->
-    ok = couch_config:set(Section, Key, Value, false).
+    ok = couch_config:set(Section, Key, Value).
+
+-spec delete_config({{string(), string()}, _Value}) -> ok.
+delete_config({Section, Key}) ->
+    ok = couch_config:delete(Section, Key).
+
+-spec file_names(string(), string()) -> string().
+file_names(Name, Version) ->
+  filename:join(
+    [plugin_dir(), get_file_slug(Name, Version),
+     "priv", "default.d", "*.ini"]).
 
 %% * * *
 
 
+%% Code Path Management
+%% The Erlang code path is where the Erlang runtime looks for `.beam`
+%% files to load on, say, `application:load()`. Since plugin directories
+%% are created on demand and named after CouchDB and Erlang versions,
+%% we manage the Erlang code path semi-automatically here.
 
 -spec add_code_path(string(), string()) -> ok | {error, bad_directory}.
 add_code_path(Name, Version) ->
@@ -134,11 +153,35 @@ add_code_path(Name, Version) ->
       Else
   end.
 
+-spec del_code_path(string(), string()) -> ok | {error, atom()}.
+del_code_path(Name, Version) ->
+  PluginPath = plugin_dir() ++ "/" ++ get_file_slug(Name, Version) ++ "/ebin",
+  case code:del_path(PluginPath) of
+    true -> ok;
+    _Else ->
+      ?LOG_DEBUG("Failed to delete PluginPath: '~s', ignoring", [PluginPath]),
+      ok
+  end.
+
+%% * * *
+
+
+%% Load Plugin
+%% This uses `appliction:load(<plugnname>)` to load the plugin
+%% and `appliction:unload(<plugnname>)` to unload the plugin.
+
 -spec load_plugin(string()) -> ok | {error, atom()}.
 load_plugin(NameList) ->
   Name = list_to_atom(NameList),
   application:load(Name).
 
+-spec unload_plugin(string()) -> ok | {error, atom()}.
+unload_plugin(NameList) ->
+  Name = list_to_atom(NameList),
+  application:unload(Name).
+
+%% * * *
+
 
 -spec untargz(string()) -> {ok, string()} | {error, string()}.
 untargz(Filename) ->
@@ -151,6 +194,10 @@ untargz(Filename) ->
   % untar
   erl_tar:extract({binary, TarData}, [{cwd, plugin_dir()}, keep_old_files]).
 
+-spec delete_files(string(), string()) -> ok | {error, atom()}.
+delete_files(Name, Version) ->
+  PluginPath = plugin_dir() ++ "/" ++ get_file_slug(Name, Version),
+  file:del_dir(PluginPath).
 
 % downloads a pluygin .tar.gz into a local plugins directory
 -spec download(string()) -> ok | {error, string()}.


[12/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add build instructions (just `rebar compile`)


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

Branch: refs/heads/master
Commit: 06cd38ed02c9e41aafcbbc63001b5826e30a3981
Parents: b10cf90
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 19:32:56 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/06cd38ed/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 53fd47a..8384a97 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -161,6 +161,10 @@ that shows how a binary package is built:
 
     https://github.com/janl/geocouch/compare/couchbase:couchdb1.3.x...couchdb1.3.x-plugins
 
+## Build this with
+
+   rebar compile
+
 * * *
 
 I hope you like this :) Please comment and improve heavily!


[07/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
hook up futon to /_plugins


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

Branch: refs/heads/master
Commit: 4f8a2b4a280c3d462dbd48f6a47f98dc1be46d8e
Parents: 26875db
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 18:49:32 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 share/www/_sidebar.html |  1 +
 share/www/plugins.html  | 82 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f8a2b4a/share/www/_sidebar.html
----------------------------------------------------------------------
diff --git a/share/www/_sidebar.html b/share/www/_sidebar.html
index e68bf73..26a1bc8 100644
--- a/share/www/_sidebar.html
+++ b/share/www/_sidebar.html
@@ -23,6 +23,7 @@ specific language governing permissions and limitations under the License.
       <li><a href="config.html">Configuration</a></li>
       <li><a href="replicator.html">Replicator</a></li>
       <li><a href="status.html">Status</a></li>
+      <li><a href="plugins.html">Plugins</a></li>
     </ul></li>
     <li><span>Documentation</span><ul>
       <li><a href="docs/">Manual</a></li>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4f8a2b4a/share/www/plugins.html
----------------------------------------------------------------------
diff --git a/share/www/plugins.html b/share/www/plugins.html
new file mode 100644
index 0000000..a99826c
--- /dev/null
+++ b/share/www/plugins.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<!--
+
+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.
+
+-->
+<html lang="en">
+  <head>
+    <title>Plugins</title>
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+    <link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css">
+    <script src="script/json2.js"></script>
+    <script src="script/sha1.js"></script>
+    <script src="script/jquery.js"></script>
+    <script src="script/jquery.couch.js"></script>
+    <script src="script/jquery.dialog.js"></script>
+    <script src="script/futon.js"></script>
+  </head>
+  <body><div id="wrap">
+    <h1>
+      <a href="index.html">Overview</a>
+      <strong>Plugins</strong>
+    </h1>
+    <div id="content">
+      <div class="row">
+        <h2>GeoCouch</h2>
+        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-gd83ba22</strong></p>
+        <p>
+          Available Erlang Versions:
+          <ul>
+            <li>R15B01</li>
+          </ul>
+        </p>
+        <p>
+          <button href="#" id="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"mw7RWJtbt7WMOF/ypwpgkRHT0Wo="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
+        </p>
+      </div>
+
+    </div>
+  </div></body>
+  <script>
+    $('#install_plugin').click(function(event) {
+      var button = $(this);
+      var plugin_spec = JSON.stringify({
+        name: button.data('name'),
+        url: button.data('url'),
+        version: button.data('version'),
+        checksums: button.data('checksums')
+      });
+      var url = '/_plugins'
+      $.ajax({
+        url: url,
+        type: 'POST',
+        data: plugin_spec,
+        contentType: 'application/json', // what we send to the server
+        dataType: 'json', // expected from the server
+        processData: false, // keep our precious JSON
+        success: function(data, textStatus, jqXhr) {
+          button.html(textStatus);
+        },
+        beforeSend: function(xhr) {
+          xhr.setRequestHeader('Accept', 'application/json');
+        },
+      });
+    });
+  </script>
+  <style type="text/css">
+  .row {
+    background-color: #EEE;
+    padding:1em;
+  }
+  </style>
+</html>


[20/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update roadmap in README


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

Branch: refs/heads/master
Commit: e575751147ce8795111db41b6adea80629d3ccd5
Parents: c877e61
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 22:12:14 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e5757511/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 02a83ce..8ed62c3 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -50,13 +50,13 @@ Here’s a list of things this first iterations does and doesn’t do:
 - No identity checking of binaries.
 - Register installed plugins in the config system.
 - Make sure plugins start with the next restart of CouchDB.
+- Uninstall a plugin via Futon (or HTTP call). Admin only.
+- Show when a particular plugin is installed.
 
 Here are a few things I want to add before I call it MVP*:
 
-- Uninstall a plugin via Futon (or HTTP call). Admin only.
 - Only installs if CouchDB version matches.
 - Binaries must be published on *.apache.org.
-- Show when a particular plugin is installed.
 
 *MVP hopefully means you agree we can ship this with a few warnings
 so people can get a hang of it.
@@ -86,7 +86,8 @@ Milestone X: Later
    authors to publish “legit” plugins.
  - Sign & verify individual releases.
  - Handle unclean un/installs if CouchDB crashes while installing/
-   uninstalling
+   uninstalling.
+ - Add `--aditional_plugin_dir` parameter to `couchdb`.
 
 A few more things that can happen concurrently depending on what
 plugins require:


[06/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add more license, update license.skip, fix `make distcheck`


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

Branch: refs/heads/master
Commit: de47b672015d07783e2fc7b033826577c3de194b
Parents: 84fd3c1
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 20:04:48 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 .gitignore                                    |  1 +
 configure.ac                                  |  1 +
 license.skip                                  |  4 +++
 src/Makefile.am                               |  1 +
 src/couch_plugins/Makefile.am                 | 39 ++++++++++++++++++++++
 src/couch_plugins/src/couch_plugins.app.src   | 11 ++++++
 src/couch_plugins/src/couch_plugins_httpd.erl |  2 +-
 7 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 9d8d50e..c554e82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,6 +61,7 @@ share/doc/build/texinfo
 share/server/main-coffee.js
 share/server/main.js
 src/couch_mrview/ebin/
+src/couch_plugins/ebin/
 src/couch_replicator/ebin/
 src/couchdb/.deps/*
 src/couchdb/.libs/*

http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fec0441..bb3ef38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -727,6 +727,7 @@ AC_CONFIG_FILES([src/Makefile])
 AC_CONFIG_FILES([src/couch_dbupdates/Makefile])
 AC_CONFIG_FILES([src/couch_index/Makefile])
 AC_CONFIG_FILES([src/couch_mrview/Makefile])
+AC_CONFIG_FILES([src/couch_plugins/Makefile])
 AC_CONFIG_FILES([src/couch_replicator/Makefile])
 AC_CONFIG_FILES([src/couchdb/couch.app.tpl])
 AC_CONFIG_FILES([src/couchdb/Makefile])

http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index 914253b..fd7b040 100644
--- a/license.skip
+++ b/license.skip
@@ -87,6 +87,10 @@
 ^src/couch_mrview/Makefile
 ^src/couch_mrview/Makefile.in
 ^src/couch_mrview/ebin/.*.beam
+^src/couch_plugins/README.md
+^src/couch_plugins/Makefile
+^src/couch_plugins/Makefile.in
+^src/couch_plugins/ebin/.*.beam
 ^src/couch_replicator/Makefile
 ^src/couch_replicator/Makefile.in
 ^src/couch_replicator/ebin/.*.beam

http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 7b11e15..c500e11 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@ SUBDIRS = \
     couch_dbupdates \
     couch_index \
     couch_mrview \
+    couch_plugins \
     couch_replicator \
     couchdb \
     ejson \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/src/couch_plugins/Makefile.am
----------------------------------------------------------------------
diff --git a/src/couch_plugins/Makefile.am b/src/couch_plugins/Makefile.am
new file mode 100644
index 0000000..300f19c
--- /dev/null
+++ b/src/couch_plugins/Makefile.am
@@ -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.
+
+couch_pluginsebindir = $(couch_pluginslibdir)/ebin
+
+couch_pluginsebin_DATA = $(compiled_files)
+
+
+source_files = \
+    src/couch_plugins.app.src \
+    src/couch_plugins.erl \
+    src/couch_plugins_httpd.erl
+
+compiled_files = \
+    ebin/couch_plugins.app \
+    ebin/couch_plugins.beam \
+    ebin/couch_plugins_httpd.beam
+
+EXTRA_DIST = $(source_files)
+CLEANFILES = $(compiled_files)
+
+ebin/%.app: src/%.app.src
+	@mkdir -p ebin/
+	sed -e "s|%version%|@version@|g" \
+	< $< > $@
+
+ebin/%.beam: src/%.erl $(include_files)
+	@mkdir -p ebin/
+	$(ERLC) -Wall -I$(top_srcdir)/src -I$(top_srcdir)/src/couchdb \
+		-o ebin/ $(ERLC_FLAGS) ${TEST} $<;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/src/couch_plugins/src/couch_plugins.app.src
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.app.src b/src/couch_plugins/src/couch_plugins.app.src
index 059663c..d961289 100644
--- a/src/couch_plugins/src/couch_plugins.app.src
+++ b/src/couch_plugins/src/couch_plugins.app.src
@@ -1,3 +1,14 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
 {application, couch_plugins,
  [
   {description, "A CouchDB Plugin Installer"},

http://git-wip-us.apache.org/repos/asf/couchdb/blob/de47b672/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
index 12f65f3..7a450f4 100644
--- a/src/couch_plugins/src/couch_plugins_httpd.erl
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -29,7 +29,7 @@ handle_req(#httpd{method='POST'}=Req) ->
       {binary_to_list(K), binary_to_list(V)}
     end, Checksums0),
 
-    case couch_plugins:install({Name, Url, Version, Checksums}}) of
+    case couch_plugins:install({Name, Url, Version, Checksums}) of
     ok ->
         couch_httpd:send_json(Req, 202, {[{ok, true}]});
     Error ->


[09/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
remove ebin


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

Branch: refs/heads/master
Commit: dcab0f255ed5eba8bd7def26cf3d28509c43a230
Parents: bbbbd50
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 19:12:18 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/ebin/couch_plugins.app | 9 ---------
 1 file changed, 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/dcab0f25/src/couch_plugins/ebin/couch_plugins.app
----------------------------------------------------------------------
diff --git a/src/couch_plugins/ebin/couch_plugins.app b/src/couch_plugins/ebin/couch_plugins.app
deleted file mode 100644
index b67645e..0000000
--- a/src/couch_plugins/ebin/couch_plugins.app
+++ /dev/null
@@ -1,9 +0,0 @@
-{application,couch_plugins,
-             [{description,"A CouchDB Plugin Installer"},
-              {vsn,"1"},
-              {registered,[]},
-              {applications,[kernel,stdlib]},
-              {mod,{couch_plugins_app,[]}},
-              {env,[]},
-              {modules,[couch_plugins,couch_plugins_app,couch_plugins_httpd,
-                        couch_plugins_sup]}]}.


[35/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
load plugin Futon/Fauxon assets via /_plugins/<name>/


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

Branch: refs/heads/master
Commit: aef40724d392cc32d55b1eb25cd304cea88d7341
Parents: b6eba9e
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Aug 3 15:19:40 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins_httpd.erl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/aef40724/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
index d292ec6..83fd916 100644
--- a/src/couch_plugins/src/couch_plugins_httpd.erl
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -35,9 +35,23 @@ handle_req(#httpd{method='POST'}=Req) ->
         ?LOG_DEBUG("Plugin Spec: ~p", [PluginSpec]),
         couch_httpd:send_error(Req, {bad_request, Error})
     end;
+% handles /_plugins/<pluginname>/<file>
+% serves <plugin_dir>/<pluginname>-<pluginversion>-<otpversion>-<couchdbversion>/<file>
+handle_req(#httpd{method='GET',path_parts=[_, Name0 | Path0]}=Req) ->
+    Name = ?b2l(Name0),
+    Path = lists:map(fun binary_to_list/1, Path0),
+    OTPRelease = erlang:system_info(otp_release),
+    PluginVersion = couch_config:get("plugins", Name),
+    CouchDBVersion = couch_server:get_version(short),
+    FullName = string:join([Name, PluginVersion, OTPRelease, CouchDBVersion], "-"),
+    FullPath = filename:join([FullName, "priv", "www", string:join(Path, "/")]) ++ "/",
+    ?LOG_DEBUG("Serving ~p from ~p", [FullPath, plugin_dir()]),
+    couch_httpd:serve_file(Req, FullPath, plugin_dir());
 handle_req(Req) ->
     couch_httpd:send_method_not_allowed(Req, "POST").
 
+plugin_dir() ->
+  couch_config:get("couchdb", "plugin_dir").
 do_install(false, Plugin) ->
     couch_plugins:install(Plugin);
 do_install(true, Plugin) ->


[13/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add license headers


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

Branch: refs/heads/master
Commit: b10cf90ee78ee6b7fbc9a940b463d634249f2d57
Parents: dcab0f2
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 19:32:34 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins.erl       | 11 +++++++++++
 src/couch_plugins/src/couch_plugins_httpd.erl | 11 +++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b10cf90e/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 7dd3bd2..daac885 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -1,3 +1,14 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
 -module(couch_plugins).
 -include("couch_db.hrl").
 -export([install/1]).

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b10cf90e/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
index 6d987ae..12f65f3 100644
--- a/src/couch_plugins/src/couch_plugins_httpd.erl
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -1,3 +1,14 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
 -module(couch_plugins_httpd).
 
 -export([handle_req/1]).


[31/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
Fire a log_request event when requests are logged


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

Branch: refs/heads/master
Commit: f8509fad094c0a0bf2fb1692b2702dfd7fef4cdb
Parents: 9504301
Author: Jason Smith (work) <ja...@gmail.com>
Authored: Mon Aug 19 13:16:40 2013 +0000
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 src/couchdb/couch_httpd.erl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f8509fad/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 7c89d0e..28932ba 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -611,13 +611,14 @@ verify_is_server_admin(#user_ctx{roles=Roles}) ->
     false -> throw({unauthorized, <<"You are not a server admin.">>})
     end.
 
-log_request(#httpd{mochi_req=MochiReq,peer=Peer}, Code) ->
+log_request(#httpd{mochi_req=MochiReq,peer=Peer}=Req, Code) ->
     ?LOG_INFO("~s - - ~s ~s ~B", [
         Peer,
         MochiReq:get(method),
         MochiReq:get(raw_path),
         Code
-    ]).
+    ]),
+    gen_event:notify(couch_plugin, {log_request, Req, Code}).
 
 
 start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Length) ->


[04/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
fix github url


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

Branch: refs/heads/master
Commit: 9de76f221f38a2aba551a49b451dfc5939f55052
Parents: de47b67
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 20:05:16 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/9de76f22/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index de06309..6f3bd3b 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -153,8 +153,8 @@ merge world, I’d love to know :)
 
 The main branch for this is 1867-feature-plugins:
 
-     ASF: https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=log;h=refs/heads/1867-feature-plugins
-  GitHub: https://github.com/janl/couchdb/compare/1867-feature-plugins
+  ASF: https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=log;h=refs/heads/1867-feature-plugins
+  GitHub: https://github.com/janl/couchdb/compare/apache:master...1867-feature-plugins
 
 I created a branch on GeoCouch that adds a few lines to its `Makefile`
 that shows how a binary package is built:


[38/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add plugins plugin for Fauxton


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

Branch: refs/heads/master
Commit: 492c98990f929dddc7de56fc0bb9582a5ce8d66b
Parents: f8509fa
Author: Jan Lehnardt <ja...@apache.org>
Authored: Mon Sep 9 11:22:01 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:09:17 2013 +0200

----------------------------------------------------------------------
 .gitignore                                      |  1 +
 src/fauxton/app/addons/plugins/base.js          | 24 ++++++
 src/fauxton/app/addons/plugins/resources.js     | 26 ++++++
 src/fauxton/app/addons/plugins/routes.js        | 47 +++++++++++
 .../app/addons/plugins/templates/plugins.html   | 88 ++++++++++++++++++++
 src/fauxton/settings.json.default               |  3 +-
 6 files changed, 188 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index c554e82..5f3c9df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,6 +92,7 @@ src/fauxton/app/load_addons.js
 src/fauxton/app/addons/*
 !src/fauxton/app/addons/activetasks
 !src/fauxton/app/addons/config
+!src/fauxton/app/addons/plugins
 !src/fauxton/app/addons/logs
 !src/fauxton/app/addons/stats
 !src/fauxton/app/addons/replication

http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/base.js b/src/fauxton/app/addons/plugins/base.js
new file mode 100644
index 0000000..140a1f8
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/base.js
@@ -0,0 +1,24 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+  "app",
+  "api",
+  "addons/plugins/routes"
+],
+
+function(app, FauxtonAPI, plugins) {
+  plugins.initialize = function() {
+    FauxtonAPI.addHeaderLink({title: "Plugins", href: "#_plugins", icon: "fonticon-plugins", className: 'plugins'});
+  };
+  return plugins;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/resources.js b/src/fauxton/app/addons/plugins/resources.js
new file mode 100644
index 0000000..d00fada
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/resources.js
@@ -0,0 +1,26 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+  "app",
+  "api"
+],
+
+function (app, FauxtonAPI) {
+  var plugins = FauxtonAPI.addon();
+
+  plugins.Hello = FauxtonAPI.View.extend({
+    template: "addons/plugins/templates/plugins"
+  });
+
+  return plugins;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/routes.js b/src/fauxton/app/addons/plugins/routes.js
new file mode 100644
index 0000000..24d47f0
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/routes.js
@@ -0,0 +1,47 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+  "app",
+  "api",
+  "addons/plugins/resources"
+],
+function(app, FauxtonAPI, plugins) {
+      var  PluginsRouteObject = FauxtonAPI.RouteObject.extend({
+        layout: "one_pane",
+
+        crumbs: [
+          {"name": "Plugins","link": "_plugins"}
+        ],
+
+        routes: {
+           "_plugins": "pluginsRoute"
+        },
+
+        selectedHeader: "Plugins",
+
+        roles: ["_admin"],
+
+        apiUrl:'plugins',
+
+        initialize: function () {
+            //put common views used on all your routes here (eg:  sidebars )
+        },
+
+        pluginsRoute: function () {
+          this.setView("#dashboard-content", new plugins.Hello({}));
+        }
+      });
+
+      plugins.RouteObjects = [PluginsRouteObject];
+  return plugins;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/templates/plugins.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/templates/plugins.html b/src/fauxton/app/addons/plugins/templates/plugins.html
new file mode 100644
index 0000000..3a49c28
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/templates/plugins.html
@@ -0,0 +1,88 @@
+    <div id="content">
+      <div class="row">
+        <h2>GeoCouch</h2>
+        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g66e6219</strong></p>
+        <p>Author: Volker Mische</p>
+        <p>
+          Available Erlang Versions:
+          <ul>
+            <li>CouchDB 1.4.0-XXX R15B01</li>
+          </ul>
+        </p>
+        <p>
+          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"D5QPhrJTAifM42DXqAj4RxzfEtI="}}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-16-g66e6219">Install GeoCouch Now</button>
+        </p>
+      </div>
+      <div class="row">
+        <h2>CouchPerUser</h2>
+        <p>Version: <strong>1.0.0</strong></p>
+        <p>Author: Bob Ippolito</p>
+        <p>
+          Available Erlang Versions:
+          <ul>
+            <li>CouchDB 1.4.0-XXX R15B01</li>
+          </ul>
+        </p>
+        <p>
+          <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"Aj3mjC6M75NA62q5/xkP0tl8Hws="}}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
+        </p>
+      </div>
+    </div>
+  </div></body>
+  <script>
+    $('.install-plugin').each(function() {
+      var button = $(this);
+      var name = button.data('name');
+      var version = button.data('version');
+      $.get("/_config/plugins/" + name + "/", function(body, textStatus) {
+        body = JSON.parse(body);
+        if(body == version) {
+          button.html('Already Installed. Click to Uninstall');
+          button.data('delete', true);
+        } else {
+          button.html('Other Version Installed: ' + body);
+          button.attr('disabled', true);
+        }
+      });
+    });
+
+    $('.install-plugin').click(function(event) {
+      var button = $(this);
+      var delete_plugin = button.data('delete') || false;
+      var plugin_spec = JSON.stringify({
+        name: button.data('name'),
+        url: button.data('url'),
+        version: button.data('version'),
+        checksums: button.data('checksums'),
+        "delete": delete_plugin
+      });
+      var url = '/_plugins'
+      $.ajax({
+        url: url,
+        type: 'POST',
+        data: plugin_spec,
+        contentType: 'application/json', // what we send to the server
+        dataType: 'json', // expected from the server
+        processData: false, // keep our precious JSON
+        success: function(data, textStatus, jqXhr) {
+          if(textStatus == "success") {
+            var action = delete_plugin ? 'Uninstalled' : 'Installed';
+            button.html('Sucessfully ' + action);
+            button.attr('disabled', true);
+          } else {
+            button.html(textStatus);
+          }
+        },
+        beforeSend: function(xhr) {
+          xhr.setRequestHeader('Accept', 'application/json');
+        },
+      });
+    });
+  </script>
+  <style type="text/css">
+  .row {
+    background-color: #FFF;
+    padding:1em;
+    margin-bottom:1em;
+  }
+  </style>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index 30088f0..4964135 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -4,7 +4,8 @@
   { "name": "config" },
   { "name": "logs" },
   { "name": "stats" },
-  { "name":  "replication" },
+  { "name": "replication" },
+  { "name": "plugins" },
   { "name": "contribute" },
   { "name": "permissions" },
   { "name": "auth" }


[18/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
teach `couch-config` `--erlang-version`


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

Branch: refs/heads/master
Commit: 98683d906b4fa447c30ad9b69f9ad555173e74b9
Parents: 0f5aa11
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 17:57:36 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:35 2013 +0200

----------------------------------------------------------------------
 bin/Makefile.am            | 2 ++
 bin/couch-config.tpl.in    | 5 +++++
 bin/erlang-version.escript | 3 +++
 configure.ac               | 6 ++++++
 license.skip               | 1 +
 5 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/98683d90/bin/Makefile.am
----------------------------------------------------------------------
diff --git a/bin/Makefile.am b/bin/Makefile.am
index c1913d0..65f9ab5 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -95,6 +95,7 @@ couch-config: couch-config.tpl
 	    -e "s|%package_author_name%|@package_author_name@|g" \
 	    -e "s|%package_name%|@package_name@|g" \
 	    -e "s|%version%|@version@|g" \
+	    -e "s|%erlangversion%|@erlangversion@|g" \
 	    -e "s|%couchdb_command_name%|$(couchdb_command_name)|g" > \
 	$@ < $<
 	chmod +x $@
@@ -118,6 +119,7 @@ couch-config_dev: couch-config.tpl
 	    -e "s|%package_author_name%|@package_author_name@|g" \
 	    -e "s|%package_name%|@package_name@|g" \
 	    -e "s|%version%|@version@|g" \
+	    -e "s|%erlangversion%|@erlangversion@|g" \
 	    -e "s|%couchdb_command_name%|$(abs_top_builddir)/utils/run|g" > \
 	$@ < $<
 	chmod +x $@

http://git-wip-us.apache.org/repos/asf/couchdb/blob/98683d90/bin/couch-config.tpl.in
----------------------------------------------------------------------
diff --git a/bin/couch-config.tpl.in b/bin/couch-config.tpl.in
index 22a886d..7db9b2a 100644
--- a/bin/couch-config.tpl.in
+++ b/bin/couch-config.tpl.in
@@ -22,6 +22,7 @@ viewdir="%localstatelibdir%"
 confdir="%localconfdir%"
 urifile="%localstaterundir%/couch.uri"
 logdir="%localstatelogdir%"
+erlangversion="%erlangversion%"
 
 version () {
     cat << EOF
@@ -60,6 +61,7 @@ Options:
   --log-dir         log directory
   --uri-file        daemon sockets file 
   --couch-version   version of Apache CouchDB
+  --erlang-version  version of Erlang that CouchDB was built with
   --version         version of $basename
   --help            Print usage
 
@@ -108,6 +110,9 @@ do
         --couch-version)
             echo $couchversion
             ;;
+        --erlang-version)
+            echo $erlangversion
+            ;;
         --version)
             version
             exit 0

http://git-wip-us.apache.org/repos/asf/couchdb/blob/98683d90/bin/erlang-version.escript
----------------------------------------------------------------------
diff --git a/bin/erlang-version.escript b/bin/erlang-version.escript
new file mode 100644
index 0000000..66aae1c
--- /dev/null
+++ b/bin/erlang-version.escript
@@ -0,0 +1,3 @@
+
+main(_) ->
+  io:format("~s~n", [erlang:system_info(otp_release)]).

http://git-wip-us.apache.org/repos/asf/couchdb/blob/98683d90/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index bb3ef38..9b980fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,6 +123,7 @@ else
 fi
 
 AC_PATH_PROG([ERL], [erl])
+AC_PATH_PROG([ESCRIPT], [escript])
 
 AS_IF([test x${ERL} = x], [
     AC_MSG_ERROR([Could not find the `erl' executable. Is Erlang installed?])
@@ -650,6 +651,9 @@ else
     fi
 fi
 
+ERL_VERSION_COMMAND="${ESCRIPT} bin/erlang-version.escript"
+erlangversion=`${ERL_VERSION_COMMAND}`
+
 AC_ARG_VAR([ERL], [path to the `erl' executable])
 AC_ARG_VAR([ERLC], [path to the `erlc' executable])
 
@@ -688,6 +692,8 @@ AC_SUBST([locallibdir], [${libdir}/${package_identifier}])
 AC_SUBST([localstatelibdir], [${localstatedir}/lib/${package_identifier}])
 AC_SUBST([localstatelogdir], [${localstatedir}/log/${package_identifier}])
 AC_SUBST([localstaterundir], [${localstatedir}/run/${package_identifier}])
+AC_SUBST([erlangversion], [${erlangversion}])
+
 
 # On Windows we install directly into our erlang distribution.
 if test x${IS_WINDOWS} = xTRUE; then

http://git-wip-us.apache.org/repos/asf/couchdb/blob/98683d90/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index fd7b040..f214b0f 100644
--- a/license.skip
+++ b/license.skip
@@ -24,6 +24,7 @@
 ^bin/Makefile.in
 ^bin/couchdb.1
 ^bin/couchjs.1
+^bin/erlang-version.escript
 ^build-aux/.*
 ^config..*
 ^configure


[15/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
teach `couch-config` `--erl-bin`


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

Branch: refs/heads/master
Commit: c8ac6773916be2e0e52ee3c60484e4097efebb40
Parents: 98683d9
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 18:06:28 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:35 2013 +0200

----------------------------------------------------------------------
 bin/Makefile.am         | 2 ++
 bin/couch-config.tpl.in | 5 +++++
 configure.ac            | 1 +
 3 files changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c8ac6773/bin/Makefile.am
----------------------------------------------------------------------
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 65f9ab5..5d722ac 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -96,6 +96,7 @@ couch-config: couch-config.tpl
 	    -e "s|%package_name%|@package_name@|g" \
 	    -e "s|%version%|@version@|g" \
 	    -e "s|%erlangversion%|@erlangversion@|g" \
+	    -e "s|%erlangbin%|@erlangbin@|g" \
 	    -e "s|%couchdb_command_name%|$(couchdb_command_name)|g" > \
 	$@ < $<
 	chmod +x $@
@@ -120,6 +121,7 @@ couch-config_dev: couch-config.tpl
 	    -e "s|%package_name%|@package_name@|g" \
 	    -e "s|%version%|@version@|g" \
 	    -e "s|%erlangversion%|@erlangversion@|g" \
+	    -e "s|%erlangbin%|@erlangbin@|g" \
 	    -e "s|%couchdb_command_name%|$(abs_top_builddir)/utils/run|g" > \
 	$@ < $<
 	chmod +x $@

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c8ac6773/bin/couch-config.tpl.in
----------------------------------------------------------------------
diff --git a/bin/couch-config.tpl.in b/bin/couch-config.tpl.in
index 7db9b2a..bd27d0e 100644
--- a/bin/couch-config.tpl.in
+++ b/bin/couch-config.tpl.in
@@ -23,6 +23,7 @@ confdir="%localconfdir%"
 urifile="%localstaterundir%/couch.uri"
 logdir="%localstatelogdir%"
 erlangversion="%erlangversion%"
+erlangbin="%erlangbin%"
 
 version () {
     cat << EOF
@@ -53,6 +54,7 @@ script.
 Options:
 
   --erl-libs-dir    Erlang library directory
+  --erl-bin         Erlang binary
   --config-dir      configuration directory
   --db-dir          database directory
   --view-dir        view index directory
@@ -86,6 +88,9 @@ do
         --erl-libs-dir)
             echo $erlanglibdir
             ;;
+        --erl-bin)
+            echo $erlangbin
+            ;;
         --config-dir)
             echo $confdir
             ;;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c8ac6773/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 9b980fb..a5c7f86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -693,6 +693,7 @@ AC_SUBST([localstatelibdir], [${localstatedir}/lib/${package_identifier}])
 AC_SUBST([localstatelogdir], [${localstatedir}/log/${package_identifier}])
 AC_SUBST([localstaterundir], [${localstatedir}/run/${package_identifier}])
 AC_SUBST([erlangversion], [${erlangversion}])
+AC_SUBST([erlangbin], [${ERL}])
 
 
 # On Windows we install directly into our erlang distribution.


[19/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update hash & version for faux geocouch release


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

Branch: refs/heads/master
Commit: 0f5aa11280b0abcaea0f5090d125d192dd72d136
Parents: 69acec4
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 17:07:57 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:35 2013 +0200

----------------------------------------------------------------------
 share/www/plugins.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0f5aa112/share/www/plugins.html
----------------------------------------------------------------------
diff --git a/share/www/plugins.html b/share/www/plugins.html
index a99826c..09f458f 100644
--- a/share/www/plugins.html
+++ b/share/www/plugins.html
@@ -33,7 +33,7 @@ specific language governing permissions and limitations under the License.
     <div id="content">
       <div class="row">
         <h2>GeoCouch</h2>
-        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-gd83ba22</strong></p>
+        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g4ea0bea</strong></p>
         <p>
           Available Erlang Versions:
           <ul>
@@ -41,7 +41,7 @@ specific language governing permissions and limitations under the License.
           </ul>
         </p>
         <p>
-          <button href="#" id="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"mw7RWJtbt7WMOF/ypwpgkRHT0Wo="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
+          <button href="#" id="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
         </p>
       </div>
 


[39/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add license to fauxton addons/plugins.html


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

Branch: refs/heads/master
Commit: ae5cfa0f0a5b3f63435918507225dcabed1254ca
Parents: a0cba30
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Sep 27 18:00:58 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:09:17 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/plugins/templates/plugins.html | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae5cfa0f/src/fauxton/app/addons/plugins/templates/plugins.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/templates/plugins.html b/src/fauxton/app/addons/plugins/templates/plugins.html
index 3a49c28..3002247 100644
--- a/src/fauxton/app/addons/plugins/templates/plugins.html
+++ b/src/fauxton/app/addons/plugins/templates/plugins.html
@@ -1,3 +1,17 @@
+<!--
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the License for the
+specific language governing permissions and limitations under the License.
+
+-->
     <div id="content">
       <div class="row">
         <h2>GeoCouch</h2>


[03/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add couch_plugins


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

Branch: refs/heads/master
Commit: dc6eb17e5949897bca522eabcbcffb5c3576bea5
Parents: 964324b
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 15:12:30 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:50 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/ebin/couch_plugins.app      |   9 +
 src/couch_plugins/src/couch_plugins.app.src   |  12 +
 src/couch_plugins/src/couch_plugins.erl       | 248 +++++++++++++++++++++
 src/couch_plugins/src/couch_plugins_httpd.erl |  10 +
 4 files changed, 279 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc6eb17e/src/couch_plugins/ebin/couch_plugins.app
----------------------------------------------------------------------
diff --git a/src/couch_plugins/ebin/couch_plugins.app b/src/couch_plugins/ebin/couch_plugins.app
new file mode 100644
index 0000000..b67645e
--- /dev/null
+++ b/src/couch_plugins/ebin/couch_plugins.app
@@ -0,0 +1,9 @@
+{application,couch_plugins,
+             [{description,"A CouchDB Plugin Installer"},
+              {vsn,"1"},
+              {registered,[]},
+              {applications,[kernel,stdlib]},
+              {mod,{couch_plugins_app,[]}},
+              {env,[]},
+              {modules,[couch_plugins,couch_plugins_app,couch_plugins_httpd,
+                        couch_plugins_sup]}]}.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc6eb17e/src/couch_plugins/src/couch_plugins.app.src
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.app.src b/src/couch_plugins/src/couch_plugins.app.src
new file mode 100644
index 0000000..059663c
--- /dev/null
+++ b/src/couch_plugins/src/couch_plugins.app.src
@@ -0,0 +1,12 @@
+{application, couch_plugins,
+ [
+  {description, "A CouchDB Plugin Installer"},
+  {vsn, "1"},
+  {registered, []},
+  {applications, [
+                  kernel,
+                  stdlib
+                 ]},
+  {mod, { couch_plugins_app, []}},
+  {env, []}
+ ]}.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc6eb17e/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
new file mode 100644
index 0000000..e406b2a
--- /dev/null
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -0,0 +1,248 @@
+-module(couch_plugins).
+-include("couch_db.hrl").
+%% Application callbacks
+-export([install/1]).
+
+
+% couch_plugins:install({"geocouch", "http://127.0.0.1:8000", "1.0.0", [{"R15B03", "+XOJP6GSzmuO2qKdnjO+mWckXVs="}]}).
+% couch_plugins:install({"geocouch", "http://people.apache.org/~jan/", "couchdb1.2.x_v0.3.0-11-gd83ba22", [{"R15B03", "Z9xK+OKLRvqKx3uoQHsiTuv6mrY="}]}).
+
+
+-define(PLUGIN_DIR, "/tmp/couchdb_plugins").
+
+log(T) -> 
+  ?LOG_DEBUG("[couch_plugins] ~p ~n", [T]).
+
+%% "geocouch", "http://localhost:8000/dist", "1.0.0"
+-type plugin() :: {string(), string(), string(), list()}.
+-spec install(plugin()) -> ok | {error, string()}.
+install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
+  log("Installing " ++ Name),
+
+  {ok, LocalFilename} = download(Plugin),
+  log("downloaded to " ++ LocalFilename),
+
+  ok = verify_checksum(LocalFilename, Checksums),
+  log("checksum verified"),
+
+  ok = untargz(LocalFilename),
+  log("extraction done"),
+
+  ok = add_code_path(Name, Version),
+  log("added code path"),
+
+  ok = load_config(Name, Version),
+  load_plugin(Name),
+
+  log("loaded plugin"),
+  ok.
+
+-spec load_config(string(), string()) -> ok | {error, string()}.
+load_config(Name, Version) ->
+  ConfigFile = ?PLUGIN_DIR ++ "/" ++ get_file_slug(Name, Version) ++ "/priv/config.erlt",
+  load_config_file(file_exists(ConfigFile), ConfigFile).
+
+-spec load_config_file(boolean(), string()) -> ok | {error, string()}.
+load_config_file(false, _) -> ok;
+load_config_file(true, ConfigFile) ->
+  % read file
+  {ok, ConfigFileData} = file:read_file(ConfigFile),
+  % split by \n
+  Lines = binary:split(ConfigFileData, <<"\n">>, [global]),
+  % feed each line...
+  lists:foreach(
+    fun(<<>>) ->
+      ok; % skip empty lines
+    (<<";", _Rest/binary>>) ->
+      ok; % ignore comments
+    (Line) ->
+    % ...to couch_util:parse_term()...
+    case couch_util:parse_term(Line) of
+      {ok, {{Section, Key}, Value}} ->
+        % ...and set the configs
+        ?LOG_DEBUG("parsed Line correctly: ~p", [Line]),
+        couch_config:set(Section, Key, Value);
+      Else ->
+        ?LOG_ERROR("Error parsing plugin config from line ~s", [Line]),
+        Else
+      end
+  end, Lines),
+  ok.
+
+-spec add_code_path(string(), string()) -> ok | {error, bad_directory}.
+add_code_path(Name, Version) ->
+  PluginPath = ?PLUGIN_DIR ++ "/" ++ get_file_slug(Name, Version) ++ "/ebin",
+  case code:add_path(PluginPath) of
+    true -> ok;
+    Else -> 
+      ?LOG_ERROR("Failed to add PluginPath: '~s'", [PluginPath]),
+      Else
+  end.
+
+load_plugin(NameList) ->
+  Name = list_to_atom(NameList),
+  application:load(Name).
+
+
+-spec untargz(string()) -> {ok, string()} | {error, string()}.
+untargz(Filename) ->
+  % read .gz file
+  {ok, GzData} = file:read_file(Filename),
+  % gunzip
+  log("unzipped"),
+  TarData = zlib:gunzip(GzData),
+  ok = filelib:ensure_dir(?PLUGIN_DIR),
+  % untar
+  erl_tar:extract({binary, TarData}, [{cwd, ?PLUGIN_DIR}, keep_old_files]).
+  
+
+% downloads a pluygin .tar.gz into a local plugins directory
+-spec download(string()) -> ok | {error, string()}.
+download({Name, _BaseUrl, Version, _Checksums}=Plugin) ->
+  TargetFile = "/tmp/" ++ get_filename(Name, Version),
+  case file_exists(TargetFile) of
+    %% wipe and redownload
+    true -> file:delete(TargetFile);
+    _Else -> ok
+  end,
+  Url = get_url(Plugin),
+  HTTPOptions = [
+    {connect_timeout, 30*1000}, % 30 seconds
+    {timeout, 30*1000} % 30 seconds
+  ],
+  % todo: windows
+  Options = [
+    {stream, TargetFile}, % /tmp/something
+    {body_format, binary},
+    {full_result, false}
+  ],
+  % todo: reduce to just httpc:request()
+  case httpc:request(get, {Url, []}, HTTPOptions, Options) of
+    {ok, _Result} ->
+      log("downloading " ++ Url),
+      {ok, TargetFile};
+    Error -> Error
+  end.
+
+-spec verify_checksum(string(), list()) -> ok | {error, string()}.
+verify_checksum(Filename, Checksums) ->
+  OTPRelease = erlang:system_info(otp_release),
+  case proplists:get_value(OTPRelease, Checksums) of
+  undefined ->
+    ?LOG_ERROR("[couch_plugins] Can't find checksum for OTP Release '~s'", [OTPRelease]),
+    {error, no_checksum};
+  Checksum ->
+    do_verify_checksum(Filename, Checksum)
+  end.
+
+-spec do_verify_checksum(string(), string()) -> ok | {error, string()}.
+do_verify_checksum(Filename, Checksum) ->
+  case file:read_file(Filename) of
+  {ok, Data} ->
+    ComputedChecksum = binary_to_list(base64:encode(crypto:sha(Data))),
+    case ComputedChecksum of
+    Checksum -> ok;
+    _Else ->
+      ?LOG_ERROR("Checksum mismatch. Wanted: '~p'. Got '~p'", [Checksum, ComputedChecksum]),
+      {error, checksum_mismatch}
+    end;
+  Error -> Error
+  end.
+
+
+
+
+-spec get_url(plugin()) -> string().
+get_url({Name, BaseUrl, Version, _Checksums}) ->
+  BaseUrl ++ "/" ++ get_filename(Name, Version).
+
+-spec get_filename(string(), string()) -> string().
+get_filename(Name, Version) ->
+  get_file_slug(Name, Version) ++ ".tar.gz".
+
+-spec get_file_slug(string(), string()) -> string().
+get_file_slug(Name, Version) ->
+  % OtpRelease does not include patch levels like the -1 in R15B03-1
+  OTPRelease = erlang:system_info(otp_release),
+  Name ++ "-" ++ Version ++ "-" ++ OTPRelease.
+
+-spec file_exists(string()) -> boolean().
+file_exists(Filename) ->
+  does_file_exist(file:read_file_info(Filename)).
+-spec does_file_exist(term()) -> boolean().
+does_file_exist({error, enoent}) -> false;
+does_file_exist(_Else) -> true.
+
+% installing a plugin:
+%  - POST /_plugins -d {plugin-def}
+%  - get plugin definition
+%  - get download URL (matching erlang version)
+%  - download archive
+%  - match checksum
+%  - untar-gz archive into a plugins dir
+%  - code:add_path(“geocouch-{geocouch_version}-{erlang_version}/ebin”)
+%  - [cp geocouch-{geocouch_version}-{erlang_version}/etc/ ]
+%  - application:start(geocouch)
+%  - register plugin in plugin registry
+
+% Plugin registry impl:
+%  - _plugins database
+%   - pro: known db ops
+%   - con: no need for replication, needs to be system db etc.
+%  - _config/plugins namespace in config
+%   - pro: lightweight, fits rarely-changing nature better
+%   - con: potentially not flexible enough
+
+
+
+% /geocouch
+% /geocouch/dist/
+% /geocouch/dist/geocouch-{geocouch_version}-{erlang_version}.tar.gz
+
+% tar.gz includes:
+% geocouch-{geocouch_version}-{erlang_version}/
+% geocouch-{geocouch_version}-{erlang_version}/ebin
+% [geocouch-{geocouch_version}-{erlang_version}/config/config.erlt]
+% [geocouch-{geocouch_version}-{erlang_version}/share/]
+
+
+
+% config.erlt:
+% // {{Section, Key}, Value}
+% {{"httpd_db_handlers", "_spatial_cleanup"}, "{couch_spatial_http, handle_cleanup_req}"}
+% {{"httpd_design_handlers", "_spatial"}, "{couch_spatial_http, handle_spatial_req}"}
+% {{"httpd_design_handlers", "_list"}, "{couch_spatial_list, handle_view_list_req}"}
+% {{"httpd_design_handlers", "_info"}, "{couch_spatial_http, handle_info_req}"}
+% {{"httpd_design_handlers", "_compact"}, "{couch_spatial_http, handle_compact_req}"}
+
+% milestones
+% 1. MVP
+%  - erlang plugins only
+%  - no c deps
+%  - install via futon (admin only)
+%  - uninstall via futon (admin only)
+%  - load plugin.tgz from the web
+%  - no security checking
+%  - no identity checking
+%  - hardcoded list of plugins in futon
+%  - must publish on *.apache.org/*
+
+% 2. Creator friendly
+%  - couchdb plugin template
+%  - easy to publish
+
+% 3. Public registry
+%  - plugin authors can publish stuff independently, shows up in futon
+%
+
+% XXX Later
+%  - signing of plugin releases
+%  - signing verification of plugin releases
+
+
+% Questions:
+% - where should the downloaded .beam files put?
+%  - in couch 1.x.x context
+%  - in bigcouch context
+%  - what is a server-user owned data/ dir we can use for this, that isn’t db_dir or index_dir or log or var/run or /tmp
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc6eb17e/src/couch_plugins/src/couch_plugins_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins_httpd.erl b/src/couch_plugins/src/couch_plugins_httpd.erl
new file mode 100644
index 0000000..1e61aa2
--- /dev/null
+++ b/src/couch_plugins/src/couch_plugins_httpd.erl
@@ -0,0 +1,10 @@
+-module(couch_plugins_httpd).
+
+-export([handle_req/1]).
+
+-include_lib("couch_db.hrl").
+
+handle_req(#httpd{method='PUT'}=Req) ->
+    couch_httpd:send_json(Req, 202, {[{ok, true}]});
+handle_req(Req) ->
+    couch_httpd:send_method_not_allowed(Req, "PUT").


[25/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
install plugins into tmp/plugins when running on `./utils/run`


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

Branch: refs/heads/master
Commit: 86ab419267371a1eac8c54e0997723bc2f9fd621
Parents: ef145a9
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 19:14:27 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 etc/couchdb/Makefile.am | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/86ab4192/etc/couchdb/Makefile.am
----------------------------------------------------------------------
diff --git a/etc/couchdb/Makefile.am b/etc/couchdb/Makefile.am
index 8d996f4..51b8fcb 100644
--- a/etc/couchdb/Makefile.am
+++ b/etc/couchdb/Makefile.am
@@ -44,6 +44,7 @@ default.ini: default.ini.tpl
 	    -e "s|%localconfdir%|$(localconfdir)|g" \
 	    -e "s|%localdatadir%|$(localdatadir)|g" \
 	    -e "s|%localbuilddatadir%|$(localdatadir)|g" \
+	    -e "s|%locallibdir%|$(locallibdir)|g" \
 	    -e "s|%localstatelibdir%|$(localstatelibdir)|g" \
 	    -e "s|%localstatelogdir%|$(localstatelogdir)|g" \
 	    -e "s|%localstaterundir%|$(localstaterundir)|g" \
@@ -58,6 +59,7 @@ default_dev.ini: default.ini.tpl
 	sed -e "s|%bindir%|$(abs_top_builddir)/bin|g" \
 	    -e "s|%localconfdir%|$(abs_top_builddir)/etc/couchdb|g" \
 	    -e "s|%localdatadir%|$(abs_top_srcdir)/share|g" \
+	    -e "s|%locallibdir%|$(abs_top_builddir)/tmp|g" \
 	    -e "s|%localbuilddatadir%|$(abs_top_builddir)/share|g" \
 	    -e "s|%localstatelibdir%|$(abs_top_builddir)/tmp/lib|g" \
 	    -e "s|%localstatelogdir%|$(abs_top_builddir)/tmp/log|g" \


[36/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
Allow plugins to provide config files (for their dependencies)


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

Branch: refs/heads/master
Commit: b53942628391c7b6341a244aa6ac2ec6aa076690
Parents: 520abcd
Author: Jason Smith (work) <ja...@gmail.com>
Authored: Sun Aug 18 11:48:14 2013 +0000
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 bin/couchdb.tpl.in | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b5394262/bin/couchdb.tpl.in
----------------------------------------------------------------------
diff --git a/bin/couchdb.tpl.in b/bin/couchdb.tpl.in
index 36d4dfb..6ebacf4 100644
--- a/bin/couchdb.tpl.in
+++ b/bin/couchdb.tpl.in
@@ -142,6 +142,12 @@ _add_config_dir () {
     done
 }
 
+_add_erlang_config () {
+    if [ -r "$1" ]; then
+        ERL_START_OPTIONS="$ERL_START_OPTIONS -config '$1'"
+    fi
+}
+
 _load_config () {
     _add_config_file "$DEFAULT_CONFIG_FILE"
     _add_config_dir "$DEFAULT_CONFIG_DIR"
@@ -233,6 +239,7 @@ _find_plugins () {
                     ERL_ZFLAGS="$ERL_ZFLAGS -pz '$plugin/ebin'"
                 fi
                 _add_config_dir "$plugin/priv/default.d"
+                _add_erlang_config "$plugin/priv/couch_plugin.config"
             fi
         done
         export ERL_ZFLAGS


[08/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
Use the same version hash in the entire readme.

Thanks @etrepum.


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

Branch: refs/heads/master
Commit: 84fd3c19d3f2dc675d2b111ccd5ea599112c3fa2
Parents: 06cd38e
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 19:43:53 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/84fd3c19/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 8384a97..de06309 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -108,7 +108,7 @@ Futon (or you) post an object to `/_plugins` with four properties:
     {
       "name": "geocouch", // name of the plugin, must be unique
       "url": "http://people.apache.org/~jan", // “base URL” for plugin releases (see below)
-      "version": "couchdb1.2.x_v0.3.0-11-gd83ba22", // whatever version internal to the plugin
+      "version": "couchdb1.2.x_v0.3.0-11-g4ea0bea", // whatever version internal to the plugin
       "checksums": {
         "R15B03": "ZetgdHj2bY2w37buulWVf3USOZs=" // base64’d sha hash over the binary
       }


[14/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add couchperuser


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

Branch: refs/heads/master
Commit: 084c8b4c367b909ba3b90bc7a901333ea5b676d6
Parents: c8ac677
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 18:19:52 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:35 2013 +0200

----------------------------------------------------------------------
 share/www/plugins.html | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/084c8b4c/share/www/plugins.html
----------------------------------------------------------------------
diff --git a/share/www/plugins.html b/share/www/plugins.html
index 09f458f..473531d 100644
--- a/share/www/plugins.html
+++ b/share/www/plugins.html
@@ -34,6 +34,7 @@ specific language governing permissions and limitations under the License.
       <div class="row">
         <h2>GeoCouch</h2>
         <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g4ea0bea</strong></p>
+        <p>Author: Volker Mische</p>
         <p>
           Available Erlang Versions:
           <ul>
@@ -41,14 +42,27 @@ specific language governing permissions and limitations under the License.
           </ul>
         </p>
         <p>
-          <button href="#" id="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
+          <button href="#" class="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
+        </p>
+      </div>
+      <div class="row">
+        <h2>CouchPerUser</h2>
+        <p>Version: <strong>1.0.0</strong></p>
+        <p>Author: Bob Ippolito</p>
+        <p>
+          Available Erlang Versions:
+          <ul>
+            <li>R15B01</li>
+          </ul>
+        </p>
+        <p>
+          <button href="#" class="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"2IvVuihCBAE4SIN3qgjofx23wJs="}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
         </p>
       </div>
-
     </div>
   </div></body>
   <script>
-    $('#install_plugin').click(function(event) {
+    $('.install_plugin').click(function(event) {
       var button = $(this);
       var plugin_spec = JSON.stringify({
         name: button.data('name'),
@@ -77,6 +91,7 @@ specific language governing permissions and limitations under the License.
   .row {
     background-color: #EEE;
     padding:1em;
+    margin-bottom:1em;
   }
   </style>
 </html>


[02/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update comment


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

Branch: refs/heads/master
Commit: 27bf560c3e7550a13c4925c24e46ea8e1dc6bee4
Parents: dc6eb17
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 15:14:55 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:50 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/27bf560c/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index e406b2a..0a65bf7 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -5,7 +5,7 @@
 
 
 % couch_plugins:install({"geocouch", "http://127.0.0.1:8000", "1.0.0", [{"R15B03", "+XOJP6GSzmuO2qKdnjO+mWckXVs="}]}).
-% couch_plugins:install({"geocouch", "http://people.apache.org/~jan/", "couchdb1.2.x_v0.3.0-11-gd83ba22", [{"R15B03", "Z9xK+OKLRvqKx3uoQHsiTuv6mrY="}]}).
+% couch_plugins:install({"geocouch", "http://people.apache.org/~jan/", "couchdb1.2.x_v0.3.0-11-gd83ba22", [{"R15B03", "ZetgdHj2bY2w37buulWVf3USOZs="}]}).
 
 
 -define(PLUGIN_DIR, "/tmp/couchdb_plugins").


[29/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add draft for `couch_plugins:uninstall()`


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

Branch: refs/heads/master
Commit: dd836092265ad6060edbede0624e91e40a06b00a
Parents: 0f7a4ef
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 18:17:29 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins.erl | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/dd836092/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 7adadc4..9c2c58f 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -51,6 +51,33 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
 
   ok.
 
+% Idempotent uninstall, if you uninstall a non-existant
+% plugin, you get an `ok`.
+% -spec uninstall(string()) -> ok | {error, string()}.
+% uninstall(Name) ->
+%   % unload app
+%   ok = unload_plugin(Name),
+%   log("plugin unloaded"),
+
+%   % unload config
+%   ok = unload_config(Name),
+%   log("config unloaded"),
+
+%   % delete files
+%   ok = delete_files(Name),
+%   log("files deleted"),
+
+%   % remove code path
+%   ok = remove_code_path(Name),
+%   log("removed code path"),
+
+%   % unregister plugin
+%   ok = unregister_plugin(Name),
+%   log("unregistered plugin"),
+
+%   % done
+%   ok.
+
 %% * * *
 
 


[23/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
register plugins at _config/plugins/pluginname with their version number


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

Branch: refs/heads/master
Commit: 21e839a22f6879ec8f03d9b4ea3fde7712e0faf0
Parents: 084c8b4
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 18:44:45 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md             |  2 +-
 src/couch_plugins/src/couch_plugins.erl | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/21e839a2/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 8851794..081788d 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -48,13 +48,13 @@ Here’s a list of things this first iterations does and doesn’t do:
 - Only installs if Erlang version matches.
 - No security checking of binaries.
 - No identity checking of binaries.
+- Register installed plugins in the config system.
 
 Here are a few things I want to add before I call it MVP*:
 
 - Uninstall a plugin via Futon (or HTTP call). Admin only.
 - Only installs if CouchDB version matches.
 - Binaries must be published on *.apache.org.
-- Register installed plugins in the config system.
 - Make sure plugins start with the next restart of CouchDB.
 - Show when a particular plugin is installed.
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/21e839a2/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index a7680c3..bbfa1e4 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -39,12 +39,21 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
   ok = add_code_path(Name, Version),
   log("added code path"),
 
-  ok = load_config(Name, Version),
-  load_plugin(Name),
+  ok = register_plugin(Name, Version),
+  log("registered plugin"),
 
+  ok = load_plugin(Name),
   log("loaded plugin"),
+
+  load_config(Name, Version),
+  log("loaded config"),
+
   ok.
 
+-spec register_plugin(string(), string()) -> ok.
+register_plugin(Name, Version) ->
+  couch_config:set("plugins", Name, Version).
+
 -spec load_config(string(), string()) -> ok.
 load_config(Name, Version) ->
     lists:foreach(


[24/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update todo list in README


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

Branch: refs/heads/master
Commit: 2bed2a5ab22035ac6a052f3ac95665a8e8ff4f01
Parents: 86ab419
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 17:59:04 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/2bed2a5a/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 081788d..c75b87d 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -49,13 +49,13 @@ Here’s a list of things this first iterations does and doesn’t do:
 - No security checking of binaries.
 - No identity checking of binaries.
 - Register installed plugins in the config system.
+- Make sure plugins start with the next restart of CouchDB.
 
 Here are a few things I want to add before I call it MVP*:
 
 - Uninstall a plugin via Futon (or HTTP call). Admin only.
 - Only installs if CouchDB version matches.
 - Binaries must be published on *.apache.org.
-- Make sure plugins start with the next restart of CouchDB.
 - Show when a particular plugin is installed.
 
 *MVP hopefully means you agree we can ship this with a few warnings


[27/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add inline comments


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

Branch: refs/heads/master
Commit: 0f7a4efa663da5dea5d89afb773518535038beec
Parents: 2bed2a5
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 18:17:05 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md             |  2 ++
 src/couch_plugins/src/couch_plugins.erl | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0f7a4efa/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index c75b87d..02a83ce 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -85,6 +85,8 @@ Milestone X: Later
  - Add some account/identity/maybe crypto-web-of-trust system for
    authors to publish “legit” plugins.
  - Sign & verify individual releases.
+ - Handle unclean un/installs if CouchDB crashes while installing/
+   uninstalling
 
 A few more things that can happen concurrently depending on what
 plugins require:

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0f7a4efa/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index dfd59a2..7adadc4 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -51,10 +51,30 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
 
   ok.
 
+%% * * *
+
+
+%% Plugin Registration
+%% On uninstall:
+%%  - add plugins/name = version to config
+%% On uninstall:
+%%  - remove plugins/name from config
+
 -spec register_plugin(string(), string()) -> ok.
 register_plugin(Name, Version) ->
   couch_config:set("plugins", Name, Version).
 
+-spec unregister_plugin(string()) -> ok.
+unregister_plugin(Name) ->
+  couch_config:delete("plugins", Name).
+
+%% * * *
+
+
+%% Load Config
+%% Pareses <plugindir>/priv/default.d/<pluginname.ini> and applies
+%% the contents to the config system.
+
 -spec load_config(string(), string()) -> ok.
 load_config(Name, Version) ->
     lists:foreach(
@@ -73,6 +93,10 @@ load_config_file(File) ->
 set_config({{Section, Key}, Value}) ->
     ok = couch_config:set(Section, Key, Value, false).
 
+%% * * *
+
+
+
 -spec add_code_path(string(), string()) -> ok | {error, bad_directory}.
 add_code_path(Name, Version) ->
   PluginPath = plugin_dir() ++ "/" ++ get_file_slug(Name, Version) ++ "/ebin",


[26/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
make plugin dir configurable


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

Branch: refs/heads/master
Commit: ef145a968248f2f9a272a1763053140b0560c1e7
Parents: f9f10fe
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 19:14:03 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:36 2013 +0200

----------------------------------------------------------------------
 etc/couchdb/default.ini.tpl.in          |  2 ++
 src/couch_plugins/src/couch_plugins.erl | 11 ++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ef145a96/etc/couchdb/default.ini.tpl.in
----------------------------------------------------------------------
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 7645c33..3267001 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -27,6 +27,8 @@ file_compression = snappy
 ; time for writes when there are many attachment write requests in parallel.
 attachment_stream_buffer_size = 4096
 
+plugin_dir = %locallibdir%/plugins
+
 [database_compaction]
 ; larger buffer sizes can originate smaller files
 doc_buffer_size = 524288 ; value in bytes

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ef145a96/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index bbfa1e4..dfd59a2 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -16,7 +16,8 @@
 % couch_plugins:install({"geocouch", "http://127.0.0.1:8000", "1.0.0", [{"R15B03", "+XOJP6GSzmuO2qKdnjO+mWckXVs="}]}).
 % couch_plugins:install({"geocouch", "http://people.apache.org/~jan/", "couchdb1.2.x_v0.3.0-11-gd83ba22", [{"R15B03", "ZetgdHj2bY2w37buulWVf3USOZs="}]}).
 
--define(PLUGIN_DIR, "/tmp/couchdb_plugins").
+plugin_dir() ->
+  couch_config:get("couchdb", "plugin_dir").
 
 log(T) ->
   ?LOG_DEBUG("[couch_plugins] ~p ~n", [T]).
@@ -60,7 +61,7 @@ load_config(Name, Version) ->
       fun load_config_file/1,
       filelib:wildcard(
         filename:join(
-          [?PLUGIN_DIR, get_file_slug(Name, Version),
+          [plugin_dir(), get_file_slug(Name, Version),
            "priv", "default.d", "*.ini"]))).
 
 -spec load_config_file(string()) -> ok.
@@ -74,7 +75,7 @@ set_config({{Section, Key}, Value}) ->
 
 -spec add_code_path(string(), string()) -> ok | {error, bad_directory}.
 add_code_path(Name, Version) ->
-  PluginPath = ?PLUGIN_DIR ++ "/" ++ get_file_slug(Name, Version) ++ "/ebin",
+  PluginPath = plugin_dir() ++ "/" ++ get_file_slug(Name, Version) ++ "/ebin",
   case code:add_path(PluginPath) of
     true -> ok;
     Else ->
@@ -95,9 +96,9 @@ untargz(Filename) ->
   % gunzip
   log("unzipped"),
   TarData = zlib:gunzip(GzData),
-  ok = filelib:ensure_dir(?PLUGIN_DIR),
+  ok = filelib:ensure_dir(plugin_dir()),
   % untar
-  erl_tar:extract({binary, TarData}, [{cwd, ?PLUGIN_DIR}, keep_old_files]).
+  erl_tar:extract({binary, TarData}, [{cwd, plugin_dir()}, keep_old_files]).
 
 
 % downloads a pluygin .tar.gz into a local plugins directory


[16/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add _plugins to [httpd_global_handlers] in default.ini


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

Branch: refs/heads/master
Commit: 69acec4c3e977db0b9055141972ee60b8d789ebf
Parents: c3efead
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Aug 1 17:07:40 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:35 2013 +0200

----------------------------------------------------------------------
 etc/couchdb/default.ini.tpl.in | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/69acec4c/etc/couchdb/default.ini.tpl.in
----------------------------------------------------------------------
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 43b13a0..7645c33 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -160,6 +160,7 @@ _log = {couch_httpd_misc_handlers, handle_log_req}
 _session = {couch_httpd_auth, handle_session_req}
 _oauth = {couch_httpd_oauth, handle_oauth_req}
 _db_updates = {couch_dbupdates_httpd, handle_req}
+_plugins = {couch_plugins_httpd, handle_req}
 
 [httpd_db_handlers]
 _all_docs = {couch_mrview_http, handle_all_docs_req}


[33/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update roadmap in README


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

Branch: refs/heads/master
Commit: ba8b68fd4d591a0a47d7f8be8b7814a87e090903
Parents: 075c811
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Aug 2 23:10:57 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ba8b68fd/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 8ed62c3..929f27a 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -52,14 +52,10 @@ Here’s a list of things this first iterations does and doesn’t do:
 - Make sure plugins start with the next restart of CouchDB.
 - Uninstall a plugin via Futon (or HTTP call). Admin only.
 - Show when a particular plugin is installed.
-
-Here are a few things I want to add before I call it MVP*:
-
 - Only installs if CouchDB version matches.
-- Binaries must be published on *.apache.org.
 
-*MVP hopefully means you agree we can ship this with a few warnings
-so people can get a hang of it.
+I hope you agree we can ship this with a few warnings so people can get a
+hang of it.
 
 Here is a rough list of features squared against future milestones:
 


[11/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update readme


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

Branch: refs/heads/master
Commit: bbbbd5015b2d55204eae9cbbfae357f728d20033
Parents: ff67d18
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 19:07:36 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 45 +++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/bbbbd501/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 58ad296..53fd47a 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -7,7 +7,9 @@ Here’s a <1 minute demo video:
 
   https://dl.dropboxusercontent.com/u/82149/couchdb-plugins-demo.mov
 
-  (alternative encoding: https://dl.dropboxusercontent.com/u/82149/couchdb-plugins-demo.m4v)
+Alternative encoding:
+
+  https://dl.dropboxusercontent.com/u/82149/couchdb-plugins-demo.m4v)
 
 
 In my head the whole plugin idea is a very wide area, but I was so
@@ -19,19 +21,21 @@ button in Futon. So I looked for a minimally viable plugin system.
 
 It took me a day to put this all together and this was only possible
 because I took a lot of shortcuts. I believe they are all viable for a
-first iteration of a plugins system.
+first iteration of a plugins system:
 
 1. Install with one click on a button in Futon (or HTTP call)
 2. Only pure Erlang plugins are allowed.
-3. The plugin author must provide a binary package for each Erlang (and
-   later each CouchDB version).
+3. The plugin author must provide a binary package for each Erlang (and,
+   later, each CouchDB version).
 4. Complete trust-based system. You trust me to not do any nasty things
    when you click on the install button. No crypto, no nothing. Only
    people who can commit to Futon can release new versions of plugins.
 5. Minimal user-friendlyness: won’t install plugins that don’t match 
-   the current Erlang version.
+   the current Erlang version, gives semi-sensible error messages
+   (wrapped in a HTTP 500 response :)
 6. Require a pretty strict format for binary releases.
 
+
 ## Roadmap
 
 Here’s a list of things this first iterations does and doesn’t do:
@@ -45,13 +49,14 @@ Here’s a list of things this first iterations does and doesn’t do:
 - No security checking of binaries.
 - No identity checking of binaries.
 
-Here are a few things I want to add before I call it MVP:
+Here are a few things I want to add before I call it MVP*:
 
 - Uninstall a plugin via Futon (or HTTP call). Admin only.
 - Only installs if CouchDB version matches.
 - Binaries must be published on *.apache.org.
 - Register installed plugins in the config system.
 - Make sure plugins start with the next restart of CouchDB.
+- Show when a particular plugin is installed.
 
 *MVP hopefully means you agree we can ship this with a few warnings
 so people can get a hang of it.
@@ -79,16 +84,17 @@ Milestone 4: Other Languages
 Milestone X: Later
  - Add some account/identity/maybe crypto-web-of-trust system for
    authors to publish “legit” plugins.
- - Sign & verify individual releases
+ - Sign & verify individual releases.
 
 A few more things that can happen concurrently depending on what
 plugins require:
- - integrate Erlang/JS tests in the installation
- - integrate docs
+ - Integrate Erlang/JS tests in the installation
+ - Integrate docs
+
 
 ## How it works
 
-This plugin system lives in src/couch_plugins and is a tiny CouchDB
+This plugin system lives in `src/couch_plugins` and is a tiny CouchDB
 module.
 
 It exposes one new API endpoint `/_plugins` that an admin user can
@@ -113,7 +119,8 @@ location:
 
     http://people.apache.org/~jan/geocouch-couchdb1.2.x_v0.3.0-12-g4ea0bea-R15B03.tar.gz
 
-(this url is live, feel free to play around with this tarball).
+It should be obvious how the URL is constructed from the POST data.
+(This url is live, feel free to play around with this tarball).
 
 Next it calculates the sha hash for the downloaded .tar.gz file and
 matches it against the correct version in the `checksums` parameter.
@@ -122,7 +129,7 @@ If that succeeds, we unpack the .tar.gz file (currently in `/tmp`,
 need to find a better place for this) and adds the extracted directory
 to the Erlang code path
 (`code:add_path("/tmp/couchdb_plugins/geocouch-couchdb1.2.x_v0.3.0-12-g4ea0bea-R15B03/ebin")`)
-and loads the included application (`application:load(geocouch)`)
+and loads the included application (`application:load(geocouch)`).
 
 Then it looks into the `./config` directory that lives next to `ebin/`
 in the plugin directory for a file `config.erlt` (“erl-terms”). with a
@@ -138,8 +145,8 @@ leaves a few things open (see above).
 
 One open question I’d like an answer for is finding a good location to
 unpack & install the plugin files that isn’t `tmp`. If the answer is
-different for a pre-BigCouch/rcouch-merge and
-post-BigCouch/rcouch-merge world, I’d love to know :)
+different for a pre-BigCouch/rcouch-merge and post-BigCouch/rcouch-
+merge world, I’d love to know :)
 
 
 ## Code
@@ -154,11 +161,15 @@ that shows how a binary package is built:
 
     https://github.com/janl/geocouch/compare/couchbase:couchdb1.3.x...couchdb1.3.x-plugins
 
+* * *
+
+I hope you like this :) Please comment and improve heavily!
 
-Please comment and improve heavily.
+Let me know if you have any questions :)
 
 If you have any criticism, please phrase it in a way that we can use
-to improve this.
+to improve this, thanks!
 
-Cheers
+Best,
 Jan
+-- 


[34/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
move couch_version() to couch_server:couch_version(short)


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

Branch: refs/heads/master
Commit: b6eba9e341af62e9a412239a5dc587d487aa3ace
Parents: ba8b68f
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Aug 3 15:19:13 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/src/couch_plugins.erl | 4 +---
 src/couchdb/couch_server.erl            | 7 ++++++-
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b6eba9e3/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index 507f114..2b110bc 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -264,9 +264,7 @@ does_file_exist({error, enoent}) -> false;
 does_file_exist(_Else) -> true.
 
 couchdb_version() ->
-  %% strip git hash from version string
-  [Version|_Rest] = string:tokens(couch_server:get_version(), "+"),
-  Version.
+  couch_server:get_version(short).
 
 % installing a plugin:
 %  - POST /_plugins -d {plugin-def}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b6eba9e3/src/couchdb/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 4aceb55..7cee0f5 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -13,7 +13,7 @@
 -module(couch_server).
 -behaviour(gen_server).
 
--export([open/2,create/2,delete/2,get_version/0,get_uuid/0]).
+-export([open/2,create/2,delete/2,get_version/0,get_version/1,get_uuid/0]).
 -export([all_databases/0, all_databases/2]).
 -export([init/1, handle_call/3,sup_start_link/0]).
 -export([handle_cast/2,code_change/3,handle_info/2,terminate/2]).
@@ -42,6 +42,11 @@ get_version() ->
     false ->
         "0.0.0"
     end.
+get_version(short) ->
+  %% strip git hash from version string
+  [Version|_Rest] = string:tokens(get_version(), "+"),
+  Version.
+
 
 get_uuid() ->
     case couch_config:get("couchdb", "uuid", nil) of


[41/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
unlink plugins from Futon & Fauxton


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

Branch: refs/heads/master
Commit: 95d6e35ace38f122ca94fe83f43b34545505e52d
Parents: ae5cfa0
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Oct 2 19:43:01 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:09:18 2013 +0200

----------------------------------------------------------------------
 share/www/_sidebar.html                | 4 ++--
 src/fauxton/app/addons/plugins/base.js | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/95d6e35a/share/www/_sidebar.html
----------------------------------------------------------------------
diff --git a/share/www/_sidebar.html b/share/www/_sidebar.html
index 26a1bc8..7ef3513 100644
--- a/share/www/_sidebar.html
+++ b/share/www/_sidebar.html
@@ -23,7 +23,7 @@ specific language governing permissions and limitations under the License.
       <li><a href="config.html">Configuration</a></li>
       <li><a href="replicator.html">Replicator</a></li>
       <li><a href="status.html">Status</a></li>
-      <li><a href="plugins.html">Plugins</a></li>
+      <!-- <li><a href="plugins.html">Plugins</a></li> -->
     </ul></li>
     <li><span>Documentation</span><ul>
       <li><a href="docs/">Manual</a></li>
@@ -53,7 +53,7 @@ specific language governing permissions and limitations under the License.
         <a href="#" class="logout">Logout</a>
       </span>
       <span class="adminparty">
-        Welcome to Admin Party! 
+        Welcome to Admin Party!
         <br/>
         Everyone is admin. <a href="#" class="createadmin">Fix this</a>
       </span>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/95d6e35a/src/fauxton/app/addons/plugins/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/base.js b/src/fauxton/app/addons/plugins/base.js
index 140a1f8..0798fbd 100644
--- a/src/fauxton/app/addons/plugins/base.js
+++ b/src/fauxton/app/addons/plugins/base.js
@@ -18,7 +18,7 @@ define([
 
 function(app, FauxtonAPI, plugins) {
   plugins.initialize = function() {
-    FauxtonAPI.addHeaderLink({title: "Plugins", href: "#_plugins", icon: "fonticon-plugins", className: 'plugins'});
+    //FauxtonAPI.addHeaderLink({title: "Plugins", href: "#_plugins", icon: "fonticon-plugins", className: 'plugins'});
   };
   return plugins;
 });


[17/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
load plugin config from priv/default.d/*.ini


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

Branch: refs/heads/master
Commit: c3efead76f0b7977ee86c7258aad8121ea065911
Parents: 963aee4
Author: Bob Ippolito <bo...@redivi.com>
Authored: Thu Aug 1 01:47:50 2013 -0700
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:35 2013 +0200

----------------------------------------------------------------------
 Makefile.am                             |  1 +
 bin/Makefile.am                         |  1 +
 bin/couchdb.tpl.in                      | 39 +++++++++++---------
 src/couch_plugins/Makefile.am           |  1 +
 src/couch_plugins/README.md             |  8 ++---
 src/couch_plugins/src/couch_plugins.erl | 53 ++++++++++------------------
 src/couchdb/couch_config.erl            |  2 +-
 utils/Makefile.am                       |  1 +
 8 files changed, 51 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index debfdf4..527cf18 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -113,6 +113,7 @@ if TESTS
 	mkdir -p $(top_builddir)/tmp/lib
 	mkdir -p $(top_builddir)/tmp/log
 	mkdir -p $(top_builddir)/tmp/run/couchdb
+	mkdir -p $(top_builddir)/tmp/plugins
 endif
 
 install-data-hook:

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/bin/Makefile.am
----------------------------------------------------------------------
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 3d7a075..c1913d0 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -51,6 +51,7 @@ couchdb: couchdb.tpl
 	    -e "s|%localstatelogdir%|@localstatelogdir@|g" \
 	    -e "s|%localstatelibdir%|@localstatelibdir@|g" \
 	    -e "s|%localstatedir%|@localstatedir@|g" \
+	    -e "s|%locallibdir%|@locallibdir@|g" \
 	    -e "s|%bug_uri%|@bug_uri@|g" \
 	    -e "s|%package_author_address%|@package_author_address@|g" \
 	    -e "s|%package_author_name%|@package_author_name@|g" \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/bin/couchdb.tpl.in
----------------------------------------------------------------------
diff --git a/bin/couchdb.tpl.in b/bin/couchdb.tpl.in
index ff06007..36d4dfb 100644
--- a/bin/couchdb.tpl.in
+++ b/bin/couchdb.tpl.in
@@ -25,6 +25,7 @@ HEART_BEAT_TIMEOUT=11
 HEART_COMMAND="%bindir%/%couchdb_command_name% -k"
 INTERACTIVE=false
 KILL=false
+PLUGINS_DIR=%locallibdir%/plugins
 LOCAL_CONFIG_DIR=%localconfdir%/local.d
 LOCAL_CONFIG_FILE=%localconfdir%/%localini%
 PID_FILE=%localstatedir%/run/couchdb/couchdb.pid
@@ -144,6 +145,8 @@ _add_config_dir () {
 _load_config () {
     _add_config_file "$DEFAULT_CONFIG_FILE"
     _add_config_dir "$DEFAULT_CONFIG_DIR"
+    # We initialize plugins here to get the desired default config load order
+    _find_plugins
     _add_config_file "$LOCAL_CONFIG_FILE"
     _add_config_dir "$LOCAL_CONFIG_DIR"
     if [ "$COUCHDB_ADDITIONAL_CONFIG_FILE" != '' ]
@@ -216,6 +219,26 @@ check_environment () {
     fi
 }
 
+_find_plugins () {
+    # Find plugins and add them to the Erlang path and load their default
+    # configurations. This should be called from _load_config.
+    if test -d "$PLUGINS_DIR"; then
+        for plugin in "$PLUGINS_DIR"/*; do
+            if echo "$COUCH_PLUGIN_BLACKLIST" | grep "$plugin" > /dev/null 2> /dev/null; then
+                : # Do not use this plugin.
+            else
+                if echo "$ERL_ZFLAGS" | grep "$plugin/ebin" > /dev/null 2> /dev/null; then
+                    : # It's already loaded.
+                else
+                    ERL_ZFLAGS="$ERL_ZFLAGS -pz '$plugin/ebin'"
+                fi
+                _add_config_dir "$plugin/priv/default.d"
+            fi
+        done
+        export ERL_ZFLAGS
+    fi
+}
+
 start_couchdb () {
     if test ! "$RECURSED" = "true"; then
         if check_status 2> /dev/null; then
@@ -232,22 +255,6 @@ start_couchdb () {
         interactive_option="+Bd -noinput"
     fi
 
-    # Find plugins and add them to the Erlang path.
-    if test -d "%localerlanglibdir%/../../plugins"; then
-        for plugin in "%localerlanglibdir%/../../plugins"/*; do
-            if echo "$ERL_ZFLAGS" | grep "$plugin/ebin" > /dev/null 2> /dev/null; then
-                : # It's already loaded.
-            else
-                if echo "$COUCH_PLUGIN_BLACKLIST" | grep "$plugin" > /dev/null 2> /dev/null; then
-                    : # Do not use this plugin.
-                else
-                    ERL_ZFLAGS="$ERL_ZFLAGS -pz '$plugin/ebin'"
-                fi
-            fi
-        done
-        export ERL_ZFLAGS
-    fi
-
     command="%ERL% $interactive_option $ERL_START_OPTIONS \
         -env ERL_LIBS $ERL_LIBS:%localerlanglibdir% -couch_ini $start_arguments -s couch"
     if test "$BACKGROUND" = "true" -a "$RECURSED" = "false"; then

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/src/couch_plugins/Makefile.am
----------------------------------------------------------------------
diff --git a/src/couch_plugins/Makefile.am b/src/couch_plugins/Makefile.am
index 300f19c..91adfae 100644
--- a/src/couch_plugins/Makefile.am
+++ b/src/couch_plugins/Makefile.am
@@ -10,6 +10,7 @@
 ## License for the specific language governing permissions and limitations under
 ## the License.
 
+couch_pluginslibdir = $(localerlanglibdir)/couch_plugins-0.1
 couch_pluginsebindir = $(couch_pluginslibdir)/ebin
 
 couch_pluginsebin_DATA = $(compiled_files)

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 09a0a71..8851794 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -131,10 +131,10 @@ to the Erlang code path
 (`code:add_path("/tmp/couchdb_plugins/geocouch-couchdb1.2.x_v0.3.0-12-g4ea0bea-R15B03/ebin")`)
 and loads the included application (`application:load(geocouch)`).
 
-Then it looks into the `./config` directory that lives next to `ebin/`
-in the plugin directory for a file `config.erlt` (“erl-terms”). with a
-list of configuration parameters to load. We parse the file and set
-the config directives one by one.
+Then it looks into the `./priv/default.d` directory that lives next to
+`ebin/` in the plugin directory for configuration `.ini` files and loads them.
+On next startup these configuration files are loaded after global defaults,
+and before any local configuration.
 
 If that all goes to plan, we report success back to the HTTP caller.
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/src/couch_plugins/src/couch_plugins.erl
----------------------------------------------------------------------
diff --git a/src/couch_plugins/src/couch_plugins.erl b/src/couch_plugins/src/couch_plugins.erl
index daac885..a7680c3 100644
--- a/src/couch_plugins/src/couch_plugins.erl
+++ b/src/couch_plugins/src/couch_plugins.erl
@@ -18,7 +18,7 @@
 
 -define(PLUGIN_DIR, "/tmp/couchdb_plugins").
 
-log(T) -> 
+log(T) ->
   ?LOG_DEBUG("[couch_plugins] ~p ~n", [T]).
 
 %% "geocouch", "http://localhost:8000/dist", "1.0.0"
@@ -45,44 +45,30 @@ install({Name, _BaseUrl, Version, Checksums}=Plugin) ->
   log("loaded plugin"),
   ok.
 
--spec load_config(string(), string()) -> ok | {error, string()}.
+-spec load_config(string(), string()) -> ok.
 load_config(Name, Version) ->
-  ConfigFile = ?PLUGIN_DIR ++ "/" ++ get_file_slug(Name, Version) ++ "/priv/config.erlt",
-  load_config_file(file_exists(ConfigFile), ConfigFile).
-
--spec load_config_file(boolean(), string()) -> ok | {error, string()}.
-load_config_file(false, _) -> ok;
-load_config_file(true, ConfigFile) ->
-  % read file
-  {ok, ConfigFileData} = file:read_file(ConfigFile),
-  % split by \n
-  Lines = binary:split(ConfigFileData, <<"\n">>, [global]),
-  % feed each line...
-  lists:foreach(
-    fun(<<>>) ->
-      ok; % skip empty lines
-    (<<";", _Rest/binary>>) ->
-      ok; % ignore comments
-    (Line) ->
-    % ...to couch_util:parse_term()...
-    case couch_util:parse_term(Line) of
-      {ok, {{Section, Key}, Value}} ->
-        % ...and set the configs
-        ?LOG_DEBUG("parsed Line correctly: ~p", [Line]),
-        couch_config:set(Section, Key, Value);
-      Else ->
-        ?LOG_ERROR("Error parsing plugin config from line ~s", [Line]),
-        Else
-      end
-  end, Lines),
-  ok.
+    lists:foreach(
+      fun load_config_file/1,
+      filelib:wildcard(
+        filename:join(
+          [?PLUGIN_DIR, get_file_slug(Name, Version),
+           "priv", "default.d", "*.ini"]))).
+
+-spec load_config_file(string()) -> ok.
+load_config_file(File) ->
+    {ok, Config} = couch_config:parse_ini_file(File),
+    lists:foreach(fun set_config/1, Config).
+
+-spec set_config({{string(), string()}, string()}) -> ok.
+set_config({{Section, Key}, Value}) ->
+    ok = couch_config:set(Section, Key, Value, false).
 
 -spec add_code_path(string(), string()) -> ok | {error, bad_directory}.
 add_code_path(Name, Version) ->
   PluginPath = ?PLUGIN_DIR ++ "/" ++ get_file_slug(Name, Version) ++ "/ebin",
   case code:add_path(PluginPath) of
     true -> ok;
-    Else -> 
+    Else ->
       ?LOG_ERROR("Failed to add PluginPath: '~s'", [PluginPath]),
       Else
   end.
@@ -103,7 +89,7 @@ untargz(Filename) ->
   ok = filelib:ensure_dir(?PLUGIN_DIR),
   % untar
   erl_tar:extract({binary, TarData}, [{cwd, ?PLUGIN_DIR}, keep_old_files]).
-  
+
 
 % downloads a pluygin .tar.gz into a local plugins directory
 -spec download(string()) -> ok | {error, string()}.
@@ -256,4 +242,3 @@ does_file_exist(_Else) -> true.
 %  - in couch 1.x.x context
 %  - in bigcouch context
 %  - what is a server-user owned data/ dir we can use for this, that isn’t db_dir or index_dir or log or var/run or /tmp
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/src/couchdb/couch_config.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl
index 96fabba..22d7cdc 100644
--- a/src/couchdb/couch_config.erl
+++ b/src/couchdb/couch_config.erl
@@ -94,7 +94,7 @@ register(Fun, Pid) ->
 init(IniFiles) ->
     ets:new(?MODULE, [named_table, set, protected]),
     try
-        lists:map(fun(IniFile) ->
+        lists:foreach(fun(IniFile) ->
             {ok, ParsedIniValues} = parse_ini_file(IniFile),
             ets:insert(?MODULE, ParsedIniValues)
         end, IniFiles),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/c3efead7/utils/Makefile.am
----------------------------------------------------------------------
diff --git a/utils/Makefile.am b/utils/Makefile.am
index e5bbdb8..5afe707 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -34,6 +34,7 @@ run: ../bin/couchdb.tpl
 	    -e "s|%localstatelogdir%|$(abs_top_builddir)/tmp/log|g" \
 	    -e "s|%localstatelibdir%|$(abs_top_builddir)/tmp/lib|g" \
 	    -e "s|%localstatedir%|$(abs_top_builddir)/tmp|g" \
+	    -e "s|%locallibdir%|$(abs_top_builddir)/tmp|g" \
 	    -e "s|%bug_uri%|@bug_uri@|g" \
 	    -e "s|%package_author_address%|@package_author_address@|g" \
 	    -e "s|%package_author_name%|@package_author_name@|g" \


[37/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
update roadmap


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

Branch: refs/heads/master
Commit: 520abcd855f9f2c8f45a868dff33c7d2d3069ffd
Parents: aef4072
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Aug 3 15:20:48 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:08:37 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/520abcd8/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
index 929f27a..b1d6fb7 100644
--- a/src/couch_plugins/README.md
+++ b/src/couch_plugins/README.md
@@ -53,6 +53,7 @@ Here’s a list of things this first iterations does and doesn’t do:
 - Uninstall a plugin via Futon (or HTTP call). Admin only.
 - Show when a particular plugin is installed.
 - Only installs if CouchDB version matches.
+- Serve static web assets (for Futon/Fauxton) from `/_plugins/<name>/`.
 
 I hope you agree we can ship this with a few warnings so people can get a
 hang of it.


[10/42] git commit: updated refs/heads/master to a4d6cd4

Posted by ja...@apache.org.
add readme


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

Branch: refs/heads/master
Commit: ff67d183b3377bda4d15a89bdb99bc48228c1afe
Parents: 4f8a2b4
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Jul 31 19:00:21 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:04:51 2013 +0200

----------------------------------------------------------------------
 src/couch_plugins/README.md | 164 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 164 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ff67d183/src/couch_plugins/README.md
----------------------------------------------------------------------
diff --git a/src/couch_plugins/README.md b/src/couch_plugins/README.md
new file mode 100644
index 0000000..58ad296
--- /dev/null
+++ b/src/couch_plugins/README.md
@@ -0,0 +1,164 @@
+Heya,
+
+I couldn’t help myself thinking about plugin stuff and ended up
+whipping up a proof of concept.
+
+Here’s a <1 minute demo video:
+
+  https://dl.dropboxusercontent.com/u/82149/couchdb-plugins-demo.mov
+
+  (alternative encoding: https://dl.dropboxusercontent.com/u/82149/couchdb-plugins-demo.m4v)
+
+
+In my head the whole plugin idea is a very wide area, but I was so
+intrigued by the idea of getting something running with a click on a
+button in Futon. So I looked for a minimally viable plugin system.
+
+
+## Design principles
+
+It took me a day to put this all together and this was only possible
+because I took a lot of shortcuts. I believe they are all viable for a
+first iteration of a plugins system.
+
+1. Install with one click on a button in Futon (or HTTP call)
+2. Only pure Erlang plugins are allowed.
+3. The plugin author must provide a binary package for each Erlang (and
+   later each CouchDB version).
+4. Complete trust-based system. You trust me to not do any nasty things
+   when you click on the install button. No crypto, no nothing. Only
+   people who can commit to Futon can release new versions of plugins.
+5. Minimal user-friendlyness: won’t install plugins that don’t match 
+   the current Erlang version.
+6. Require a pretty strict format for binary releases.
+
+## Roadmap
+
+Here’s a list of things this first iterations does and doesn’t do:
+
+- Pure Erlang plugins only. No C-dependencies, no JavaScript, no nothing.
+- No C-dependencies.
+- Install a plugin via Futon (or HTTP call). Admin only.
+- A hardcoded list of plugins in Futon.
+- Loads a pre-packaged, pre-compiled .tar.gz file from a URL.
+- Only installs if Erlang version matches.
+- No security checking of binaries.
+- No identity checking of binaries.
+
+Here are a few things I want to add before I call it MVP:
+
+- Uninstall a plugin via Futon (or HTTP call). Admin only.
+- Only installs if CouchDB version matches.
+- Binaries must be published on *.apache.org.
+- Register installed plugins in the config system.
+- Make sure plugins start with the next restart of CouchDB.
+
+*MVP hopefully means you agree we can ship this with a few warnings
+so people can get a hang of it.
+
+Here is a rough list of features squared against future milestones:
+
+Milestone 2: Be creator friendly
+ - Make it easy to build a CouchDB plugin by providing one or more easy 
+   to start templates.
+ - Make it easy to publish new plugins and new versions of existing plugins.
+ - Make it easy to supply packages for multiple Erlang & CouchDB versions.
+
+Milestone 3: Public registry
+ - Instead of hardcoding a list of plugins into Futon/Fauxton, we load
+   a list of applicable plugins from a central (and configurable)
+   plugins repository.
+ - This allows plugin authors to publish new plugins and new versions
+   of existing plugins independently.
+
+Milestone 4: Other Languages
+ - Figure out how to handle C-dependencies for Erlang plugins.
+ - Figure out how to allow other language plugins
+   (c.f. non-JS query servers)
+
+Milestone X: Later
+ - Add some account/identity/maybe crypto-web-of-trust system for
+   authors to publish “legit” plugins.
+ - Sign & verify individual releases
+
+A few more things that can happen concurrently depending on what
+plugins require:
+ - integrate Erlang/JS tests in the installation
+ - integrate docs
+
+## How it works
+
+This plugin system lives in src/couch_plugins and is a tiny CouchDB
+module.
+
+It exposes one new API endpoint `/_plugins` that an admin user can
+POST to.
+
+The additional Futon page lives at /_utils/plugins.html it is
+hardcoded.
+
+Futon (or you) post an object to `/_plugins` with four properties:
+
+    {
+      "name": "geocouch", // name of the plugin, must be unique
+      "url": "http://people.apache.org/~jan", // “base URL” for plugin releases (see below)
+      "version": "couchdb1.2.x_v0.3.0-11-gd83ba22", // whatever version internal to the plugin
+      "checksums": {
+        "R15B03": "ZetgdHj2bY2w37buulWVf3USOZs=" // base64’d sha hash over the binary
+      }
+    }
+
+`couch_plugins` then attempts to download a .tar.gz from this
+location:
+
+    http://people.apache.org/~jan/geocouch-couchdb1.2.x_v0.3.0-12-g4ea0bea-R15B03.tar.gz
+
+(this url is live, feel free to play around with this tarball).
+
+Next it calculates the sha hash for the downloaded .tar.gz file and
+matches it against the correct version in the `checksums` parameter.
+
+If that succeeds, we unpack the .tar.gz file (currently in `/tmp`,
+need to find a better place for this) and adds the extracted directory
+to the Erlang code path
+(`code:add_path("/tmp/couchdb_plugins/geocouch-couchdb1.2.x_v0.3.0-12-g4ea0bea-R15B03/ebin")`)
+and loads the included application (`application:load(geocouch)`)
+
+Then it looks into the `./config` directory that lives next to `ebin/`
+in the plugin directory for a file `config.erlt` (“erl-terms”). with a
+list of configuration parameters to load. We parse the file and set
+the config directives one by one.
+
+If that all goes to plan, we report success back to the HTTP caller.
+
+That’s it! :)
+
+It’s deceptively simple, probably does a few things very wrong and
+leaves a few things open (see above).
+
+One open question I’d like an answer for is finding a good location to
+unpack & install the plugin files that isn’t `tmp`. If the answer is
+different for a pre-BigCouch/rcouch-merge and
+post-BigCouch/rcouch-merge world, I’d love to know :)
+
+
+## Code
+
+The main branch for this is 1867-feature-plugins:
+
+     ASF: https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=log;h=refs/heads/1867-feature-plugins
+  GitHub: https://github.com/janl/couchdb/compare/1867-feature-plugins
+
+I created a branch on GeoCouch that adds a few lines to its `Makefile`
+that shows how a binary package is built:
+
+    https://github.com/janl/geocouch/compare/couchbase:couchdb1.3.x...couchdb1.3.x-plugins
+
+
+Please comment and improve heavily.
+
+If you have any criticism, please phrase it in a way that we can use
+to improve this.
+
+Cheers
+Jan