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 17:46:59 UTC

[01/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Updated Branches:
  refs/heads/1894-feature-experimental-nodejs-couchjs e8f5dd36d -> 532100c10 (forced update)


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/1894-feature-experimental-nodejs-couchjs
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
 
 * * *
 


[39/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
configure nodejs view server


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 1c61f30b30e15397ee039d66991abbeb2c03e321
Parents: dc37570
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 15:43:59 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/1c61f30b/etc/couchdb/default.ini.tpl.in
----------------------------------------------------------------------
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 3267001..981bbb1 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -123,6 +123,7 @@ use_users_db = false
 [query_servers]
 javascript = %bindir%/%couchjs_command_name% %localbuilddatadir%/server/main.js
 coffeescript = %bindir%/%couchjs_command_name% %localbuilddatadir%/server/main-coffee.js
+nodejs = /usr/local/bin/couchjs-node %localbuilddatadir%/server/main.js
 
 
 ; Changing reduce_limit to false will disable reduce_limit.


[05/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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.


[04/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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>


[10/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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:


[07/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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>
 


[09/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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" \


[45/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
add sandbox.js


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: ba6bdae4e3e941c8f815228d5937f35a33deddf7
Parents: 12763ee
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:28:47 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 NOTICE                      |  4 ++++
 license.skip                |  1 +
 src/couchjs-node/sandbox.js | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ba6bdae4/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 6a41c6c..5c95dd2 100644
--- a/NOTICE
+++ b/NOTICE
@@ -189,3 +189,7 @@ This product also includes the following third-party components:
  * share/doc/src/templates/couchdb/domainindex.html
 
    Copyright 2007-2011 by the Sphinx team
+
+ * sandbox.js https://github.com/KlausTrainer/sandbox.js
+
+   (c) 2013 Klaus Trainer

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ba6bdae4/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index d87cc6c..4352011 100644
--- a/license.skip
+++ b/license.skip
@@ -110,6 +110,7 @@
 ^src/couchdb/priv/couchspawnkillable
 ^src/couchdb/priv/stat_descriptions.cfg
 ^src/couchjs-node/package.json
+^src/couchjs-node/sandbox.js
 ^src/couchjs-node/README.md
 ^src/erlang-oauth/.*
 ^src/couch_dbupdates

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ba6bdae4/src/couchjs-node/sandbox.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/sandbox.js b/src/couchjs-node/sandbox.js
new file mode 100644
index 0000000..cfdff18
--- /dev/null
+++ b/src/couchjs-node/sandbox.js
@@ -0,0 +1,40 @@
+// from https://github.com/KlausTrainer/sandbox.js
+exports.runInSandbox = function(src, ctx, whitelist) {
+  var vm = require('vm'),
+    sandbox;
+
+  if (ctx && ctx.require) {
+    whitelist = whitelist || [];
+    var insecureRequire = ctx.require,
+      module = require("module"),
+      oldModulePrototype = module.prototype;
+
+    var secureRequire = function(moduleName) {
+      if (whitelist.indexOf(moduleName) == -1) {
+        module.prototype = oldModulePrototype;
+        throw new Error("'" + moduleName + "' is not whitelisted");
+      } else {
+        var requiredModule = insecureRequire(moduleName);
+        module.prototype = oldModulePrototype;
+        return requiredModule;
+      }
+    };
+
+    module.prototype = {
+      require: secureRequire,
+      load: module.prototype.load,
+      _compile: module.prototype._compile
+    };
+
+    module._cache = {};
+
+    ctx.require = secureRequire;
+    sandbox = Object.freeze(vm.createContext(ctx));
+    ctx.require = insecureRequire;
+  } else {
+    sandbox = Object.freeze(vm.createContext(ctx || {}));
+  }
+
+  return vm.createScript('(function() {"use strict"; return ('
+                         + src + ')()}())').runInContext(sandbox);
+};


[34/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: eebe8aeee9bbf8b6d0dec745aa8552b68e477f82
Parents: 1c61f30
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:14:39 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

----------------------------------------------------------------------
 share/doc/build/Makefile.am    |  2 +
 share/doc/src/contents.rst     |  1 +
 share/doc/src/experimental.rst | 73 +++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/eebe8aee/share/doc/build/Makefile.am
----------------------------------------------------------------------
diff --git a/share/doc/build/Makefile.am b/share/doc/build/Makefile.am
index 66819fa..1b69ef6 100644
--- a/share/doc/build/Makefile.am
+++ b/share/doc/build/Makefile.am
@@ -143,6 +143,7 @@ html_files = \
     html/_sources/about.txt \
     html/_sources/contents.txt \
     html/_sources/contributing.txt \
+    html/_sources/experimental.txt \
     html/_sources/externals.txt \
     html/_sources/json-structure.txt \
     html/_static/ajax-loader.gif \
@@ -403,6 +404,7 @@ src_files = \
     ../src/whatsnew/index.rst \
     ../src/about.rst \
     ../src/contents.rst \
+    ../src/experimental.rst \
     ../src/contributing.rst \
     ../src/externals.rst \
     ../src/json-structure.rst \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/eebe8aee/share/doc/src/contents.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/contents.rst b/share/doc/src/contents.rst
index 0b38b73..4395f92 100644
--- a/share/doc/src/contents.rst
+++ b/share/doc/src/contents.rst
@@ -29,6 +29,7 @@
     fauxton/index
     api/index
     json-structure
+    experimental
     contributing
     whatsnew/index
     cve/index

http://git-wip-us.apache.org/repos/asf/couchdb/blob/eebe8aee/share/doc/src/experimental.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/experimental.rst b/share/doc/src/experimental.rst
new file mode 100644
index 0000000..1e883bf
--- /dev/null
+++ b/share/doc/src/experimental.rst
@@ -0,0 +1,73 @@
+.. 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.
+
+.. _experimental:
+
+=====================
+Experimental Features
+=====================
+
+This is a list of experimental features in CouchDB. They are included in
+a release because the development team is requesting feedback from the
+larger developer community. As such, please play around with these features
+and send us feedback, thanks!
+
+Use at your own risk! Do not rely on these features for critical
+applications.
+
+NodeJS Query Server
+===================
+
+The NodeJS Query Server is an alternative runtime environment for
+the default JavaScript Query Server that runs on top of Node.JS and
+not SpiderMonkey like the default Query Server.
+
+
+Setup
+-----
+
+You will need to install Node.JS version 0.10.0 or later. See `Node.JS
+Downloads <http://nodejs.org/download/>`_ for options.
+
+1. Install the `couchjs-node` binary. Either via NPM:
+
+.. code-block:: shell
+
+    npm install -g couchjs
+
+Or from the CouchDB sources:
+
+.. code-block:: shell
+
+    cd src/couchjs-node
+    npm link
+
+.. note:: **NPM in non-standard locations**
+
+    If your Node.JS installation doesn’t store binaries in `/usr/local/bin`
+    you will need to adjust CouchDB’s configuration. Add this to your `local.ini`
+    file:
+
+    .. code-block:: ini
+
+      [query_servers]
+      nodejs = /path/to/couchjs-node /path/to/couchdb/share/server/main.js
+
+    And then restart your CouchDB instance.
+
+2. Done. Now you can create design documents with the `language` parameter
+set to `nodejs` and all JavaScript functions in this design document will
+be processed by the Node.JS query server.
+
+Enjoy!
+
+


[24/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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.


[17/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[15/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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",


[33/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
update license.skip for compiled fauxton images


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 3e19db216ce44ae1c6729ed68d1316b12b5d1875
Parents: a4d6cd4
Author: Jan Lehnardt <ja...@apache.org>
Authored: Thu Oct 3 17:20:57 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:20:57 2013 +0200

----------------------------------------------------------------------
 license.skip | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/3e19db21/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index f214b0f..067fce3 100644
--- a/license.skip
+++ b/license.skip
@@ -80,6 +80,7 @@
 ^share/www/script/base64.js
 ^share/www/script/test/lorem.*
 ^share/www/style/jquery-ui-1.8.11.custom.css
+^share/www/fauxton/img/.*
 ^src/Makefile
 ^src/Makefile.in
 ^src/couch_index/Makefile


[49/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
move module exports past function decrarations


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 447f101d3245e18384cddfedc10277ff7fe2647b
Parents: 0902e8c
Author: Sven Lito <me...@svenlito.com>
Authored: Thu Oct 3 16:33:11 2013 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:45:40 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/couchjs.js | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/447f101d/src/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchjs.js b/src/couchjs-node/couchjs.js
index 7b12dc3..84c21e0 100644
--- a/src/couchjs-node/couchjs.js
+++ b/src/couchjs-node/couchjs.js
@@ -10,14 +10,6 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-module.exports = {
-  'print': print,
-  'readline': readline,
-  'stdin': stdin,
-  'evalcx': evalcx,
-  'quit': quit,
-  'gc': gc
-};
 
 
 var vm = require('vm');
@@ -127,3 +119,13 @@ function toSource() {
 
   return util.inspect(this);
 }
+
+module.exports = {
+  'print': print,
+  'readline': readline,
+  'stdin': stdin,
+  'evalcx': evalcx,
+  'quit': quit,
+  'gc': gc
+};
+


[43/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
add differences notice


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: ccf9309c32ec06821babd94a3c5ecaaa279fed9f
Parents: 868c261
Author: Jan Lehnardt <ja...@apache.org>
Authored: Tue Sep 24 15:09:37 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 share/doc/src/experimental.rst | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ccf9309c/share/doc/src/experimental.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/experimental.rst b/share/doc/src/experimental.rst
index 1e883bf..7d11ab3 100644
--- a/share/doc/src/experimental.rst
+++ b/share/doc/src/experimental.rst
@@ -71,3 +71,9 @@ be processed by the Node.JS query server.
 Enjoy!
 
 
+Differences from the SpiderMonkey Query Server
+----------------------------------------------
+
+V8 and SpiderMonkey roughly behave similar, but there might be engine-
+specific differences that make or break a JavaScript function in one or
+the other server.


[26/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[22/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[03/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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 ->


[27/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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) ->


[42/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
prefer install from source


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 96d3847e25deb331dd9ba4dae42e879d124d1100
Parents: ea6fe18
Author: Jan Lehnardt <ja...@apache.org>
Authored: Tue Sep 24 17:10:25 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 share/doc/src/experimental.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/96d3847e/share/doc/src/experimental.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/experimental.rst b/share/doc/src/experimental.rst
index 7d11ab3..bca22a0 100644
--- a/share/doc/src/experimental.rst
+++ b/share/doc/src/experimental.rst
@@ -38,18 +38,18 @@ Setup
 You will need to install Node.JS version 0.10.0 or later. See `Node.JS
 Downloads <http://nodejs.org/download/>`_ for options.
 
-1. Install the `couchjs-node` binary. Either via NPM:
+1. Install the `couchjs-node` binary. Either from the CouchDB sources:
 
 .. code-block:: shell
 
-    npm install -g couchjs
+    cd src/couchjs-node
+    npm link
 
-Or from the CouchDB sources:
+Or via NPM:
 
 .. code-block:: shell
 
-    cd src/couchjs-node
-    npm link
+    npm install -g couchjs
 
 .. note:: **NPM in non-standard locations**
 


[02/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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:


[25/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[19/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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.
+
 %% * * *
 
 


[08/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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}


[38/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
add couchjs-node from Jason


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: dc375701d02db659b6364f1d2aab4d6631c1e285
Parents: 3e19db2
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 15:42:47 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/LICENSE            | 202 ++++++++++++++++++
 src/couchjs-node/README.md          |  54 +++++
 src/couchjs-node/checkout.sh        |  36 ++++
 src/couchjs-node/cli.js             |  85 ++++++++
 src/couchjs-node/console.js         |  65 ++++++
 src/couchjs-node/couchdb.js         |  29 +++
 src/couchjs-node/couchjs.js         | 116 +++++++++++
 src/couchjs-node/extra.js           | 346 +++++++++++++++++++++++++++++++
 src/couchjs-node/inspector.js       |  92 ++++++++
 src/couchjs-node/package.json       |  30 +++
 src/couchjs-node/stream.js          | 107 ++++++++++
 src/couchjs-node/test/experiment.js | 105 ++++++++++
 src/couchjs-node/xml.js             |  23 ++
 13 files changed, 1290 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/LICENSE
----------------------------------------------------------------------
diff --git a/src/couchjs-node/LICENSE b/src/couchjs-node/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/src/couchjs-node/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/README.md
----------------------------------------------------------------------
diff --git a/src/couchjs-node/README.md b/src/couchjs-node/README.md
new file mode 100644
index 0000000..c686e80
--- /dev/null
+++ b/src/couchjs-node/README.md
@@ -0,0 +1,54 @@
+# CouchJS
+
+## Drop-in replacement JavaScript engine for Apache CouchDB
+
+CouchJS is a command-line Node.js program. It is 100% compatible with Apache CouchDB's built-in JavaScript system.
+
+By using CouchJS, you will get 100% CouchDB compatibility (the test suite completely passes) but your JavaScript environment is V8, or Node.js.
+
+CouchJS is available as an npm module.
+
+    $ npm install -g couchjs
+
+## Usage
+
+Install CouchDB. Install this package with npm. Confirm your `couchjs` install location.
+
+    $ which couchjs # Note, your path will be different from mine.
+    /home/jhs/node/bin/couchjs
+
+Look at the CouchDB config for the JavaScript query server.
+
+    $ curl http://localhost:5984/_config/query_servers/javascript
+    "/home/jhs/couchdb/bin/couchjs /home/jhs/couchdb/share/couchdb/server/main.js"
+
+Change that to this `couchjs`. **Leave the second argument the same.**
+
+    $ curl -X PUT http://localhost:5984/_config/query_servers/javascript \
+      -H content-type:application/json \
+      -d "\"`which couchjs` /home/jhs/couchdb/share/couchdb/server/main.js\""
+
+Done!
+
+## Idea
+
+JavaScript is decoupled from the CouchDB core. To do JavaScript stuff, CouchDB runs a normal Unix subprocess, `couchjs`. This subprocess is just a read-eval-print loop on standard i/o. CouchDB passes `couchjs` a file name, and *that file* contains the view server  implementation.
+
+This tool duplicates the "REPL" look and feel of `couchjs` and supports the exact same view server implementation.
+
+## Security
+
+I have no idea. I would not trust it for production use.
+
+## Log
+
+If you create a file, `/tmp/couchjs.log` then *couchjs* will output debugging messages there.
+
+## License
+
+Apache 2.0
+
+See the [Apache 2.0 license](named/blob/master/LICENSE).
+
+[tap]: https://github.com/isaacs/node-tap
+[def]: https://github.com/iriscouch/defaultable

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/checkout.sh
----------------------------------------------------------------------
diff --git a/src/couchjs-node/checkout.sh b/src/couchjs-node/checkout.sh
new file mode 100644
index 0000000..0076b51
--- /dev/null
+++ b/src/couchjs-node/checkout.sh
@@ -0,0 +1,36 @@
+# Copyright 2011 Iris Couch
+#
+#    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.
+
+repo="$1"
+commit="$2"
+
+if [ -z "$repo" -o ! -d "$repo" ]; then
+  echo "Not a valid repo: $repo" >&2
+  exit 1
+fi
+if [ -z "$commit" ]; then
+  echo "Not a valid commit: $commit" >&2
+  exit 1
+fi
+
+echo "Clone $repo:$commit to $(pwd)"
+
+set -e
+
+git clone "$repo" .
+git checkout "$commit"
+
+if [ -z "$skip_npm_install" ]; then
+  npm install --production
+fi

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/cli.js b/src/couchjs-node/cli.js
new file mode 100755
index 0000000..14a6d97
--- /dev/null
+++ b/src/couchjs-node/cli.js
@@ -0,0 +1,85 @@
+#!/usr/bin/env node
+//
+// couchjs replacement
+//
+// Copyright 2011 Iris Couch
+//
+//    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.
+
+var fs = require('fs')
+var util = require('util')
+var Fiber = require('fibers')
+var optimist = require('optimist')
+var child_process = require('child_process')
+
+var couchjs = require('./couchjs')
+var package_json = require('./package.json')
+var couchdb_extra = require('./extra')
+var LineStream = require('./stream')
+var inspector = require('./inspector')
+var log = require('./console').log
+
+
+var opts = optimist.boolean(['h', 'V', 'H'])
+                   .describe({ 'h': 'display a short help message and exit'
+                             , 'V': 'display version information and exit'
+                             , 'H': 'enable couchjs cURL bindings (not implemented)'
+                             })
+                   .boolean('extra')
+                   .describe('extra', 'Extra features for CouchDB, for os_daemons')
+                   .usage('$0 <path to main.js>')
+
+
+function main() {
+  if(opts.argv.extra)
+    return couchdb_extra()
+
+  var main_js = opts.argv._[0]
+  if(!main_js)
+    return console.error(opts.help())
+
+  log('couchjs/%s %s: %s', package_json.version, process.pid, main_js)
+  if(process.env.COUCHJS_DEBUG_PORT)
+    inspector(+process.env.COUCHJS_DEBUG_PORT)
+
+  fs.readFile(main_js, 'utf8', function(er, body) {
+    if(er)
+      throw er
+
+    var stdin = new LineStream.v2
+    stdin.on('readable', function() {
+      var buf = stdin.read()
+      if(buf)
+        couchjs.stdin(buf)
+    })
+    stdin.on('end', function() {
+      log('Terminate; connection to parent closed')
+      process.exit(0)
+    })
+
+    process.stdin.setEncoding('utf8')
+    process.stdin.pipe(stdin)
+
+    var main_func = Function(['print', 'readline', 'evalcx', 'gc', 'quit'], body)
+
+    log('Call main')
+    Fiber(function() { main_func(couchjs.print, couchjs.readline, couchjs.evalcx, couchjs.gc) }).run()
+  })
+
+  process.on('uncaughtException', function(er) {
+    log('Error:\n%s', er.stack)
+  })
+}
+
+if(require.main === module)
+  main()

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/console.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/console.js b/src/couchjs-node/console.js
new file mode 100644
index 0000000..2a0a17a
--- /dev/null
+++ b/src/couchjs-node/console.js
@@ -0,0 +1,65 @@
+// Copyright 2011 Iris Couch
+//
+//    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.
+
+var fs = require('fs')
+var util = require('util')
+
+
+module.exports = {}
+module.exports.log = noop
+module.exports.debug = noop
+module.exports.info = noop
+module.exports.warn = noop
+module.exports.error = noop
+
+var LOG_PATH = '/tmp/couchjs.log'
+  , stat = null
+  , LOG = null
+
+try {
+  stat = fs.statSync(LOG_PATH)
+} catch(er) {}
+
+if(stat) {
+  LOG = fs.createWriteStream(LOG_PATH, {'flags':'a'})
+
+  module.exports.log = log
+  module.exports.debug = log
+  module.exports.info = log
+  module.exports.warn = log
+  module.exports.error = log
+
+  process.on('exit', function() {
+    module.exports.log('Exit %d', process.pid)
+  })
+
+  process.on('uncaughtException', on_err)
+}
+
+function log() {
+  var str = util.format.apply(this, arguments)
+  LOG.write(str + '\n')
+}
+
+function on_err(er) {
+  module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er))
+
+  if(er.stack)
+    er = ['fatal', 'unknown_error', er.stack]
+
+  process.stdout.write(JSON.stringify(er) + '\n')
+  process.exit(1)
+}
+
+function noop() {}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/couchdb.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchdb.js b/src/couchjs-node/couchdb.js
new file mode 100755
index 0000000..d297112
--- /dev/null
+++ b/src/couchjs-node/couchdb.js
@@ -0,0 +1,29 @@
+// Copyright 2011 Iris Couch
+//
+//    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.exports = handler
+
+var http = require('http')
+
+function handler(req, res) {
+  res.writeHead(200)
+  res.end('Hello: ' + req.url + '\n')
+}
+
+if(require.main === module) {
+  var http = require('http')
+  var server = http.createServer(handler)
+  server.listen(3000)
+  console.log('Listening on :3000')
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchjs.js b/src/couchjs-node/couchjs.js
new file mode 100644
index 0000000..d95341d
--- /dev/null
+++ b/src/couchjs-node/couchjs.js
@@ -0,0 +1,116 @@
+// Copyright 2011 Iris Couch
+//
+//    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.exports = { 'print'   : print
+                 , 'readline': readline
+                 , 'stdin'   : stdin
+                 , 'evalcx'  : evalcx
+                 , 'quit'    : quit
+                 , 'gc'      : gc
+                 }
+
+
+var vm = require('vm')
+var Fiber = require('fibers')
+
+var XML = require('./xml')
+var log = require('./console').log
+
+var INPUT = {'queue':[], 'waiting':null}
+
+Error.prototype.toSource = Error.prototype.toSource || toSource
+Error.prototype.toString = Error.prototype.toString || toSource
+Function.prototype.toSource = Function.prototype.toSource || toSource
+Function.prototype.toString = Function.prototype.toString || toSource
+
+
+function print(line) {
+  log('STDOUT %s: %s', process.pid, line)
+  process.stdout.write(line + '\n')
+
+  try {
+    line = JSON.parse(line)
+  } catch(er) { return }
+
+  if(line[0] == 'log')
+    log('LOG: %s', line[1])
+}
+
+function stdin(line) {
+  log('STDIN %s: %s', process.pid, line.trim())
+  if(INPUT.waiting)
+    INPUT.waiting.run(line)
+  else
+    INPUT.queue.push(line)
+}
+
+function readline() {
+  var line = INPUT.queue.shift()
+  if(line)
+    return line
+
+  INPUT.waiting = Fiber.current
+  line = Fiber.yield()
+  INPUT.waiting = null
+
+  return line
+}
+
+
+function evalcx(source, sandbox) {
+  sandbox = sandbox || {}
+  //log('evalcx in %j: %j', Object.keys(sandbox), source)
+
+  if(source == '')
+    return sandbox
+
+  // source might be "function(doc) { emit(doc._id, 1) }"
+  source = source.replace(/;+$/, '')
+
+  sandbox.XML = sandbox.XML || XML
+  source = '(' + source + ')'
+
+  try {
+    var id = Math.floor(Math.random() * 1000*1000)
+    var filename = '_couchdb:' + id + '.js'
+    var script = vm.createScript(source, filename)
+    var func = script.runInNewContext(sandbox)
+  } catch (er) {
+    log('Error making code: %s', er.stack)
+    return sandbox
+  }
+
+  return func
+}
+
+function quit(code) {
+  code = code || 1
+  if(code < 0)
+    code = -code
+
+  process.exit(code)
+}
+
+function gc() { }
+
+
+function toSource() {
+  if(typeof this == 'function')
+    return '' + this
+
+  if(this instanceof Error)
+    return this.stack
+
+  return util.inspect(this)
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/extra.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/extra.js b/src/couchjs-node/extra.js
new file mode 100755
index 0000000..2df0168
--- /dev/null
+++ b/src/couchjs-node/extra.js
@@ -0,0 +1,346 @@
+#!/usr/bin/env node
+// Copyright 2011 Iris Couch
+//
+//    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.exports = main
+
+var os = require('os')
+var fs = require('fs')
+var URL = require('url')
+var util = require('util')
+var http = require('http')
+var async = require('async')
+var mkdirp = require('mkdirp')
+var request = require('request')
+var optimist = require('optimist')
+var pushover = require('pushover')
+var child_process = require('child_process')
+
+var console = require('./console')
+var VER = require('./package.json').version
+
+var couch = { 'log': mk_couch_log('info')
+            , 'warn' : mk_couch_log('warn')
+            , 'error': mk_couch_log('error')
+            , 'debug': mk_couch_log('debug')
+            }
+
+
+var opts = optimist.usage('$0')
+
+var COUCH = null
+var GIT_DIR = null
+var COUCH_PASSWORD = null
+var GIT_PORT = null
+var APPLICATION = null
+
+function main() {
+  if(opts.argv.help)
+    return console.log(opts.help())
+
+  console.log('Extra CouchDB daemon: %s', process.pid)
+  couch.debug('CouchDB daemon %s: %s', VER, process.pid)
+
+  var env = {}
+  for (var k in process.env) {
+    var match = k.match(/^_couchdb_app_(.*)$/)
+    if(match)
+      env[match[1]] = process.env[k]
+  }
+
+  for (k in env)
+    couch.debug('  %s = %s', k, env[k])
+
+  if(env.port && env.password && env.couch && env.dir)
+    return git(env)
+
+  setInterval(function() {
+    console.log('Still here')
+    couch.log('Still in couch')
+  }, 60000)
+}
+
+function git(env) {
+  GIT_PORT = +env.port
+  COUCH = env.couch
+  COUCH_DIR = util.format('%s/couchjs-%s', env.dir, VER)
+  COUCH_PASSWORD = env.password
+
+  //var couch_url = util.format('http://_nodejs:%s@127.0.0.1:%d', password, couch_port)
+  //couch.log('couch url %j', couch_url)
+
+  auth('_nodejs', COUCH_PASSWORD, function(er, userCtx) {
+    if(er)
+      throw er
+
+    var roles = userCtx.roles || []
+    if(userCtx.name != '_nodejs' || !~roles.indexOf('_admin'))
+      throw new Error('Not admin: ' + JSON.stringify(res.body.userCtx))
+
+    var repos = pushover(COUCH_DIR)
+    repos.on('push', function(push) {
+      couch.log('Push %s/%s: %s', push.repo, push.commit, push.branch)
+      push.accept()
+      //couch.log('Response: %j', Object.keys(push.response))
+      push.response.on('finish', function() {
+        //couch.log('Finished!')
+        publish(push)
+      })
+    })
+
+    repos.on('fetch', function(fetch) {
+      couch.log('fetch %j', fetch.commit)
+      fetch.accept()
+    })
+
+    var server = http.createServer(function(req, res) {
+      if(! req.url.match(/^\/_nodejs\/_git(\/|$)/))
+        return handle_http(req, res)
+
+      req.pause()
+      auth_req(req, function(er, userCtx) {
+        if(er && er.statusCode) {
+          res.writeHead(er.statusCode, er.headers)
+          return res.end(er.body)
+        }
+
+        if(er) {
+          couch.log('Bad req %s: %s', req.url, er.message)
+          return res.end()
+        }
+
+        var roles = userCtx.roles || []
+        if(!~ roles.indexOf('_admin')) {
+          couch.log('Not admin: %s, %j', req.url, userCtx)
+          res.writeHead(401, 'Unauthorized', {'content-type':'application/json'})
+          return res.end('{"error":"not_authorized"}\n')
+        }
+
+        //couch.log('Handle Git: %j', req.url)
+        repos.handle(req, res)
+        req.resume()
+      })
+    })
+
+    server.listen(GIT_PORT)
+  })
+}
+
+function handle_http(req, res) {
+  if(! APPLICATION) {
+    var headers = { 'content-type': 'application/json'
+                  , 'server': 'NodeJS-CouchDB/'+VER
+                  }
+    res.writeHead(200, 'OK', headers)
+    var body = {'ok':true}
+    return res.end(JSON.stringify(body) + '\n')
+  }
+
+  // Clean up the vhost changes.
+  var vhost_path = req.headers['x-couchdb-vhost-path']
+  if(vhost_path) {
+    req.url = vhost_path
+    delete req.headers['x-couchdb-vhost-path']
+  }
+
+  APPLICATION(req, res)
+}
+
+function auth(user, pass, callback) {
+  if(!COUCH)
+    return process.nextTick(function() { callback(new Error('No _couchdb_port')) })
+
+  var url = COUCH + '/_session'
+  if(user || pass) {
+    url = URL.parse(url)
+    url.auth = util.format('%s:%s', user || '', pass || '')
+    url = URL.format(url)
+  }
+
+  //couch.log('auth: %j', url)
+  request({'url':url, 'json':true}, function(er, res) {
+    //couch.log('auth result: %j', res.body)
+    if(er)
+      return callback(er)
+
+    if(res.statusCode != 200) {
+      er = new Error('Bad status '+res.statusCode+' for auth: ' + res.body)
+      er.statusCode = res.statusCode
+      er.body = JSON.stringify(res.body) + '\n'
+      er.headers = res.headers
+      return callback(er)
+    }
+
+    return callback(null, res.body.userCtx)
+  })
+}
+
+function auth_req(req, callback) {
+  var headers = req.headers || {}
+  var auth_str = req.headers.authorization || ''
+
+  var match = auth_str.match(/^Basic (.+)$/)
+  if(!match)
+    return auth(null, null, callback)
+
+  try {
+    auth_str = new Buffer(match[1], 'base64').toString()
+    match = auth_str.match(/^([^:]+):(.+)$/)
+  } catch (er) {
+    return callback(er)
+  }
+
+  if(!match)
+    return callback(new Error('Bad auth string: ' + auth_str))
+
+  auth(match[1], match[2], callback)
+}
+
+
+function publish(push) {
+  var script = __dirname + '/checkout.sh'
+  var repo = COUCH_DIR + '/' + push.repo
+
+  var id = Math.floor(Math.random() * 1000 * 1000)
+  var work = util.format('%s/%s/%s', COUCH_DIR, push.commit, id)
+
+  mkdirp(work, function(er) {
+    if(er) {
+      couch.error('Failed to make working dir: %s', work)
+      throw er
+    }
+
+    checkout()
+  })
+
+  function checkout() {
+    var args = [script, repo, push.commit]
+    var opts = { 'cwd':work, 'stdio':'pipe' }
+
+    var child = child_process.spawn('bash', args, opts)
+
+    var output = []
+
+    child.stdout.on('data', function(x) {
+      var msg = util.format('OUT %s', x.toString().trim())
+      couch.debug(msg)
+      output.push(msg)
+    })
+    child.stderr.on('data', function(x) {
+      var msg = util.format('ERR %s', x.toString().trim())
+      couch.debug(msg)
+      output.push(msg)
+    })
+
+    child.on('exit', function(code) {
+      if(code !== 0) {
+        couch.error('Bad checkout: %d', code)
+        output.forEach(function(line) {
+          couch.error(line)
+        })
+
+        throw new Error('Bad checkout')
+      }
+
+      couch.log('Checked out push: %s', work)
+      fs.readFile(work+'/package.json', 'utf8', function(er, body) {
+        if(er)
+          throw er
+
+        body = JSON.parse(body)
+        if(!body.couchdb)
+          return couch.warn('No "couchdb" value in pushed package.json')
+
+        run_app(work, body)
+      })
+    })
+  }
+}
+
+
+function run_app(work_dir, pkg) {
+  var vhosts = []
+    , main = null
+
+  if(typeof pkg.couchdb == 'string')
+    main = pkg.couchdb
+  else {
+    vhosts = pkg.couchdb.vhosts || []
+    main = pkg.couchdb.main
+  }
+
+  couch.log('Run app %s: %j', main, vhosts)
+
+  var mod_path = util.format('%s/%s', work_dir, main)
+  try {
+    var ok = require.resolve(mod_path)
+  } catch (er) {
+    return couch.error('Bad module path: %s', mod_path)
+  }
+
+  couch_mod = require(mod_path)
+  APPLICATION = couch_mod
+  couch.log('Installed CouchDB application')
+
+  return async.forEach(vhosts, set_vhost, vhosts_set)
+
+  function set_vhost(vhost, to_async) {
+    var couch_url = URL.parse(COUCH)
+    couch_url.auth = '_nodejs:' + COUCH_PASSWORD
+    couch_url = URL.format(couch_url)
+    couch.log('couch_url: %j', couch_url)
+
+    var url = couch_url + '_config/vhosts/' + vhost
+    var body = '/_nodejs'
+    request.put({'url':url, 'json':body}, function(er, res) {
+      if(er)
+        return to_async(er)
+      if(res.statusCode != 200)
+        return to_async(new Error('Bad response '+res.statusCode+' to vhost: ' + vhost))
+
+      couch.log('Set vhost: %s', vhost)
+      return to_async()
+    })
+  }
+
+  function vhosts_set(er) {
+    if(er)
+      throw er
+
+    couch.log('Set %d vhosts for CouchDB application', vhosts.length)
+  }
+}
+
+
+//
+// Utilities
+//
+
+function mk_couch_log(level) {
+  if(level == 'warn')
+    level = 'error'
+
+  return logger
+
+  function logger() {
+    var str = util.format.apply(util, arguments)
+    var msg = ['log', str, {'level':level}]
+    msg = JSON.stringify(msg)
+    process.stdout.write(msg + '\n')
+  }
+}
+
+
+if(require.main === module)
+  main()

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/inspector.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/inspector.js b/src/couchjs-node/inspector.js
new file mode 100755
index 0000000..efa9856
--- /dev/null
+++ b/src/couchjs-node/inspector.js
@@ -0,0 +1,92 @@
+#!/usr/bin/env node
+//
+// couchjs replacement
+//
+// Copyright 2011 Iris Couch
+//
+//    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.exports = start
+
+if(require.main === module)
+  main()
+
+
+var fs = require('fs')
+var util = require('util')
+var child_process = require('child_process')
+
+var log = require('./console').log
+
+function start(debugPort) {
+  if(!debugPort || typeof debugPort != 'number')
+    throw new Error('Need a listen debugPort')
+  var webPort = debugPort + 1
+
+  var cmd = __filename
+  var args = [debugPort, webPort]
+  var opts =
+    { 'cwd': __dirname
+    , 'stdio': 'pipe'
+    , 'detached': false
+    }
+
+  log('Start inspector: %s %j %j', cmd, args, opts)
+  var inspector = child_process.spawn(cmd, args, opts)
+  watch_inspector(inspector)
+
+  log('Enable remote debug pid=%d port=%d', process.pid, debugPort)
+  process.debugPort = debugPort
+  process.kill(process.pid, 'SIGUSR1')
+}
+
+function watch_inspector(child) {
+  child.stderr.on('data', function(body) {
+    log('Inspector STDERR: %s', body)
+  })
+  child.stdout.on('data', function(body) {
+    log('Inspector STDOUT: %s', body)
+  })
+
+  child.on('exit', function(code, signal) {
+    log('Inspector exited %d signal=%j', code, signal)
+    process.exit(code)
+  })
+
+  process.on('exit', function() {
+    log('Kill inspector upon exit: %d', child.pid)
+    process.kill(child.pid, 'SIGTERM')
+  })
+}
+
+
+function main() {
+  var debugPort = +process.argv[2]
+  var webPort = +process.argv[3]
+
+  if(!debugPort || !webPort)
+    throw new Error('Bad arguments: need debugPort and webPort')
+
+  console.log('Start inspector debugPort=%j webPort=%j', debugPort, webPort)
+  var DebugServer = require('node-inspector/lib/debug-server')
+  var server = new DebugServer
+  server.on('close', function() {
+    console.log('Server closed')
+    process.exit(0)
+  })
+
+  server.start({'webPort':webPort, 'debugPort':debugPort})
+  process.on('uncaughtException', function(er) {
+    console.log('Error:\n%s', er.stack)
+  })
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/package.json
----------------------------------------------------------------------
diff --git a/src/couchjs-node/package.json b/src/couchjs-node/package.json
new file mode 100644
index 0000000..665888c
--- /dev/null
+++ b/src/couchjs-node/package.json
@@ -0,0 +1,30 @@
+{ "name": "couchjs"
+, "description": "Drop-in replacement for CouchDB JavaScript view server"
+, "keywords": [ "couchdb", "couchjs" ]
+, "version": "0.3.2"
+, "author": "Jason Smith <jh...@iriscouch.com> (http://www.iriscouch.com)"
+, "repository": { "type":"git", "url":"https://github.com/iriscouch/couchjs" }
+
+, "engines": { "node": ">= 0.8" }
+, "main": "./couchjs.js"
+, "bin": {"couchjs-node":"./cli.js", "couchjs-extra":"./extra.js"}
+
+, "couchdb": { "main":"./couchdb.js"
+             , "vhosts": ["127.0.0.1.xip.io"]
+             }
+
+, "bundledDependencies": ["node-inspector"]
+
+, "dependencies": { "optimist": "~0.3.4"
+                  , "async"   : "~0.2.5"
+                  , "mkdirp"  : "~0.3.4"
+                  , "fibers"  : "~1.0.0"
+                  , "request" : "~2.9.203"
+                  , "pushover": "~1.2.1"
+                  , "defaultable": "~0.7.2"
+                  , "node-inspector": "git://github.com/iriscouch/node-inspector#couchjs"
+                  }
+
+, "devDependencies": { "tap": "~0.2.5"
+                     }
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/stream.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/stream.js b/src/couchjs-node/stream.js
new file mode 100644
index 0000000..90deda1
--- /dev/null
+++ b/src/couchjs-node/stream.js
@@ -0,0 +1,107 @@
+// Text line stream
+//
+// Copyright 2011 Iris Couch
+//
+//    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.exports = LineStream
+module.exports.v2 = LineStream2
+
+var stream = require('stream')
+var util = require('util')
+
+
+util.inherits(LineStream2, stream.Transform)
+function LineStream2 () {
+  if(! (this instanceof LineStream2))
+    return new LineStream2
+
+  stream.Transform.call(this)
+  this.setEncoding('utf8')
+}
+
+LineStream2.prototype._transform = function(message, encoding, done) {
+  var self = this
+
+  message = message.toString(encoding)
+  var lines = message.split(/\n/)
+
+  // If the data ends in "\n" this will be ""; otherwise the final partial line.
+  var remainder = lines.pop()
+  if(remainder)
+    this.unshift(remainder)
+
+  lines.forEach(function(line) {
+    self.push(line)
+  })
+
+  done()
+}
+
+util.inherits(LineStream, stream)
+function LineStream () {
+  var self = this
+  stream.call(self)
+
+  self.readable = true
+  self.writable = true
+
+  self.buffer = ''
+  self.downstream = null
+
+  self.on('pipe', function(upstream) {
+    upstream.on('end', function(data, encoding) {
+      self.emit('end', data, encoding)
+    })
+  })
+}
+
+
+LineStream.prototype.write = function(data, encoding) {
+  var self = this
+
+  data = data || ''
+  if(typeof data != 'string')
+    return self.error(new Error('Data was not a string: ' + util.inspect(data)))
+
+  self.buffer += data
+  var lines = self.buffer.split(/\n/)
+  self.buffer = lines.pop() // If the data ended in "\n" this will be ""; otherwise the final partial line.
+
+  lines.forEach(function(line) {
+    self.emit('data', line)
+  })
+}
+
+
+LineStream.prototype.end = function(data, encoding) {
+  var self = this
+
+  self.is_ending = true
+  self.writable = false
+
+  // Always call write, even with no data, so it can fire the "end" event.
+  self.write(data)
+}
+
+
+LineStream.prototype.error = function(er) {
+  var self = this
+
+  self.readable = false
+  self.writable = false
+  self.emit('error', er)
+
+  // The write() method sometimes returns this value, so if there was an error, make write() return false.
+  return false
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/test/experiment.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/test/experiment.js b/src/couchjs-node/test/experiment.js
new file mode 100644
index 0000000..54a5ab4
--- /dev/null
+++ b/src/couchjs-node/test/experiment.js
@@ -0,0 +1,105 @@
+var vm = require('vm')
+var util = require('util')
+
+var STATE = 'wait'
+  , v = 'vm'
+
+function main() {
+  process.debugPort = 5859
+  process.kill(process.pid, 'SIGUSR1')
+
+  setTimeout(function() { stuff(0) }, 1000)
+}
+
+function stuff(count) {
+  console.log('Doing stuff: %d', count)
+  //debugger
+  STATE = 'vm'
+  console.log('More stuff: %d', count)
+  if(STATE == 'done')
+    console.log('Done')
+  else if(STATE == 'code')
+    setTimeout(code, 1000)
+  else if(STATE == 'eval')
+    test_eval()
+  else if(STATE == 'vm')
+    test_vm()
+  else if(STATE == 'wait')
+    setTimeout(function() { stuff(count+1) }, 1000)
+  else
+    throw new Error('Unknown state: ' + STATE)
+}
+
+function code() {
+  var code =
+    [ 'var foo = "in the code"'
+    , 'console.log("This is some code")'
+    , 'debugger'
+    , 'console.log("foo = " + foo)'
+    ].join('\n')
+
+  var runner = Function([], code)
+  console.log('Run runner in 1s')
+  setTimeout(run_runner, 1000)
+
+  function run_runner() {
+    console.log('About to run runner')
+    debugger
+    runner()
+    console.log('Runner done')
+  }
+}
+
+function test_eval() {
+  console.log('Test eval in 1s')
+  setTimeout(run_eval, 1000)
+
+  var code =
+    [ 'var foo = "in eval"'
+    , 'console.log("This is eval")'
+    , 'debugger'
+    , 'console.log("foo = " + foo)'
+    ].join('\n')
+
+  function run_eval() {
+    console.log('Run eval now')
+    debugger
+    eval(code)
+  }
+}
+
+function test_vm() {
+  console.log('Test vm')
+
+  var code =
+    [ 'var i = 10'
+    , 'setTimeout(hello, 1000)'
+    , ''
+    , 'function hello() {'
+    , '  debugger'
+    , '  console.log("Hello: " + i)'
+    , '  if(--i)'
+    , '    setTimeout(hello, 1000)'
+    , '}'
+    ].join('\n')
+
+  console.log('Run vm now')
+  var filename = '_couchdb:code.js'
+
+  var sandbox = {}
+    , ok = ['console', 'setTimeout']
+
+  ok.forEach(function(key) {
+    sandbox[key] = global[key]
+  })
+
+  var ctx = vm.createContext(sandbox)
+  var script = vm.createScript(code, filename)
+
+  var r = script.runInNewContext(sandbox)
+  console.log('Result:\n%s', util.inspect(r, false, 10))
+  return r
+}
+
+if(require.main === module)
+  main()

http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc375701/src/couchjs-node/xml.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/xml.js b/src/couchjs-node/xml.js
new file mode 100644
index 0000000..c81525b
--- /dev/null
+++ b/src/couchjs-node/xml.js
@@ -0,0 +1,23 @@
+// Copyright 2011 Iris Couch
+//
+//    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.exports = XML
+
+function XML () {
+  this.foo = 'bar'
+}
+
+XML.prototype.toXMLString = function() {
+  return '<xml>\n  <title>test</title>\n</xml>'
+}


[32/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[31/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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;
 });


[46/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
remove user-facing docs from in-src README, point to docs


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: c547a7c3d9e206e45438a282b47f815cd5843955
Parents: 96d3847
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Sep 25 15:13:11 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/README.md | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c547a7c3/src/couchjs-node/README.md
----------------------------------------------------------------------
diff --git a/src/couchjs-node/README.md b/src/couchjs-node/README.md
index c686e80..551c3df 100644
--- a/src/couchjs-node/README.md
+++ b/src/couchjs-node/README.md
@@ -6,29 +6,7 @@ CouchJS is a command-line Node.js program. It is 100% compatible with Apache Cou
 
 By using CouchJS, you will get 100% CouchDB compatibility (the test suite completely passes) but your JavaScript environment is V8, or Node.js.
 
-CouchJS is available as an npm module.
-
-    $ npm install -g couchjs
-
-## Usage
-
-Install CouchDB. Install this package with npm. Confirm your `couchjs` install location.
-
-    $ which couchjs # Note, your path will be different from mine.
-    /home/jhs/node/bin/couchjs
-
-Look at the CouchDB config for the JavaScript query server.
-
-    $ curl http://localhost:5984/_config/query_servers/javascript
-    "/home/jhs/couchdb/bin/couchjs /home/jhs/couchdb/share/couchdb/server/main.js"
-
-Change that to this `couchjs`. **Leave the second argument the same.**
-
-    $ curl -X PUT http://localhost:5984/_config/query_servers/javascript \
-      -H content-type:application/json \
-      -d "\"`which couchjs` /home/jhs/couchdb/share/couchdb/server/main.js\""
-
-Done!
+See share/doc/src/experimental.rst for installation instructions.
 
 ## Idea
 


[23/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[06/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[16/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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" \


[35/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
rm license file, we have one in hte top level


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 93fd37bd4eb43d49e6b159620800e169b8399453
Parents: eebe8ae
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:15:13 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/LICENSE | 202 ------------------------------------------
 1 file changed, 202 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/93fd37bd/src/couchjs-node/LICENSE
----------------------------------------------------------------------
diff --git a/src/couchjs-node/LICENSE b/src/couchjs-node/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/src/couchjs-node/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   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.


[37/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
handle extras


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 8d0e74915d07786c38a3c1bd8a13bdda67a4b028
Parents: 93fd37b
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:16:13 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/checkout.sh |  36 ----
 src/couchjs-node/cli.js      |   6 -
 src/couchjs-node/extra.js    | 346 --------------------------------------
 3 files changed, 388 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/8d0e7491/src/couchjs-node/checkout.sh
----------------------------------------------------------------------
diff --git a/src/couchjs-node/checkout.sh b/src/couchjs-node/checkout.sh
deleted file mode 100644
index 0076b51..0000000
--- a/src/couchjs-node/checkout.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2011 Iris Couch
-#
-#    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.
-
-repo="$1"
-commit="$2"
-
-if [ -z "$repo" -o ! -d "$repo" ]; then
-  echo "Not a valid repo: $repo" >&2
-  exit 1
-fi
-if [ -z "$commit" ]; then
-  echo "Not a valid commit: $commit" >&2
-  exit 1
-fi
-
-echo "Clone $repo:$commit to $(pwd)"
-
-set -e
-
-git clone "$repo" .
-git checkout "$commit"
-
-if [ -z "$skip_npm_install" ]; then
-  npm install --production
-fi

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8d0e7491/src/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/cli.js b/src/couchjs-node/cli.js
index 14a6d97..a835cab 100755
--- a/src/couchjs-node/cli.js
+++ b/src/couchjs-node/cli.js
@@ -24,7 +24,6 @@ var child_process = require('child_process')
 
 var couchjs = require('./couchjs')
 var package_json = require('./package.json')
-var couchdb_extra = require('./extra')
 var LineStream = require('./stream')
 var inspector = require('./inspector')
 var log = require('./console').log
@@ -35,15 +34,10 @@ var opts = optimist.boolean(['h', 'V', 'H'])
                              , 'V': 'display version information and exit'
                              , 'H': 'enable couchjs cURL bindings (not implemented)'
                              })
-                   .boolean('extra')
-                   .describe('extra', 'Extra features for CouchDB, for os_daemons')
                    .usage('$0 <path to main.js>')
 
 
 function main() {
-  if(opts.argv.extra)
-    return couchdb_extra()
-
   var main_js = opts.argv._[0]
   if(!main_js)
     return console.error(opts.help())

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8d0e7491/src/couchjs-node/extra.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/extra.js b/src/couchjs-node/extra.js
deleted file mode 100755
index 2df0168..0000000
--- a/src/couchjs-node/extra.js
+++ /dev/null
@@ -1,346 +0,0 @@
-#!/usr/bin/env node
-// Copyright 2011 Iris Couch
-//
-//    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.exports = main
-
-var os = require('os')
-var fs = require('fs')
-var URL = require('url')
-var util = require('util')
-var http = require('http')
-var async = require('async')
-var mkdirp = require('mkdirp')
-var request = require('request')
-var optimist = require('optimist')
-var pushover = require('pushover')
-var child_process = require('child_process')
-
-var console = require('./console')
-var VER = require('./package.json').version
-
-var couch = { 'log': mk_couch_log('info')
-            , 'warn' : mk_couch_log('warn')
-            , 'error': mk_couch_log('error')
-            , 'debug': mk_couch_log('debug')
-            }
-
-
-var opts = optimist.usage('$0')
-
-var COUCH = null
-var GIT_DIR = null
-var COUCH_PASSWORD = null
-var GIT_PORT = null
-var APPLICATION = null
-
-function main() {
-  if(opts.argv.help)
-    return console.log(opts.help())
-
-  console.log('Extra CouchDB daemon: %s', process.pid)
-  couch.debug('CouchDB daemon %s: %s', VER, process.pid)
-
-  var env = {}
-  for (var k in process.env) {
-    var match = k.match(/^_couchdb_app_(.*)$/)
-    if(match)
-      env[match[1]] = process.env[k]
-  }
-
-  for (k in env)
-    couch.debug('  %s = %s', k, env[k])
-
-  if(env.port && env.password && env.couch && env.dir)
-    return git(env)
-
-  setInterval(function() {
-    console.log('Still here')
-    couch.log('Still in couch')
-  }, 60000)
-}
-
-function git(env) {
-  GIT_PORT = +env.port
-  COUCH = env.couch
-  COUCH_DIR = util.format('%s/couchjs-%s', env.dir, VER)
-  COUCH_PASSWORD = env.password
-
-  //var couch_url = util.format('http://_nodejs:%s@127.0.0.1:%d', password, couch_port)
-  //couch.log('couch url %j', couch_url)
-
-  auth('_nodejs', COUCH_PASSWORD, function(er, userCtx) {
-    if(er)
-      throw er
-
-    var roles = userCtx.roles || []
-    if(userCtx.name != '_nodejs' || !~roles.indexOf('_admin'))
-      throw new Error('Not admin: ' + JSON.stringify(res.body.userCtx))
-
-    var repos = pushover(COUCH_DIR)
-    repos.on('push', function(push) {
-      couch.log('Push %s/%s: %s', push.repo, push.commit, push.branch)
-      push.accept()
-      //couch.log('Response: %j', Object.keys(push.response))
-      push.response.on('finish', function() {
-        //couch.log('Finished!')
-        publish(push)
-      })
-    })
-
-    repos.on('fetch', function(fetch) {
-      couch.log('fetch %j', fetch.commit)
-      fetch.accept()
-    })
-
-    var server = http.createServer(function(req, res) {
-      if(! req.url.match(/^\/_nodejs\/_git(\/|$)/))
-        return handle_http(req, res)
-
-      req.pause()
-      auth_req(req, function(er, userCtx) {
-        if(er && er.statusCode) {
-          res.writeHead(er.statusCode, er.headers)
-          return res.end(er.body)
-        }
-
-        if(er) {
-          couch.log('Bad req %s: %s', req.url, er.message)
-          return res.end()
-        }
-
-        var roles = userCtx.roles || []
-        if(!~ roles.indexOf('_admin')) {
-          couch.log('Not admin: %s, %j', req.url, userCtx)
-          res.writeHead(401, 'Unauthorized', {'content-type':'application/json'})
-          return res.end('{"error":"not_authorized"}\n')
-        }
-
-        //couch.log('Handle Git: %j', req.url)
-        repos.handle(req, res)
-        req.resume()
-      })
-    })
-
-    server.listen(GIT_PORT)
-  })
-}
-
-function handle_http(req, res) {
-  if(! APPLICATION) {
-    var headers = { 'content-type': 'application/json'
-                  , 'server': 'NodeJS-CouchDB/'+VER
-                  }
-    res.writeHead(200, 'OK', headers)
-    var body = {'ok':true}
-    return res.end(JSON.stringify(body) + '\n')
-  }
-
-  // Clean up the vhost changes.
-  var vhost_path = req.headers['x-couchdb-vhost-path']
-  if(vhost_path) {
-    req.url = vhost_path
-    delete req.headers['x-couchdb-vhost-path']
-  }
-
-  APPLICATION(req, res)
-}
-
-function auth(user, pass, callback) {
-  if(!COUCH)
-    return process.nextTick(function() { callback(new Error('No _couchdb_port')) })
-
-  var url = COUCH + '/_session'
-  if(user || pass) {
-    url = URL.parse(url)
-    url.auth = util.format('%s:%s', user || '', pass || '')
-    url = URL.format(url)
-  }
-
-  //couch.log('auth: %j', url)
-  request({'url':url, 'json':true}, function(er, res) {
-    //couch.log('auth result: %j', res.body)
-    if(er)
-      return callback(er)
-
-    if(res.statusCode != 200) {
-      er = new Error('Bad status '+res.statusCode+' for auth: ' + res.body)
-      er.statusCode = res.statusCode
-      er.body = JSON.stringify(res.body) + '\n'
-      er.headers = res.headers
-      return callback(er)
-    }
-
-    return callback(null, res.body.userCtx)
-  })
-}
-
-function auth_req(req, callback) {
-  var headers = req.headers || {}
-  var auth_str = req.headers.authorization || ''
-
-  var match = auth_str.match(/^Basic (.+)$/)
-  if(!match)
-    return auth(null, null, callback)
-
-  try {
-    auth_str = new Buffer(match[1], 'base64').toString()
-    match = auth_str.match(/^([^:]+):(.+)$/)
-  } catch (er) {
-    return callback(er)
-  }
-
-  if(!match)
-    return callback(new Error('Bad auth string: ' + auth_str))
-
-  auth(match[1], match[2], callback)
-}
-
-
-function publish(push) {
-  var script = __dirname + '/checkout.sh'
-  var repo = COUCH_DIR + '/' + push.repo
-
-  var id = Math.floor(Math.random() * 1000 * 1000)
-  var work = util.format('%s/%s/%s', COUCH_DIR, push.commit, id)
-
-  mkdirp(work, function(er) {
-    if(er) {
-      couch.error('Failed to make working dir: %s', work)
-      throw er
-    }
-
-    checkout()
-  })
-
-  function checkout() {
-    var args = [script, repo, push.commit]
-    var opts = { 'cwd':work, 'stdio':'pipe' }
-
-    var child = child_process.spawn('bash', args, opts)
-
-    var output = []
-
-    child.stdout.on('data', function(x) {
-      var msg = util.format('OUT %s', x.toString().trim())
-      couch.debug(msg)
-      output.push(msg)
-    })
-    child.stderr.on('data', function(x) {
-      var msg = util.format('ERR %s', x.toString().trim())
-      couch.debug(msg)
-      output.push(msg)
-    })
-
-    child.on('exit', function(code) {
-      if(code !== 0) {
-        couch.error('Bad checkout: %d', code)
-        output.forEach(function(line) {
-          couch.error(line)
-        })
-
-        throw new Error('Bad checkout')
-      }
-
-      couch.log('Checked out push: %s', work)
-      fs.readFile(work+'/package.json', 'utf8', function(er, body) {
-        if(er)
-          throw er
-
-        body = JSON.parse(body)
-        if(!body.couchdb)
-          return couch.warn('No "couchdb" value in pushed package.json')
-
-        run_app(work, body)
-      })
-    })
-  }
-}
-
-
-function run_app(work_dir, pkg) {
-  var vhosts = []
-    , main = null
-
-  if(typeof pkg.couchdb == 'string')
-    main = pkg.couchdb
-  else {
-    vhosts = pkg.couchdb.vhosts || []
-    main = pkg.couchdb.main
-  }
-
-  couch.log('Run app %s: %j', main, vhosts)
-
-  var mod_path = util.format('%s/%s', work_dir, main)
-  try {
-    var ok = require.resolve(mod_path)
-  } catch (er) {
-    return couch.error('Bad module path: %s', mod_path)
-  }
-
-  couch_mod = require(mod_path)
-  APPLICATION = couch_mod
-  couch.log('Installed CouchDB application')
-
-  return async.forEach(vhosts, set_vhost, vhosts_set)
-
-  function set_vhost(vhost, to_async) {
-    var couch_url = URL.parse(COUCH)
-    couch_url.auth = '_nodejs:' + COUCH_PASSWORD
-    couch_url = URL.format(couch_url)
-    couch.log('couch_url: %j', couch_url)
-
-    var url = couch_url + '_config/vhosts/' + vhost
-    var body = '/_nodejs'
-    request.put({'url':url, 'json':body}, function(er, res) {
-      if(er)
-        return to_async(er)
-      if(res.statusCode != 200)
-        return to_async(new Error('Bad response '+res.statusCode+' to vhost: ' + vhost))
-
-      couch.log('Set vhost: %s', vhost)
-      return to_async()
-    })
-  }
-
-  function vhosts_set(er) {
-    if(er)
-      throw er
-
-    couch.log('Set %d vhosts for CouchDB application', vhosts.length)
-  }
-}
-
-
-//
-// Utilities
-//
-
-function mk_couch_log(level) {
-  if(level == 'warn')
-    level = 'error'
-
-  return logger
-
-  function logger() {
-    var str = util.format.apply(util, arguments)
-    var msg = ['log', str, {'level':level}]
-    msg = JSON.stringify(msg)
-    process.stdout.write(msg + '\n')
-  }
-}
-
-
-if(require.main === module)
-  main()


[50/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
remove unused module imports and improved module structure


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 532100c101387a3314a870264e58e7761c787c67
Parents: 447f101
Author: Sven Lito <me...@svenlito.com>
Authored: Thu Oct 3 16:34:06 2013 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:45:43 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/cli.js             |  2 -
 src/couchjs-node/console.js         |  2 +-
 src/couchjs-node/couchjs.js         | 18 +++++----
 src/couchjs-node/inspector.js       | 64 ++++++++++++++++----------------
 src/couchjs-node/stream.js          | 50 +++++++++++++------------
 src/couchjs-node/test/experiment.js |  1 -
 6 files changed, 69 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/532100c1/src/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/cli.js b/src/couchjs-node/cli.js
index 065951f..5447dd5 100755
--- a/src/couchjs-node/cli.js
+++ b/src/couchjs-node/cli.js
@@ -13,10 +13,8 @@
 // the License.
 
 var fs = require('fs');
-var util = require('util');
 var Fiber = require('fibers');
 var optimist = require('optimist');
-var child_process = require('child_process');
 
 var couchjs = require('./couchjs');
 var package_json = require('./package.json');

http://git-wip-us.apache.org/repos/asf/couchdb/blob/532100c1/src/couchjs-node/console.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/console.js b/src/couchjs-node/console.js
index 0fda066..18e7241 100644
--- a/src/couchjs-node/console.js
+++ b/src/couchjs-node/console.js
@@ -41,7 +41,7 @@ if (stat) {
   };
 
   var on_err = function (er) {
-    module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er))
+    module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er));
 
     if (er.stack) {
       er = ['fatal', 'unknown_error', er.stack];

http://git-wip-us.apache.org/repos/asf/couchdb/blob/532100c1/src/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchjs.js b/src/couchjs-node/couchjs.js
index 84c21e0..ccc1aa9 100644
--- a/src/couchjs-node/couchjs.js
+++ b/src/couchjs-node/couchjs.js
@@ -14,6 +14,7 @@
 
 var vm = require('vm');
 var Fiber = require('fibers');
+var util = require('util');
 
 var XML = require('./xml');
 var log = require('./console').log;
@@ -23,11 +24,6 @@ var INPUT = {
   'waiting':null
 };
 
-Error.prototype.toSource = Error.prototype.toSource || toSource;
-Error.prototype.toString = Error.prototype.toString || toSource;
-Function.prototype.toSource = Function.prototype.toSource || toSource;
-Function.prototype.toString = Function.prototype.toString || toSource;
-
 
 function print(line) {
   log('STDOUT %s: %s', process.pid, line);
@@ -71,9 +67,10 @@ function readline () {
 
 function evalcx (source, sandbox) {
   sandbox = sandbox || {};
+  var func;
   //log('evalcx in %j: %j', Object.keys(sandbox), source)
 
-  if (source == '') {
+  if (source === '') {
     return sandbox;
   }
 
@@ -87,7 +84,7 @@ function evalcx (source, sandbox) {
     var id = Math.floor(Math.random() * 1000*1000);
     var filename = '_couchdb:' + id + '.js';
     var script = vm.createScript(source, filename);
-    var func = script.runInNewContext(sandbox);
+    func = script.runInNewContext(sandbox);
   } catch (er) {
     log('Error making code: %s', er.stack);
     return sandbox;
@@ -109,7 +106,7 @@ function gc() { }
 
 
 function toSource() {
-  if (typeof this == 'function') {
+  if (typeof this === 'function') {
     return '' + this;
   }
 
@@ -120,6 +117,11 @@ function toSource() {
   return util.inspect(this);
 }
 
+Error.prototype.toSource = Error.prototype.toSource || toSource;
+Error.prototype.toString = Error.prototype.toString || toSource;
+Function.prototype.toSource = Function.prototype.toSource || toSource;
+Function.prototype.toString = Function.prototype.toString || toSource;
+
 module.exports = {
   'print': print,
   'readline': readline,

http://git-wip-us.apache.org/repos/asf/couchdb/blob/532100c1/src/couchjs-node/inspector.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/inspector.js b/src/couchjs-node/inspector.js
index 343770f..48182e5 100755
--- a/src/couchjs-node/inspector.js
+++ b/src/couchjs-node/inspector.js
@@ -12,18 +12,33 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-module.exports = start;
 
-if (require.main === module) {
-  main();
-}
 
-
-var fs = require('fs');
-var util = require('util');
-var child_process = require('child_process');
+var cp = require('child_process');
 var log = require('./console').log;
 
+function watchInspector(child) {
+
+  child.stderr.on('data', function(body) {
+    log('Inspector STDERR: %s', body);
+  });
+
+  child.stdout.on('data', function(body) {
+    log('Inspector STDOUT: %s', body);
+  });
+
+  child.on('exit', function(code, signal) {
+    log('Inspector exited %d signal=%j', code, signal);
+    process.exit(code);
+  });
+
+  process.on('exit', function() {
+    log('Kill inspector upon exit: %d', child.pid);
+    process.kill(child.pid, 'SIGTERM');
+  });
+
+}
+
 function start (debugPort) {
 
   if (!debugPort || typeof debugPort !== 'number') {
@@ -31,7 +46,6 @@ function start (debugPort) {
   }
 
   var webPort = debugPort + 1;
-
   var cmd = __filename;
   var args = [debugPort, webPort];
   var opts = {
@@ -42,9 +56,9 @@ function start (debugPort) {
 
   log('Start inspector: %s %j %j', cmd, args, opts);
 
-  var inspector = child_process.spawn(cmd, args, opts);
+  var inspector = cp.spawn(cmd, args, opts);
 
-  watch_inspector(inspector);
+  watchInspector(inspector);
 
   log('Enable remote debug pid=%d port=%d', process.pid, debugPort);
 
@@ -52,28 +66,6 @@ function start (debugPort) {
   process.kill(process.pid, 'SIGUSR1');
 }
 
-function watch_inspector(child) {
-
-  child.stderr.on('data', function(body) {
-    log('Inspector STDERR: %s', body);
-  });
-
-  child.stdout.on('data', function(body) {
-    log('Inspector STDOUT: %s', body);
-  });
-
-  child.on('exit', function(code, signal) {
-    log('Inspector exited %d signal=%j', code, signal);
-    process.exit(code);
-  });
-
-  process.on('exit', function() {
-    log('Kill inspector upon exit: %d', child.pid);
-    process.kill(child.pid, 'SIGTERM');
-  });
-
-}
-
 function main() {
   var debugPort = +process.argv[2];
   var webPort = +process.argv[3];
@@ -101,3 +93,9 @@ function main() {
     console.log('Error:\n%s', er.stack);
   });
 }
+
+module.exports = start;
+
+if (require.main === module) {
+  main();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/532100c1/src/couchjs-node/stream.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/stream.js b/src/couchjs-node/stream.js
index d0c192c..ebffc30 100644
--- a/src/couchjs-node/stream.js
+++ b/src/couchjs-node/stream.js
@@ -12,16 +12,29 @@
 
 // Text line stream
 
-module.exports = LineStream;
-module.exports.v2 = LineStream2;
-
 var stream = require('stream');
 var util = require('util');
 
 
-util.inherits(LineStream2, stream.Transform);
+function LineStream() {
 
-function LineStream2 () {
+  var self = this;
+  stream.call(self);
+
+  self.readable = true;
+  self.writable = true;
+
+  self.buffer = '';
+  self.downstream = null;
+
+  self.on('pipe', function(upstream) {
+    upstream.on('end', function(data, encoding) {
+      self.emit('end', data, encoding);
+    });
+  });
+}
+
+function LineStream2() {
 
   if (!(this instanceof LineStream2)) {
     return new LineStream2();
@@ -31,6 +44,8 @@ function LineStream2 () {
   this.setEncoding('utf8');
 }
 
+util.inherits(LineStream2, stream.Transform);
+
 LineStream2.prototype._transform = function(message, encoding, done) {
   var self = this;
 
@@ -52,25 +67,9 @@ LineStream2.prototype._transform = function(message, encoding, done) {
 
 util.inherits(LineStream, stream);
 
-function LineStream () {
-  var self = this;
-  stream.call(self);
 
-  self.readable = true;
-  self.writable = true;
 
-  self.buffer = '';
-  self.downstream = null;
-
-  self.on('pipe', function(upstream) {
-    upstream.on('end', function(data, encoding) {
-      self.emit('end', data, encoding);
-    });
-  });
-}
-
-
-LineStream.prototype.write = function(data, encoding) {
+LineStream.prototype.write = function(data) {
   var self = this;
 
   data = data || '';
@@ -88,7 +87,7 @@ LineStream.prototype.write = function(data, encoding) {
 };
 
 
-LineStream.prototype.end = function(data, encoding) {
+LineStream.prototype.end = function(data) {
   var self = this;
 
   self.is_ending = true;
@@ -109,3 +108,8 @@ LineStream.prototype.error = function(er) {
   // The write() method sometimes returns this value, so if there was an error, make write() return false.
   return false;
 };
+
+
+module.exports = LineStream;
+module.exports.v2 = LineStream2;
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/532100c1/src/couchjs-node/test/experiment.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/test/experiment.js b/src/couchjs-node/test/experiment.js
index fedf6d0..9197ec6 100644
--- a/src/couchjs-node/test/experiment.js
+++ b/src/couchjs-node/test/experiment.js
@@ -14,7 +14,6 @@ var vm = require('vm');
 var util = require('util');
 
 var STATE = 'wait';
-var v = 'vm';
 
 function main() {
   process.debugPort = 5859;


[28/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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>


[14/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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()}.


[20/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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) ->


[36/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/0595c5e9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0595c5e9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0595c5e9

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 0595c5e966a8f20a407683118263d6dc9d52a075
Parents: 8d0e749
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:22:47 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/cli.js             | 24 ++++++++++--------------
 src/couchjs-node/console.js         | 20 +++++++++-----------
 src/couchjs-node/couchdb.js         | 20 +++++++++-----------
 src/couchjs-node/couchjs.js         | 20 +++++++++-----------
 src/couchjs-node/inspector.js       | 24 ++++++++++--------------
 src/couchjs-node/stream.js          | 24 +++++++++++-------------
 src/couchjs-node/test/experiment.js | 12 ++++++++++++
 src/couchjs-node/xml.js             | 20 +++++++++-----------
 8 files changed, 79 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/cli.js b/src/couchjs-node/cli.js
index a835cab..8b7abef 100755
--- a/src/couchjs-node/cli.js
+++ b/src/couchjs-node/cli.js
@@ -1,20 +1,16 @@
 #!/usr/bin/env node
+
+// 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
 //
-// couchjs replacement
-//
-// Copyright 2011 Iris Couch
-//
-//    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
+//   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.
+// 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.
 
 var fs = require('fs')
 var util = require('util')

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/console.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/console.js b/src/couchjs-node/console.js
index 2a0a17a..67cc32d 100644
--- a/src/couchjs-node/console.js
+++ b/src/couchjs-node/console.js
@@ -1,16 +1,14 @@
-// Copyright 2011 Iris Couch
+// 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
 //
-//    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
 //
-//        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.
+// 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.
 
 var fs = require('fs')
 var util = require('util')

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/couchdb.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchdb.js b/src/couchjs-node/couchdb.js
index d297112..46b23b0 100755
--- a/src/couchjs-node/couchdb.js
+++ b/src/couchjs-node/couchdb.js
@@ -1,16 +1,14 @@
-// Copyright 2011 Iris Couch
+// 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
 //
-//    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
 //
-//        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.
+// 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.exports = handler
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchjs.js b/src/couchjs-node/couchjs.js
index d95341d..b633f6f 100644
--- a/src/couchjs-node/couchjs.js
+++ b/src/couchjs-node/couchjs.js
@@ -1,16 +1,14 @@
-// Copyright 2011 Iris Couch
+// 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
 //
-//    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
 //
-//        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.
+// 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.exports = { 'print'   : print
                  , 'readline': readline

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/inspector.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/inspector.js b/src/couchjs-node/inspector.js
index efa9856..2b75c3b 100755
--- a/src/couchjs-node/inspector.js
+++ b/src/couchjs-node/inspector.js
@@ -1,20 +1,16 @@
 #!/usr/bin/env node
+
+// 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
 //
-// couchjs replacement
-//
-// Copyright 2011 Iris Couch
-//
-//    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
+//   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.
+// 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.exports = start
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/stream.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/stream.js b/src/couchjs-node/stream.js
index 90deda1..ad6bcab 100644
--- a/src/couchjs-node/stream.js
+++ b/src/couchjs-node/stream.js
@@ -1,18 +1,16 @@
-// Text line stream
-//
-// Copyright 2011 Iris Couch
-//
-//    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
+// 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
+//   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.
+// 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.
+
+// Text line stream
 
 module.exports = LineStream
 module.exports.v2 = LineStream2

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/test/experiment.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/test/experiment.js b/src/couchjs-node/test/experiment.js
index 54a5ab4..094ac1d 100644
--- a/src/couchjs-node/test/experiment.js
+++ b/src/couchjs-node/test/experiment.js
@@ -1,3 +1,15 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
 var vm = require('vm')
 var util = require('util')
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0595c5e9/src/couchjs-node/xml.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/xml.js b/src/couchjs-node/xml.js
index c81525b..efd3a8f 100644
--- a/src/couchjs-node/xml.js
+++ b/src/couchjs-node/xml.js
@@ -1,16 +1,14 @@
-// Copyright 2011 Iris Couch
+// 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
 //
-//    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
 //
-//        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.
+// 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.exports = XML
 


[47/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
move config to local.ini


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: ea6fe1886172562ad1d42d625c410bdaf9d14947
Parents: ccf9309
Author: Jan Lehnardt <ja...@apache.org>
Authored: Tue Sep 24 17:01:12 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 etc/couchdb/default.ini.tpl.in | 1 -
 etc/couchdb/local.ini          | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/ea6fe188/etc/couchdb/default.ini.tpl.in
----------------------------------------------------------------------
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 981bbb1..3267001 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -123,7 +123,6 @@ use_users_db = false
 [query_servers]
 javascript = %bindir%/%couchjs_command_name% %localbuilddatadir%/server/main.js
 coffeescript = %bindir%/%couchjs_command_name% %localbuilddatadir%/server/main-coffee.js
-nodejs = /usr/local/bin/couchjs-node %localbuilddatadir%/server/main.js
 
 
 ; Changing reduce_limit to false will disable reduce_limit.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/ea6fe188/etc/couchdb/local.ini
----------------------------------------------------------------------
diff --git a/etc/couchdb/local.ini b/etc/couchdb/local.ini
index a5db26f..8aae331 100644
--- a/etc/couchdb/local.ini
+++ b/etc/couchdb/local.ini
@@ -25,6 +25,10 @@
 ; the whitelist.
 ;config_whitelist = [{httpd,config_whitelist}, {log,level}, {etc,etc}]
 
+[query_servers]
+;nodejs = /usr/local/bin/couchjs-node /path/to/couchdb/share/server/main.js
+
+
 [httpd_global_handlers]
 ;_google = {couch_httpd_proxy, handle_proxy_req, <<"http://www.google.com">>}
 


[11/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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).


[44/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
Add 'html/experimental.html' to 'Makefile.am'


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 2d7da550c90af5e9adb543ca43bcc32ad72d8c4d
Parents: c547a7c
Author: Klaus Trainer <kl...@posteo.de>
Authored: Wed Sep 25 16:40:16 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 share/doc/build/Makefile.am | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/2d7da550/share/doc/build/Makefile.am
----------------------------------------------------------------------
diff --git a/share/doc/build/Makefile.am b/share/doc/build/Makefile.am
index 1b69ef6..78558f4 100644
--- a/share/doc/build/Makefile.am
+++ b/share/doc/build/Makefile.am
@@ -264,6 +264,7 @@ html_files = \
     html/config-ref.html \
     html/contents.html \
     html/externals.html \
+    html/experimental.html \
     html/json-structure.html \
     html/objects.inv \
     html/http-api.html \


[29/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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" }


[30/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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
--- 
+--


[13/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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(


[41/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
remove last extra reference


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 868c2614f56c88be155d83fc82a0698dee14ac0d
Parents: ba6bdae
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:35:08 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:30 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/868c2614/src/couchjs-node/package.json
----------------------------------------------------------------------
diff --git a/src/couchjs-node/package.json b/src/couchjs-node/package.json
index 665888c..5e8ade0 100644
--- a/src/couchjs-node/package.json
+++ b/src/couchjs-node/package.json
@@ -7,7 +7,7 @@
 
 , "engines": { "node": ">= 0.8" }
 , "main": "./couchjs.js"
-, "bin": {"couchjs-node":"./cli.js", "couchjs-extra":"./extra.js"}
+, "bin": {"couchjs-node":"./cli.js"}
 
 , "couchdb": { "main":"./couchdb.js"
              , "vhosts": ["127.0.0.1.xip.io"]


[12/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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');


[18/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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


[48/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
applied formatting for constancy


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 0902e8c5e8f7e66eecfacbdb266422d51f8cafc3
Parents: 2d7da55
Author: Sven Lito <me...@svenlito.com>
Authored: Thu Oct 3 09:23:07 2013 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:45:38 2013 +0200

----------------------------------------------------------------------
 src/couchjs-node/cli.js             |  96 +++++++++++--------
 src/couchjs-node/console.js         |  73 +++++++-------
 src/couchjs-node/couchdb.js         |  20 ++--
 src/couchjs-node/couchjs.js         | 133 ++++++++++++++------------
 src/couchjs-node/inspector.js       | 111 +++++++++++----------
 src/couchjs-node/package.json       |  68 +++++++------
 src/couchjs-node/sandbox.js         |  23 +++--
 src/couchjs-node/stream.js          | 106 +++++++++++----------
 src/couchjs-node/test/experiment.js | 159 ++++++++++++++++---------------
 src/couchjs-node/xml.js             |   9 +-
 10 files changed, 441 insertions(+), 357 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/cli.js b/src/couchjs-node/cli.js
index 8b7abef..065951f 100755
--- a/src/couchjs-node/cli.js
+++ b/src/couchjs-node/cli.js
@@ -12,64 +12,80 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-var fs = require('fs')
-var util = require('util')
-var Fiber = require('fibers')
-var optimist = require('optimist')
-var child_process = require('child_process')
+var fs = require('fs');
+var util = require('util');
+var Fiber = require('fibers');
+var optimist = require('optimist');
+var child_process = require('child_process');
 
-var couchjs = require('./couchjs')
-var package_json = require('./package.json')
-var LineStream = require('./stream')
-var inspector = require('./inspector')
-var log = require('./console').log
+var couchjs = require('./couchjs');
+var package_json = require('./package.json');
+var LineStream = require('./stream');
+var inspector = require('./inspector');
+var log = require('./console').log;
 
 
 var opts = optimist.boolean(['h', 'V', 'H'])
-                   .describe({ 'h': 'display a short help message and exit'
-                             , 'V': 'display version information and exit'
-                             , 'H': 'enable couchjs cURL bindings (not implemented)'
+                   .describe({ 'h': 'display a short help message and exit',
+                             'V': 'display version information and exit',
+                             'H': 'enable couchjs cURL bindings (not implemented)'
                              })
-                   .usage('$0 <path to main.js>')
+                   .usage('$0 <path to main.js>');
 
 
 function main() {
-  var main_js = opts.argv._[0]
-  if(!main_js)
-    return console.error(opts.help())
 
-  log('couchjs/%s %s: %s', package_json.version, process.pid, main_js)
-  if(process.env.COUCHJS_DEBUG_PORT)
-    inspector(+process.env.COUCHJS_DEBUG_PORT)
+  'use strict';
+
+  var main_js = opts.argv._[0];
+
+  if (!main_js) {
+    return console.error(opts.help());
+  }
+
+  log('couchjs/%s %s: %s', package_json.version, process.pid, main_js);
+
+  if (process.env.COUCHJS_DEBUG_PORT) {
+    inspector(+process.env.COUCHJS_DEBUG_PORT);
+  }
 
   fs.readFile(main_js, 'utf8', function(er, body) {
-    if(er)
-      throw er
+    if (er) {
+      throw er;
+    }
+
+    var stdin = new LineStream.v2();
 
-    var stdin = new LineStream.v2
     stdin.on('readable', function() {
-      var buf = stdin.read()
-      if(buf)
-        couchjs.stdin(buf)
-    })
+      var buf = stdin.read();
+
+      if (buf) {
+        couchjs.stdin(buf);
+      }
+    });
+
     stdin.on('end', function() {
-      log('Terminate; connection to parent closed')
-      process.exit(0)
-    })
+      log('Terminate; connection to parent closed');
+      process.exit(0);
+    });
 
-    process.stdin.setEncoding('utf8')
-    process.stdin.pipe(stdin)
+    process.stdin.setEncoding('utf8');
+    process.stdin.pipe(stdin);
 
-    var main_func = Function(['print', 'readline', 'evalcx', 'gc', 'quit'], body)
+    var main_func = Function(['print', 'readline', 'evalcx', 'gc', 'quit'], body);
 
-    log('Call main')
-    Fiber(function() { main_func(couchjs.print, couchjs.readline, couchjs.evalcx, couchjs.gc) }).run()
-  })
+    log('Call main');
+
+    new Fiber(function() {
+      main_func(couchjs.print, couchjs.readline, couchjs.evalcx, couchjs.gc);
+    }).run();
+  });
 
   process.on('uncaughtException', function(er) {
-    log('Error:\n%s', er.stack)
-  })
+    log('Error:\n%s', er.stack);
+  });
 }
 
-if(require.main === module)
-  main()
+if (require.main === module) {
+  main();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/console.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/console.js b/src/couchjs-node/console.js
index 67cc32d..0fda066 100644
--- a/src/couchjs-node/console.js
+++ b/src/couchjs-node/console.js
@@ -10,54 +10,57 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-var fs = require('fs')
-var util = require('util')
+var fs = require('fs');
+var util = require('util');
 
+var noop = function() {};
 
-module.exports = {}
-module.exports.log = noop
-module.exports.debug = noop
-module.exports.info = noop
-module.exports.warn = noop
-module.exports.error = noop
+module.exports = {};
+module.exports.log = noop;
+module.exports.debug = noop;
+module.exports.info = noop;
+module.exports.warn = noop;
+module.exports.error = noop;
 
-var LOG_PATH = '/tmp/couchjs.log'
-  , stat = null
-  , LOG = null
+var LOG_PATH = '/tmp/couchjs.log';
+var stat = null;
+var LOG = null;
 
 try {
-  stat = fs.statSync(LOG_PATH)
+  stat = fs.statSync(LOG_PATH);
 } catch(er) {}
 
-if(stat) {
-  LOG = fs.createWriteStream(LOG_PATH, {'flags':'a'})
+if (stat) {
+  LOG = fs.createWriteStream(LOG_PATH, {
+    'flags':'a'
+  });
 
-  module.exports.log = log
-  module.exports.debug = log
-  module.exports.info = log
-  module.exports.warn = log
-  module.exports.error = log
+  var log = function () {
+    var str = util.format.apply(this, arguments);
+    LOG.write(str + '\n');
+  };
 
-  process.on('exit', function() {
-    module.exports.log('Exit %d', process.pid)
-  })
+  var on_err = function (er) {
+    module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er))
 
-  process.on('uncaughtException', on_err)
-}
+    if (er.stack) {
+      er = ['fatal', 'unknown_error', er.stack];
+    }
 
-function log() {
-  var str = util.format.apply(this, arguments)
-  LOG.write(str + '\n')
-}
+    process.stdout.write(JSON.stringify(er) + '\n');
+    process.exit(1);
+  };
 
-function on_err(er) {
-  module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er))
+  module.exports.log = log;
+  module.exports.debug = log;
+  module.exports.info = log;
+  module.exports.warn = log;
+  module.exports.error = log;
 
-  if(er.stack)
-    er = ['fatal', 'unknown_error', er.stack]
+  process.on('exit', function() {
+    module.exports.log('Exit %d', process.pid);
+  });
 
-  process.stdout.write(JSON.stringify(er) + '\n')
-  process.exit(1)
+  process.on('uncaughtException', on_err);
 }
 
-function noop() {}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/couchdb.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchdb.js b/src/couchjs-node/couchdb.js
index 46b23b0..d420540 100755
--- a/src/couchjs-node/couchdb.js
+++ b/src/couchjs-node/couchdb.js
@@ -10,18 +10,20 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-module.exports = handler
 
-var http = require('http')
+var http = require('http');
 
 function handler(req, res) {
-  res.writeHead(200)
-  res.end('Hello: ' + req.url + '\n')
+  res.writeHead(200);
+  res.end('Hello: ' + req.url + '\n');
 }
 
-if(require.main === module) {
-  var http = require('http')
-  var server = http.createServer(handler)
-  server.listen(3000)
-  console.log('Listening on :3000')
+if (require.main === module) {
+  var http = require('http');
+  var server = http.createServer(handler);
+
+  server.listen(3000);
+  console.log('Listening on :3000');
 }
+
+module.exports = handler;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchjs.js b/src/couchjs-node/couchjs.js
index b633f6f..7b12dc3 100644
--- a/src/couchjs-node/couchjs.js
+++ b/src/couchjs-node/couchjs.js
@@ -10,105 +10,120 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-module.exports = { 'print'   : print
-                 , 'readline': readline
-                 , 'stdin'   : stdin
-                 , 'evalcx'  : evalcx
-                 , 'quit'    : quit
-                 , 'gc'      : gc
-                 }
+module.exports = {
+  'print': print,
+  'readline': readline,
+  'stdin': stdin,
+  'evalcx': evalcx,
+  'quit': quit,
+  'gc': gc
+};
 
 
-var vm = require('vm')
-var Fiber = require('fibers')
+var vm = require('vm');
+var Fiber = require('fibers');
 
-var XML = require('./xml')
-var log = require('./console').log
+var XML = require('./xml');
+var log = require('./console').log;
 
-var INPUT = {'queue':[], 'waiting':null}
+var INPUT = {
+  'queue':[],
+  'waiting':null
+};
 
-Error.prototype.toSource = Error.prototype.toSource || toSource
-Error.prototype.toString = Error.prototype.toString || toSource
-Function.prototype.toSource = Function.prototype.toSource || toSource
-Function.prototype.toString = Function.prototype.toString || toSource
+Error.prototype.toSource = Error.prototype.toSource || toSource;
+Error.prototype.toString = Error.prototype.toString || toSource;
+Function.prototype.toSource = Function.prototype.toSource || toSource;
+Function.prototype.toString = Function.prototype.toString || toSource;
 
 
 function print(line) {
-  log('STDOUT %s: %s', process.pid, line)
-  process.stdout.write(line + '\n')
+  log('STDOUT %s: %s', process.pid, line);
+  process.stdout.write(line + '\n');
 
   try {
-    line = JSON.parse(line)
-  } catch(er) { return }
+    line = JSON.parse(line);
+  } catch(er) {
+    return;
+  }
 
-  if(line[0] == 'log')
-    log('LOG: %s', line[1])
+  if (line[0] === 'log') {
+    log('LOG: %s', line[1]);
+  }
 }
 
-function stdin(line) {
-  log('STDIN %s: %s', process.pid, line.trim())
-  if(INPUT.waiting)
-    INPUT.waiting.run(line)
-  else
-    INPUT.queue.push(line)
+function stdin (line) {
+  log('STDIN %s: %s', process.pid, line.trim());
+
+  if (INPUT.waiting) {
+    INPUT.waiting.run(line);
+  } else {
+    INPUT.queue.push(line);
+  }
 }
 
-function readline() {
-  var line = INPUT.queue.shift()
-  if(line)
-    return line
+function readline () {
+  var line = INPUT.queue.shift();
+
+  if (line) {
+    return line;
+  }
 
-  INPUT.waiting = Fiber.current
-  line = Fiber.yield()
-  INPUT.waiting = null
+  INPUT.waiting = Fiber.current;
+  line = Fiber.yield();
+  INPUT.waiting = null;
 
-  return line
+  return line;
 }
 
 
-function evalcx(source, sandbox) {
-  sandbox = sandbox || {}
+function evalcx (source, sandbox) {
+  sandbox = sandbox || {};
   //log('evalcx in %j: %j', Object.keys(sandbox), source)
 
-  if(source == '')
-    return sandbox
+  if (source == '') {
+    return sandbox;
+  }
 
   // source might be "function(doc) { emit(doc._id, 1) }"
-  source = source.replace(/;+$/, '')
+  source = source.replace(/;+$/, '');
 
-  sandbox.XML = sandbox.XML || XML
-  source = '(' + source + ')'
+  sandbox.XML = sandbox.XML || XML;
+  source = '(' + source + ')';
 
   try {
-    var id = Math.floor(Math.random() * 1000*1000)
-    var filename = '_couchdb:' + id + '.js'
-    var script = vm.createScript(source, filename)
-    var func = script.runInNewContext(sandbox)
+    var id = Math.floor(Math.random() * 1000*1000);
+    var filename = '_couchdb:' + id + '.js';
+    var script = vm.createScript(source, filename);
+    var func = script.runInNewContext(sandbox);
   } catch (er) {
-    log('Error making code: %s', er.stack)
-    return sandbox
+    log('Error making code: %s', er.stack);
+    return sandbox;
   }
 
-  return func
+  return func;
 }
 
 function quit(code) {
-  code = code || 1
-  if(code < 0)
-    code = -code
+  code = code || 1;
+  if (code < 0) {
+    code = -code;
+  }
 
-  process.exit(code)
+  process.exit(code);
 }
 
 function gc() { }
 
 
 function toSource() {
-  if(typeof this == 'function')
-    return '' + this
+  if (typeof this == 'function') {
+    return '' + this;
+  }
 
-  if(this instanceof Error)
-    return this.stack
+  if (this instanceof Error) {
+    return this.stack;
+  }
 
-  return util.inspect(this)
+  return util.inspect(this);
 }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/inspector.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/inspector.js b/src/couchjs-node/inspector.js
index 2b75c3b..343770f 100755
--- a/src/couchjs-node/inspector.js
+++ b/src/couchjs-node/inspector.js
@@ -12,77 +12,92 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-module.exports = start
+module.exports = start;
 
-if(require.main === module)
-  main()
+if (require.main === module) {
+  main();
+}
+
+
+var fs = require('fs');
+var util = require('util');
+var child_process = require('child_process');
+var log = require('./console').log;
 
+function start (debugPort) {
 
-var fs = require('fs')
-var util = require('util')
-var child_process = require('child_process')
+  if (!debugPort || typeof debugPort !== 'number') {
+    throw new Error('Need a listen debugPort');
+  }
 
-var log = require('./console').log
+  var webPort = debugPort + 1;
 
-function start(debugPort) {
-  if(!debugPort || typeof debugPort != 'number')
-    throw new Error('Need a listen debugPort')
-  var webPort = debugPort + 1
+  var cmd = __filename;
+  var args = [debugPort, webPort];
+  var opts = {
+    'cwd': __dirname,
+    'stdio': 'pipe',
+    'detached': false
+  };
 
-  var cmd = __filename
-  var args = [debugPort, webPort]
-  var opts =
-    { 'cwd': __dirname
-    , 'stdio': 'pipe'
-    , 'detached': false
-    }
+  log('Start inspector: %s %j %j', cmd, args, opts);
 
-  log('Start inspector: %s %j %j', cmd, args, opts)
-  var inspector = child_process.spawn(cmd, args, opts)
-  watch_inspector(inspector)
+  var inspector = child_process.spawn(cmd, args, opts);
 
-  log('Enable remote debug pid=%d port=%d', process.pid, debugPort)
-  process.debugPort = debugPort
-  process.kill(process.pid, 'SIGUSR1')
+  watch_inspector(inspector);
+
+  log('Enable remote debug pid=%d port=%d', process.pid, debugPort);
+
+  process.debugPort = debugPort;
+  process.kill(process.pid, 'SIGUSR1');
 }
 
 function watch_inspector(child) {
+
   child.stderr.on('data', function(body) {
-    log('Inspector STDERR: %s', body)
-  })
+    log('Inspector STDERR: %s', body);
+  });
+
   child.stdout.on('data', function(body) {
-    log('Inspector STDOUT: %s', body)
-  })
+    log('Inspector STDOUT: %s', body);
+  });
 
   child.on('exit', function(code, signal) {
-    log('Inspector exited %d signal=%j', code, signal)
-    process.exit(code)
-  })
+    log('Inspector exited %d signal=%j', code, signal);
+    process.exit(code);
+  });
 
   process.on('exit', function() {
-    log('Kill inspector upon exit: %d', child.pid)
-    process.kill(child.pid, 'SIGTERM')
-  })
-}
+    log('Kill inspector upon exit: %d', child.pid);
+    process.kill(child.pid, 'SIGTERM');
+  });
 
+}
 
 function main() {
-  var debugPort = +process.argv[2]
-  var webPort = +process.argv[3]
+  var debugPort = +process.argv[2];
+  var webPort = +process.argv[3];
 
-  if(!debugPort || !webPort)
-    throw new Error('Bad arguments: need debugPort and webPort')
+  if (!debugPort || !webPort) {
+    throw new Error('Bad arguments: need debugPort and webPort');
+  }
+
+  console.log('Start inspector debugPort=%j webPort=%j', debugPort, webPort);
+
+  var DebugServer = require('node-inspector/lib/debug-server');
+  var server = new DebugServer();
 
-  console.log('Start inspector debugPort=%j webPort=%j', debugPort, webPort)
-  var DebugServer = require('node-inspector/lib/debug-server')
-  var server = new DebugServer
   server.on('close', function() {
-    console.log('Server closed')
-    process.exit(0)
-  })
+    console.log('Server closed');
+    process.exit(0);
+  });
+
+  server.start({
+    'webPort':webPort,
+    'debugPort':debugPort
+  });
 
-  server.start({'webPort':webPort, 'debugPort':debugPort})
   process.on('uncaughtException', function(er) {
-    console.log('Error:\n%s', er.stack)
-  })
+    console.log('Error:\n%s', er.stack);
+  });
 }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/package.json
----------------------------------------------------------------------
diff --git a/src/couchjs-node/package.json b/src/couchjs-node/package.json
index 5e8ade0..445f3b9 100644
--- a/src/couchjs-node/package.json
+++ b/src/couchjs-node/package.json
@@ -1,30 +1,40 @@
-{ "name": "couchjs"
-, "description": "Drop-in replacement for CouchDB JavaScript view server"
-, "keywords": [ "couchdb", "couchjs" ]
-, "version": "0.3.2"
-, "author": "Jason Smith <jh...@iriscouch.com> (http://www.iriscouch.com)"
-, "repository": { "type":"git", "url":"https://github.com/iriscouch/couchjs" }
-
-, "engines": { "node": ">= 0.8" }
-, "main": "./couchjs.js"
-, "bin": {"couchjs-node":"./cli.js"}
-
-, "couchdb": { "main":"./couchdb.js"
-             , "vhosts": ["127.0.0.1.xip.io"]
-             }
-
-, "bundledDependencies": ["node-inspector"]
-
-, "dependencies": { "optimist": "~0.3.4"
-                  , "async"   : "~0.2.5"
-                  , "mkdirp"  : "~0.3.4"
-                  , "fibers"  : "~1.0.0"
-                  , "request" : "~2.9.203"
-                  , "pushover": "~1.2.1"
-                  , "defaultable": "~0.7.2"
-                  , "node-inspector": "git://github.com/iriscouch/node-inspector#couchjs"
-                  }
-
-, "devDependencies": { "tap": "~0.2.5"
-                     }
+{
+  "name": "couchjs",
+  "description": "Drop-in replacement for CouchDB JavaScript view server",
+  "keywords": [ "couchdb", "couchjs" ],
+  "version": "0.3.2",
+  "author": "Jason Smith <jh...@iriscouch.com> (http://www.iriscouch.com)",
+  "repository": {
+    "type":"git",
+    "url":"https://github.com/iriscouch/couchjs"
+  },
+  "engines": {
+    "node": ">= 0.8"
+  },
+  "main": "./couchjs.js",
+  "bin": {
+    "couchjs-node":"./cli.js"
+  },
+  "couchdb": {
+    "main":"./couchdb.js",
+    "vhosts": [
+      "127.0.0.1.xip.io"
+    ]
+  },
+  "bundledDependencies": [
+    "node-inspector"
+  ],
+  "dependencies": {
+    "optimist": "~0.3.4",
+    "async"   : "~0.2.5",
+    "mkdirp"  : "~0.3.4",
+    "fibers"  : "~1.0.0",
+    "request" : "~2.9.203",
+    "pushover": "~1.2.1",
+    "defaultable": "~0.7.2",
+    "node-inspector": "git://github.com/iriscouch/node-inspector#couchjs"
+  },
+  "devDependencies": {
+    "tap": "~0.2.5"
+  }
 }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/sandbox.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/sandbox.js b/src/couchjs-node/sandbox.js
index cfdff18..5c18ef4 100644
--- a/src/couchjs-node/sandbox.js
+++ b/src/couchjs-node/sandbox.js
@@ -1,21 +1,28 @@
 // from https://github.com/KlausTrainer/sandbox.js
 exports.runInSandbox = function(src, ctx, whitelist) {
-  var vm = require('vm'),
-    sandbox;
+  var vm = require('vm');
+  var sandbox;
 
   if (ctx && ctx.require) {
+
     whitelist = whitelist || [];
-    var insecureRequire = ctx.require,
-      module = require("module"),
-      oldModulePrototype = module.prototype;
+
+    var insecureRequire = ctx.require;
+    var module = require('module');
+    var oldModulePrototype = module.prototype;
 
     var secureRequire = function(moduleName) {
-      if (whitelist.indexOf(moduleName) == -1) {
+
+      if (whitelist.indexOf(moduleName) === -1) {
         module.prototype = oldModulePrototype;
+
         throw new Error("'" + moduleName + "' is not whitelisted");
+
       } else {
         var requiredModule = insecureRequire(moduleName);
+
         module.prototype = oldModulePrototype;
+
         return requiredModule;
       }
     };
@@ -31,10 +38,10 @@ exports.runInSandbox = function(src, ctx, whitelist) {
     ctx.require = secureRequire;
     sandbox = Object.freeze(vm.createContext(ctx));
     ctx.require = insecureRequire;
+
   } else {
     sandbox = Object.freeze(vm.createContext(ctx || {}));
   }
 
-  return vm.createScript('(function() {"use strict"; return ('
-                         + src + ')()}())').runInContext(sandbox);
+  return vm.createScript('(function() {"use strict"; return (' + src + ')()}())').runInContext(sandbox);
 };

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/stream.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/stream.js b/src/couchjs-node/stream.js
index ad6bcab..d0c192c 100644
--- a/src/couchjs-node/stream.js
+++ b/src/couchjs-node/stream.js
@@ -12,94 +12,100 @@
 
 // Text line stream
 
-module.exports = LineStream
-module.exports.v2 = LineStream2
+module.exports = LineStream;
+module.exports.v2 = LineStream2;
 
-var stream = require('stream')
-var util = require('util')
+var stream = require('stream');
+var util = require('util');
 
 
-util.inherits(LineStream2, stream.Transform)
+util.inherits(LineStream2, stream.Transform);
+
 function LineStream2 () {
-  if(! (this instanceof LineStream2))
-    return new LineStream2
 
-  stream.Transform.call(this)
-  this.setEncoding('utf8')
+  if (!(this instanceof LineStream2)) {
+    return new LineStream2();
+  }
+
+  stream.Transform.call(this);
+  this.setEncoding('utf8');
 }
 
 LineStream2.prototype._transform = function(message, encoding, done) {
-  var self = this
+  var self = this;
 
-  message = message.toString(encoding)
-  var lines = message.split(/\n/)
+  message = message.toString(encoding);
+  var lines = message.split(/\n/);
 
   // If the data ends in "\n" this will be ""; otherwise the final partial line.
-  var remainder = lines.pop()
-  if(remainder)
-    this.unshift(remainder)
+  var remainder = lines.pop();
+  if (remainder) {
+    this.unshift(remainder);
+  }
 
   lines.forEach(function(line) {
-    self.push(line)
-  })
+    self.push(line);
+  });
 
-  done()
-}
+  done();
+};
+
+util.inherits(LineStream, stream);
 
-util.inherits(LineStream, stream)
 function LineStream () {
-  var self = this
-  stream.call(self)
+  var self = this;
+  stream.call(self);
 
-  self.readable = true
-  self.writable = true
+  self.readable = true;
+  self.writable = true;
 
-  self.buffer = ''
-  self.downstream = null
+  self.buffer = '';
+  self.downstream = null;
 
   self.on('pipe', function(upstream) {
     upstream.on('end', function(data, encoding) {
-      self.emit('end', data, encoding)
-    })
-  })
+      self.emit('end', data, encoding);
+    });
+  });
 }
 
 
 LineStream.prototype.write = function(data, encoding) {
-  var self = this
+  var self = this;
 
-  data = data || ''
-  if(typeof data != 'string')
-    return self.error(new Error('Data was not a string: ' + util.inspect(data)))
+  data = data || '';
+  if (typeof data !== 'string') {
+    return self.error(new Error('Data was not a string: ' + util.inspect(data)));
+  }
 
-  self.buffer += data
-  var lines = self.buffer.split(/\n/)
-  self.buffer = lines.pop() // If the data ended in "\n" this will be ""; otherwise the final partial line.
+  self.buffer += data;
+  var lines = self.buffer.split(/\n/);
+  self.buffer = lines.pop(); // If the data ended in "\n" this will be ""; otherwise the final partial line.
 
   lines.forEach(function(line) {
-    self.emit('data', line)
-  })
-}
+    self.emit('data', line);
+  });
+};
 
 
 LineStream.prototype.end = function(data, encoding) {
-  var self = this
+  var self = this;
 
-  self.is_ending = true
-  self.writable = false
+  self.is_ending = true;
+  self.writable = false;
 
   // Always call write, even with no data, so it can fire the "end" event.
-  self.write(data)
-}
+  self.write(data);
+};
 
 
 LineStream.prototype.error = function(er) {
-  var self = this
+  var self = this;
 
-  self.readable = false
-  self.writable = false
-  self.emit('error', er)
+  self.readable = false;
+  self.writable = false;
+  self.emit('error', er);
 
   // The write() method sometimes returns this value, so if there was an error, make write() return false.
-  return false
-}
+  return false;
+};

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/test/experiment.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/test/experiment.js b/src/couchjs-node/test/experiment.js
index 094ac1d..fedf6d0 100644
--- a/src/couchjs-node/test/experiment.js
+++ b/src/couchjs-node/test/experiment.js
@@ -10,108 +10,117 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-var vm = require('vm')
-var util = require('util')
+var vm = require('vm');
+var util = require('util');
 
-var STATE = 'wait'
-  , v = 'vm'
+var STATE = 'wait';
+var v = 'vm';
 
 function main() {
-  process.debugPort = 5859
-  process.kill(process.pid, 'SIGUSR1')
+  process.debugPort = 5859;
+  process.kill(process.pid, 'SIGUSR1');
 
-  setTimeout(function() { stuff(0) }, 1000)
+  setTimeout(function() {
+    stuff(0);
+  }, 1000);
 }
 
 function stuff(count) {
-  console.log('Doing stuff: %d', count)
-  //debugger
-  STATE = 'vm'
-  console.log('More stuff: %d', count)
-  if(STATE == 'done')
-    console.log('Done')
-  else if(STATE == 'code')
-    setTimeout(code, 1000)
-  else if(STATE == 'eval')
-    test_eval()
-  else if(STATE == 'vm')
-    test_vm()
-  else if(STATE == 'wait')
-    setTimeout(function() { stuff(count+1) }, 1000)
-  else
-    throw new Error('Unknown state: ' + STATE)
+
+  console.log('Doing stuff: %d', count);
+  STATE = 'vm';
+  console.log('More stuff: %d', count);
+
+  if (STATE === 'done') {
+    console.log('Done');
+  } else if (STATE === 'code') {
+    setTimeout(code, 1000);
+  } else if(STATE === 'eval') {
+    test_eval();
+  } else if(STATE === 'vm') {
+    test_vm();
+  } else if(STATE === 'wait') {
+    setTimeout(function() {
+      stuff(count+1);
+    }, 1000);
+  } else {
+    throw new Error('Unknown state: ' + STATE);
+  }
 }
 
 function code() {
-  var code =
-    [ 'var foo = "in the code"'
-    , 'console.log("This is some code")'
-    , 'debugger'
-    , 'console.log("foo = " + foo)'
-    ].join('\n')
-
-  var runner = Function([], code)
-  console.log('Run runner in 1s')
+  var code = [
+    'var foo = "in the code"',
+    'console.log("This is some code")',
+    'debugger',
+    'console.log("foo = " + foo)'
+    ].join('\n');
+
+  var runner = Function([], code);
+
+  console.log('Run runner in 1s');
+
   setTimeout(run_runner, 1000)
 
   function run_runner() {
-    console.log('About to run runner')
-    debugger
-    runner()
-    console.log('Runner done')
+    console.log('About to run runner');
+    debugger;
+    runner();
+    console.log('Runner done');
   }
 }
 
 function test_eval() {
-  console.log('Test eval in 1s')
-  setTimeout(run_eval, 1000)
+  console.log('Test eval in 1s');
+  setTimeout(run_eval, 1000);
 
-  var code =
-    [ 'var foo = "in eval"'
-    , 'console.log("This is eval")'
-    , 'debugger'
-    , 'console.log("foo = " + foo)'
-    ].join('\n')
+  var code = [
+    'var foo = "in eval"',
+    'console.log("This is eval")',
+    'debugger',
+    'console.log("foo = " + foo)'
+    ].join('\n');
 
   function run_eval() {
-    console.log('Run eval now')
-    debugger
-    eval(code)
+    console.log('Run eval now');
+    debugger;
+    eval(code);
   }
 }
 
 function test_vm() {
-  console.log('Test vm')
-
-  var code =
-    [ 'var i = 10'
-    , 'setTimeout(hello, 1000)'
-    , ''
-    , 'function hello() {'
-    , '  debugger'
-    , '  console.log("Hello: " + i)'
-    , '  if(--i)'
-    , '    setTimeout(hello, 1000)'
-    , '}'
-    ].join('\n')
-
-  console.log('Run vm now')
-  var filename = '_couchdb:code.js'
-
-  var sandbox = {}
-    , ok = ['console', 'setTimeout']
+  console.log('Test vm');
+
+  var code = [
+    'var i = 10',
+    'setTimeout(hello, 1000)',
+    '',
+    'function hello() {',
+    '  debugger',
+    '  console.log("Hello: " + i)',
+    '  if(--i)',
+    '    setTimeout(hello, 1000)',
+    '}'
+  ].join('\n');
+
+  console.log('Run vm now');
+  var filename = '_couchdb:code.js';
+
+  var sandbox = {};
+  var ok = ['console', 'setTimeout'];
 
   ok.forEach(function(key) {
-    sandbox[key] = global[key]
-  })
+    sandbox[key] = global[key];
+  });
 
-  var ctx = vm.createContext(sandbox)
-  var script = vm.createScript(code, filename)
+  var ctx = vm.createContext(sandbox);
+  var script = vm.createScript(code, filename);
 
-  var r = script.runInNewContext(sandbox)
-  console.log('Result:\n%s', util.inspect(r, false, 10))
-  return r
+  var r = script.runInNewContext(sandbox);
+  console.log('Result:\n%s', util.inspect(r, false, 10));
+  return r;
 }
 
-if(require.main === module)
-  main()
+if (require.main === module) {
+  main();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0902e8c5/src/couchjs-node/xml.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/xml.js b/src/couchjs-node/xml.js
index efd3a8f..b64d221 100644
--- a/src/couchjs-node/xml.js
+++ b/src/couchjs-node/xml.js
@@ -10,12 +10,13 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-module.exports = XML
 
 function XML () {
-  this.foo = 'bar'
+  this.foo = 'bar';
 }
 
 XML.prototype.toXMLString = function() {
-  return '<xml>\n  <title>test</title>\n</xml>'
-}
+  return '<xml>\n  <title>test</title>\n</xml>';
+};
+
+module.exports = XML;


[21/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

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/1894-feature-experimental-nodejs-couchjs
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:
 


[40/50] git commit: updated refs/heads/1894-feature-experimental-nodejs-couchjs to 532100c

Posted by ja...@apache.org.
add files to license.skip


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

Branch: refs/heads/1894-feature-experimental-nodejs-couchjs
Commit: 12763ee4b51780f793ce213ca2ae7a99da055f2c
Parents: 0595c5e
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Sep 21 16:24:20 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 17:21:29 2013 +0200

----------------------------------------------------------------------
 license.skip | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/12763ee4/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index 067fce3..d87cc6c 100644
--- a/license.skip
+++ b/license.skip
@@ -109,6 +109,8 @@
 ^src/couchdb/priv/couchjs
 ^src/couchdb/priv/couchspawnkillable
 ^src/couchdb/priv/stat_descriptions.cfg
+^src/couchjs-node/package.json
+^src/couchjs-node/README.md
 ^src/erlang-oauth/.*
 ^src/couch_dbupdates
 ^src/ejson/.*