summaryrefslogtreecommitdiff
path: root/src/fabric.erl
diff options
context:
space:
mode:
authorBrad Anderson <brad@cloudant.com>2010-05-27 17:09:19 -0400
committerBrad Anderson <brad@cloudant.com>2010-05-27 17:09:19 -0400
commit6c7e3665cd941083dedb8ead5e9314f3c531ff89 (patch)
tree98e34ad5faf353bcce1ed600e511ef57ef09ee7f /src/fabric.erl
parentfaedecbc0393d87523fbc19b9edc17504c504782 (diff)
remove fabric_api, clean up other things to get futon rendering db list
Diffstat (limited to 'src/fabric.erl')
-rw-r--r--src/fabric.erl31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/fabric.erl b/src/fabric.erl
index e75e31eb..0957387e 100644
--- a/src/fabric.erl
+++ b/src/fabric.erl
@@ -1,10 +1,18 @@
-module(fabric).
-export([all_databases/1, create_db/2, delete_db/2, open_doc/3, open_doc/4,
- get_db_info/2]).
+ get_db_info/2, db_path/2]).
+
+-include("../../couch/src/couch_db.hrl").
% db operations
+-spec db_path(bstring(), bstring()) -> bstring().
+db_path(RawUri, Customer) ->
+ CustomerUri = generate_customer_path(RawUri, Customer),
+ {Path, _, _} = mochiweb_util:urlsplit_path(CustomerUri),
+ Path.
+
all_databases(Customer) ->
fabric_db:all_databases(Customer).
@@ -22,4 +30,23 @@ open_doc(Db, DocId, Options) ->
fabric_doc:open_doc(Db, DocId, Options).
open_doc(Db, DocId, Revs, Options) ->
- fabric_open:open_doc(Db, DocId, Revs, Options).
+ fabric_doc:open_doc(Db, DocId, Revs, Options).
+
+
+
+%%
+%% internal
+%%
+generate_customer_path("/", _Customer) ->
+ "";
+generate_customer_path("/favicon.ico", _Customer) ->
+ "favicon.ico";
+generate_customer_path([$/,$_|Rest], _Customer) ->
+ lists:flatten([$_|Rest]);
+generate_customer_path([$/|RawPath], Customer) ->
+ case Customer of
+ "" ->
+ RawPath;
+ Else ->
+ lists:flatten([Else, "%2F", RawPath])
+ end.