Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 29 - relax having a .couchapprc file #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/erica_push.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ push1(Path, DbKey, Config) ->
Path1 = filename:absname(Path),
case erica_util:in_couchapp(Path1) of
{ok, CouchappDir} ->
%% load app conf from .couchapprc and initialize ignore
%% patterns.
Config1 = erica_config:update(CouchappDir, Config),

Db = erica_util:db_from_key(Config1, DbKey),
?DEBUG("push ~s => ~s~n", [CouchappDir, DbKey]),
{ok, _} = do_push(CouchappDir, Db, Config1),
push2(CouchappDir, DbKey, Config),
ok;

{error, not_found} ->
?ERROR("Can't find initialized couchapp in '~p'~n", [Path]),
halt(1)
push2(Path1, DbKey, Config),
ok
end.

push2(CouchappDir, DbKey, Config) ->
Config1 = erica_config:update(CouchappDir, Config),

Db = erica_util:db_from_key(Config1, DbKey),
?DEBUG("push ~s => ~s~n", [CouchappDir, DbKey]),
{ok, _} = do_push(CouchappDir, Db, Config1).


do_push(Path, Db, Config) ->
DocId = id_from_path(Path, Config),
do_push(Path, Db, DocId, Config).
Expand Down
11 changes: 7 additions & 4 deletions src/erica_web.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ web([Path], Config) ->
Path1 = filename:absname(Path),
case erica_util:in_couchapp(Path1) of
{ok, CouchappDir} ->
Config1 = erica_config:update(CouchappDir, Config),
do_web(CouchappDir, Config1);
web1(CouchappDir, Config);
{error, not_found} ->
?ERROR("Can't find initialized couchapp in '~p'~n", [Path]),
halt(1)
web1(Path1, Config)
end.

web1(CouchappDir, Config) ->
Config1 = erica_config:update(CouchappDir, Config),
do_web(CouchappDir, Config1).


do_web(Path, Config) ->

%% get files from memory
Expand Down
21 changes: 12 additions & 9 deletions src/erica_webbrowser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ browse1(Path, DbKey, Config) ->
Path1 = filename:absname(Path),
case erica_util:in_couchapp(Path1) of
{ok, CouchappDir} ->
%% load app conf from .couchapprc and initialize ignore
%% patterns.
Config1 = erica_config:update(CouchappDir, Config),

Db = erica_util:db_from_key(Config1, DbKey),
?DEBUG("browse ~p to ~p~n", [DbKey, CouchappDir]),
do_browse(CouchappDir, Db, Config1);
browse2(CouchappDir, DbKey, Config),
ok;

{error, not_found} ->
?ERROR("Can't find initialized couchapp in '~p'~n", [Path]),
halt(1)
browse2(Path1, DbKey, Config),
ok
end.

browse2(CouchappDir, DbKey, Config) ->
Config1 = erica_config:update(CouchappDir, Config),

Db = erica_util:db_from_key(Config1, DbKey),
?DEBUG("push ~s => ~s~n", [CouchappDir, DbKey]),
do_browse(CouchappDir, Db, Config1).



do_browse(Path, Db, Config) ->
DocId = erica_push:id_from_path(Path, Config),
Expand Down