Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a readme and a url .

  • Loading branch information...
commit 480582b5f7df76a6d7578167ddfc42d5b7cc15e3 1 parent 623ee74
Ryan Ramage ryanramage authored

Showing 2 changed files with 101 additions and 0 deletions. Show diff stats Hide diff stats

  1. +100 0 README.md
  2. +1 0  kanso.json
100 README.md
Source Rendered
... ... @@ -0,0 +1,100 @@
  1 +## node.couchapp.js support
  2 +
  3 +This kanso package lets you build couchapps in the [node.couchapp.js](https://github.com/mikeal/node.couchapp.js) style of project.
  4 +
  5 +## Install
  6 +
  7 +Add to your project's kanso.json dependencies setting, here is the minimal
  8 +case:
  9 +
  10 +```json
  11 +{
  12 + "app": "app",
  13 + "dependencies": {
  14 + "node-couchapp": null
  15 + }
  16 +}
  17 +```
  18 +
  19 +Notice the app property. The value is 'app' which means look for a file called 'app.js'.
  20 +
  21 +Run kanso install to install in your packages directory:
  22 +
  23 +```
  24 +kanso install
  25 +```
  26 +
  27 +
  28 +## app.js example:
  29 +
  30 +<pre>
  31 + var couchapp = require('couchapp')
  32 + , path = require('path');
  33 +
  34 + ddoc = {
  35 + _id: '_design/app'
  36 + , views: {}
  37 + , lists: {}
  38 + , shows: {}
  39 + }
  40 +
  41 + module.exports = ddoc;
  42 +
  43 + ddoc.views.byType = {
  44 + map: function(doc) {
  45 + emit(doc.type, null);
  46 + },
  47 + reduce: '_count'
  48 + }
  49 +
  50 + ddoc.views.peopleByName = {
  51 + map: function(doc) {
  52 + if(doc.type == 'person') {
  53 + emit(doc.name, null);
  54 + }
  55 + }
  56 + }
  57 +
  58 + ddoc.lists.people = function(head, req) {
  59 + start({
  60 + headers: {"Content-type": "text/html"}
  61 + });
  62 + send("&lt;ul id='people'>\n");
  63 + while(row = getRow()) {
  64 + doc = row.doc;
  65 + send("\t&lt;li class='person name'>" + doc.name + "&lt;/li>\n");
  66 + }
  67 + send("&lt;/ul>\n")
  68 + }
  69 +
  70 + ddoc.shows.person = function(doc, req) {
  71 + return {
  72 + headers: {"Content-type": "text/html"},
  73 + body: "&lt;h1 id='person' class='name'>" + doc.name + "&lt;/h1>\n"
  74 + }
  75 + }
  76 +
  77 + couchapp.loadAttachments(ddoc, path.join(__dirname, '_attachments'));
  78 +</pre>
  79 +
  80 +
  81 +## Options
  82 +
  83 +If you are including a node.couchapp.js style project into another kanso app, the design docs will get merged.
  84 +The exception is 'rewrites'. This can't be merged very well, so there is an option to prepend the included rewrites. Here is how:
  85 +
  86 +```json
  87 +{
  88 + "app": "app",
  89 + "node-couchapp" : {
  90 + "merge-rewrites" : true
  91 + },
  92 + "dependencies": {
  93 + "node-couchapp": null
  94 + }
  95 +}
  96 +```
  97 +
  98 +
  99 +
  100 +
1  kanso.json
... ... @@ -1,5 +1,6 @@
1 1 {
2 2 "name": "node-couchapp",
  3 + "url" : "https://github.com/kanso/node-couchapp",
3 4 "version": "0.8.2",
4 5 "categories": ["build-tools"],
5 6 "description": "adds a build step using node.couchapp.js",

0 comments on commit 480582b

Please sign in to comment.
Something went wrong with that request. Please try again.