incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf Nieuwenhuijsen" <ralf.nieuwenhuij...@gmail.com>
Subject CouchDB qooxdoo contribution is now available
Date Thu, 29 May 2008 16:45:31 GMT
Hi, there, dear qooxdoo-ers,

I've finally got around to uploading the couchDB support code.
For more information about CouchDB, see: http://wiki.apache.org/couchdb/

The documentation is still a bit sparse, but it should work pretty intuitively.
The most difficult part, I think, is setting up a couchDB server and
making the webserver that is hosting your qooxdoo project proxy a
specific path to the couchDB server. This is required because of the
security limitations of modern browsers concerning cross-domain
requests.

Because some of questions may be CouchDB related, i've also sent this
mail to the couchdb mailing list. So make sure to hit reply-all when
you have a question concerning CouchDB.

Below, i'll show:
  1) how to use the contribution in your project
  2) a simple example code
  3) how to setup the couchdb server in Ubuntu.

Greetings,
Ralf Nieuwenhuijsen

=================
Using the contribution
=================

  In your qooxdoo project's makefile, put:

      APPLICATION_INCLUDES = contrib://CouchDB/trunk

  Everytime your make your project, it will check for updates and
download them from svn if available. You need subversion installed
offcourse.

==============
A simple example
==============

   couch.Default.configure('mydatabase', 'path/to/couchdb',
'username', 'password');
   var myDoc = new couch.Document('mydocument');

   myDoc.setKey('type', 'recipe');
   myDoc.setKey('ingredients', ['milk','egg','flower' ]);
   myDoc.setKey('name', 'pancakes');

   myDoc.save();
   myDoc.once('available', function(){
     alert('document is now saved and available on the server!');
   });

==================================================
Setting it up on Ubuntu (and likely all other debian derivatives):
==================================================

  sudo apt-get install automake autoconf libtool subversion-tools
help2man build-essential erlang libicu38 libicu-dev libmozjs-dev
  mkdir couchdb
  cd couchdb
   svn co http://svn.apache.org/repos/asf/incubator/couchdb/trunk couchdb
  ./bootstrap
  ./configure
  make && sudo make install
  sudo adduser  --home /usr/local/var/lib/couchdb  couchdb
  sudo cp /usr/local/etc/init.d/couchdb /etc/init.d/couchdb

Now you can launch the couchdb server with:

  sudo /etc/init.d/couchdb start

It is not started automatically when you boot-up though, but since
it's not stable software yet, that might be a Good Thing (tm)
Also note that it runs on its own user for security purposes. (it
could be simpler .. )
Now try to see if it works:

  http://localhost:5984/_utils/

This should show you futon .. the built-in web-administration. (Nice, huh?)
Remember couchDB uses rest, so GET queries can be tested directly in
the database.
If you try:

   http://localhost:5984/

You get the current status of server:

{"couchdb":"Welcome","version":"0.7.3a661200"}

It's all http queries (GET|PUT|POST|DELETE) and JSON.
However, your webserver you likely run on localhost:80 isn't allowed
to access localhost:5984 because of security restrictions with
XMLRemoteRequest thingie.
So, you need to setup a proxy. Assuming you are running Apache2:

  sudo aptitude install apache2 apache2-mod-rewrite-html
  sudo a2enmod rewrite proxy proxy_http

Make sure you are allowed to rewrite urls in your .htaccess files
A typical entry in /etc/apache2/sites-available that does that would be:

<VirtualHost *>
	ServerAdmin webmaster@localhost
	Alias /mysite /path/to/site
	<Directory /path/to/site>
	   Options Indexes FollowSymLinks MultiViews
	   AllowOverride All
	</Directory>
</VirtualHost>

It's the AllowOverride that does the magic ..
Now in your site's document root, do this:

  cd /path/to/site
  mkdir couch
  cd couch
  nano .htaccess

In that .htaccess file you should put:

RewriteEngine   on
RewriteRule     ([^\/]*)\/_view\/([^\/]*)\/(.*) http://localhost:5984/$1/_view/$
2/$3 [p]
RewriteRule     ([^\/]*)\/([^\/]*)\/(.*) http://localhost:5984/$1/$2\%2F$3 [p]
RewriteRule     (.*) http://localhost:5984/$1 [p]

Press control+o to save and then control-x to exit the nano-text-editor.
Now, let's reload apache:

  sudo /etc/init.d/apache2 reload

Then try to see if the rewriting works. Open the following url:

  http://localhost/mysite/couch

So, the path to couch is now mysite/couch.
You're done ;-)

=========================================================

Mime
View raw message