Reupholster

For CouchDB Application Development

Start Reupholster

Easy

Reupholster makes developing a CouchDB Application easy. One click and you have all you need to start.

Well Rounded

Reupholster has baked in support for BDD tests, continuous integration, automated deployments, and release management.

Compatible

The format reupholster uses is compatible with node.couchapp.js, another popular CouchDB development tool. We are adding support for other tools in the future.

Getting Started

Step 1.

Get a CouchDB

Step 2.

Run Reupholster
Start Reupholster

Click on this button to download and run reupholster. It should both download and run the application.

Java Java is required to run reupholster. Most computers will already have this installed. You may need to check here.

Google Chrome Chrome will list the download on the bottom of the page, and to the right of the filename is a small drop down arrow, click it. Select 'Always open files of this type'. See here for more details.

Not Working? If you are unable to launch reupholster, you can download it here

Step 3.

Create An App
  • Use the ... button to select an empty directoy.
  • Select a template. Can be any zip couchapp project. Other urls you can use:
    • https://github.com/maxogden/couchtml5/zipball/master
    • https://github.com/maxogden/recline/zipball/master
  • Fill in the couch db details from Step 1. Optionally add your authentication details.
  • Click Start

Step 4.

Interact With Reupholster

Reupholster runs as a tray icon.
Clicking on it will bring up this menu:

Menu ItemAction
ExitExit Reupholster
Toggle ConsoleShow/Hide a console. This console helps you see what reupholster is doing under the hood.
Run Tests Local(Firefox)Runs all the tests in the /tests directory using the firefox browser.
Run Tests Local(HtmlUnit)Runs all the tests in the /tests directory using a headless browser. This is faster than firefox, and is the same method used for continuous integration.
Open Test ResultsAfter tests are run, this item will be enabled. It will show an html report of the test results in your default browser.
Deploy To: Deploy the current application to a remote CouchDB. See Deployment section.
Open App In BrowserOpen your default browser and show the Couch Application.
Open Project DirectoryShow the project directory using your default filesystem browser.

Step 5.

Edit/Save/View
Open the project directory, and you can now start the normal edit, save, page-reload development. Start with the html folder and play around.
The overall project structure:
ProjectRoot
  .couchappignore
  app.js
  pom.xml
  README.md
  reupholster.json
 +docs
      Test.json 
 +test
        defaultPageStory.groovy
 +html
      index.html

			

ProjectRoot

.couchappignore

This allows you to specify what files (in the html folder) are to be ignored, and not included in the final couchapp. The format is a json array of regular expressions.
[
   ".*\\.swp$",
   ".*~$"
]

app.js

This is the main file for generating the couch application. It is used to generate the main _design/doc which holds the application. Here are some examples.

Define the design doc

ddoc = {
      _id: '_design/app'
    , views: {}
    , lists: {}
    , shows: {}
 }

Create a CouchDB View

ddoc.views.byType = {
    map: function(doc) {
      emit(doc.type, null);
    },
    reduce: '_count'
  }
 }
This view would be accessed at http://localhost:5984/_design/app/_view/byType

Create a CouchDB list

/**
* A list function that outputs the same format that you 
* use to post into the _bulk_docs API
*
* @author Max Ogden
*/
ddoc.lists.bulkDocs: function(head, req) {
      var row, out, sep = '\n';

      start({"headers":{"Content-Type" : "application/json"}});

      if ('callback' in req.query) send(req.query['callback'] + "(");

      send('{"docs":[');
      while (row = getRow()) {
          out = JSON.stringify(row.value);
          send(sep + out);
          sep = ',\n';
      }
      send("\n]}");
      if ('callback' in req.query) send(")");
  }

Create A Validation Function

ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {
  if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) {
    throw "Only admin can delete documents on this database.";
  }
};

Set the html folder

  couchapp.loadAttachments(ddoc, path.join(__dirname, 'html'));
This is done at the end of app.js. It defines 'html' as the folder that holds the attachments. If you change this, rename the html file as well.

Warning Reupholster only supports this being called once.
node.couchapp.js supports this with multiple calls.

pom.xml

This allows you run reupholster with maven, and used for continuous integration, automated deployments, and release management. You should not need to edit or change it.

reupholster.json

This file holds project settings that reupholster needs. Here is the layout:
{
  couch : {
    host : "localhost",
    port : 4977,
    db : "couchhtml5"
  },
  test-couch : {
    host : "ecko-it.iriscouch.com",
    port : "5984",
    db : "testsample",
    username : "test"
  },
  stages : {
    qa : {
      host : "ecko-it.iriscouch.com",
      port : "5984",
      db : "sampleqa",
      username : "test"
    }
  }
}

couch is the local (or remote) couch that is your working copy, updated as you change files. The Run Tests Local menu options run the tests against this couch.

test-couch is used for continuous integration. On every check-in reupholster will delete it, redeploy the app, and run the test against on this db.

stages Holds a list of couchdbs that can be deployed to.