couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Couchdb Wiki] Update of "How to serve applications" by MartinCzura
Date Sun, 02 Nov 2008 01:04:52 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by MartinCzura:

The comment on the change is:
page creation

New page:
## page was renamed from ServingAppsFromCouchDb
You can write applications that are written entirely in HTML/CSS and JavaScript and that is
stored within CouchDB document attachments. Here's a short script that makes it easy to wrap
up a bunch of files and put them into a database.

This is a quick'n'dirty hack. All you need to do is fill the {{{$files}}} array with entries
of {{{$file}}} arrays that contain the filename and content-type of that file.

Run with: 
$ curl -X PUT http://server:5984/database/document -d "\`php upload.php\`"

$file["name"] = "main.html";
$file["contentType"] = "text/html";
$files[] = $file;

$file["name"] = "thread.html";
$file["contentType"] = "text/html";
$files[] = $file;

$file["name"] = "styles.css";
$file["contentType"] = "text/css";
$files[] = $file;

$file["name"] = "DetectWebkit.js";
$file["contentType"] = "application/javascript";
$files[] = $file;

foreach($files AS $file) {
	$file["data"] = base64_encode(file_get_contents($file["name"]));
	$attachments[] = <<<EOF
		"$file[name]": {

$attachments = implode(",\n\n", $attachments);

$document = <<<EOF
	"_attachments": {


echo $document;

View raw message