Permalink
Browse files

Print error if design doc already exists

  • Loading branch information...
1 parent 9eeab0c commit d1b35bb47602a18cde49b8ef194135defda8838f @paulcarey committed Jan 12, 2009
Showing with 11 additions and 3 deletions.
  1. +1 −1 README.textile
  2. +10 −2 upload_binaries.sh
View
@@ -4,7 +4,7 @@ Fuschia is a graphical document browser for CouchDB. It's built on prefuse and F
h3. Using
-Clone this repo, set @DB_NAME@ in @upload_binaries.sh@ to your target database and run @./upload_binaries.sh@. This will create a design document named fuschia containing views that, for a given document, retrieve all documents that it points to, and all documents that point to it.
+Clone this repo @git clone git@github.com:paulcarey/fuschia.git@, then run @./upload_binaries.sh $your_db_name@. This will create a design document named fuschia containing views that, for a given document, retrieve all documents that it points to, and all documents that point to it.
Now direct your browser at "http://localhost:5984/*mydb*/_design/fuschia/Fuschia.html":http://localhost:5984/mydb/_design/fuschia/Fuschia.html, enter a full database uri (e.g. @http://localhost:5984/mydb@), seed document id and click load. You should be able to browse through your database.
View
@@ -1,6 +1,8 @@
#!/bin/bash
-DB_NAME=your_db_name
+set -u
+
+DB_NAME=$1
DESIGN_DOC=localhost:5984/${DB_NAME}/_design%2Ffuschia
@@ -9,7 +11,13 @@ HTML='Content-Type:text/html'
SWF='Content-Type:application/x-shockwave-flash'
CSS='Content-Type:text/css'
-# Will intentionally fail if a design doc named fuschia already exists
+RES=`curl -s $DESIGN_DOC | grep not_found`
+if [ $? != 0 ]; then
+ echo "${DESIGN_DOC} exists!"
+ echo It must be deleted before running this script
+ exit 1
+fi
+
REV=`curl -s -T bin/fuschia_queries.json $DESIGN_DOC | egrep -o '[0-9]+'`
REV=`curl -s -H $JS -T bin/AC_OETags.js ${DESIGN_DOC}/AC_OETags.js?rev=${REV} | egrep -o '[0-9]+'`
REV=`curl -s -H $HTML -T bin/Fuschia.html ${DESIGN_DOC}/Fuschia.html?rev=${REV} | egrep -o '[0-9]+'`

0 comments on commit d1b35bb

Please sign in to comment.