X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fquery%2Fvendor%2Fcouchapp%2Flib%2Fcode.js;fp=web%2Fquery%2Fvendor%2Fcouchapp%2Flib%2Fcode.js;h=51052d3789cd3bf0f2dc1cdb461ddb29f831aa75;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/query/vendor/couchapp/lib/code.js b/web/query/vendor/couchapp/lib/code.js new file mode 100644 index 0000000..51052d3 --- /dev/null +++ b/web/query/vendor/couchapp/lib/code.js @@ -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