Add scripts to create myops-getqueryview:
[myops.git] / web / query / vendor / couchapp / lib / code.js
diff --git a/web/query/vendor/couchapp/lib/code.js b/web/query/vendor/couchapp/lib/code.js
new file mode 100644 (file)
index 0000000..51052d3
--- /dev/null
@@ -0,0 +1,20 @@
+exports.ddoc = function(ddoc) {
+  // only return the parts of the app that we use
+  var i, j, path, key, obj, ref, out = {},
+    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 out;
+};
\ No newline at end of file