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/08/03 15:19:50 UTC
[1/2] git commit: updated refs/heads/1867-feature-plugins to 44a9dbc
Updated Branches:
refs/heads/1867-feature-plugins 0d848df86 -> 44a9dbc0e
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/140245d1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/140245d1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/140245d1
Branch: refs/heads/1867-feature-plugins
Commit: 140245d10cb035f3d915509e3d14ead2d298b650
Parents: 0d848df
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Aug 3 15:19:13 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat Aug 3 15:19:13 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/140245d1/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/140245d1/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
[2/2] git commit: updated refs/heads/1867-feature-plugins to 44a9dbc
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/44a9dbc0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/44a9dbc0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/44a9dbc0
Branch: refs/heads/1867-feature-plugins
Commit: 44a9dbc0e1a35dcf19e610098432c934c63cfbc0
Parents: 140245d
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Aug 3 15:19:40 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat Aug 3 15:19:40 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/44a9dbc0/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) ->