Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement a show function to send a subset of the ddoc based on the d…

…doc.couchapp.load member
  • Loading branch information...
commit 6a17e9884984083e7e6cd788c9ac50ebbeeef860 1 parent 3b63dfa
@jchris jchris authored
Showing with 36 additions and 4 deletions.
  1. +15 −4 couchapp.json
  2. +21 −0 shows/app.js
View
19 couchapp.json
@@ -1,5 +1,16 @@
{
- "name": "CouchApp Pages",
- "description": "A Simple CouchApp Wiki",
- "index" : "_rewrite/page/index"
-}
+ "name": "CouchApp Pages",
+ "description": "A Simple CouchApp Wiki",
+ "index" : "_rewrite/page/index",
+ "load" : {
+ "app" : [
+ "lib",
+ "evently",
+ "vendor/couchapp/evently",
+ "vendor/couchapp/lib/linkup",
+ "vendor/couchapp/lib/markdown",
+ "vendor/couchapp/lib/mustache",
+ "vendor/couchapp/lib/md5"
+ ]
+ }
+}
View
21 shows/app.js
@@ -0,0 +1,21 @@
+function(doc, req) {
+ // make this a commonjs module so you can inline the ddoc in the html
+ // only return the parts of the app that we use
+ var i, j, path, key, obj, ref, out = {}, ddoc = this,
+ resources = ddoc.couchapp && ddoc.couchapp.load && ddoc.couchapp.load.app || [];
+ for (i=0; i < resources.length; i++) {
+ path = resources[i].split('/');
+ obj = ddoc;
+ ref = out;
+ for (j=0; j < path.length; j++) {
+ key = path[j];
+ ref[key] = ref[key] || {};
+ if (j < path.length - 1) {
+ obj = obj[key];
+ ref = ref[key];
+ }
+ };
+ ref[key] = obj[key];
+ };
+ return {json : out};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.