Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ddoc is embedded in the html

  • Loading branch information...
commit db1860143cfd7d3ff85a97a0d5058c90ae9ea09f 1 parent 1e8cfba
@jchris jchris authored
View
5 shows/page.js
@@ -1,8 +1,13 @@
function(doc, req) {
+ var code = require("vendor/couchapp/lib/code").ddoc(this),
+ ddoc_code = JSON.stringify(code);
+ // top two lines have to come first or else parent references in the ddoc
+ // which are created by calls to require will break JSON.stringify.
var name, stub, ddoc = this,
mustache = require("vendor/couchapp/lib/mustache"),
wiki = require("lib/wiki"),
data = {
+ ddoc : ddoc_code,
docid : JSON.stringify(req.id),
id : req.id,
path : "../page/"+req.id,
View
2  templates/page.html
@@ -23,7 +23,7 @@
opts.db = "pages";
opts.design = "pages";
};
- opts.code = "_show/app";
+ opts.ddoc = {{{ddoc}}};
$.couch.app(function(app) {
$("#account").evently("account", app);
$("#profile").evently("profile", app);
View
7 vendor/couchapp/_attachments/jquery.couch.app.js
@@ -133,7 +133,7 @@
dname = opts.design || fragments[index + 4];
$.couch.urlPrefix = urlPrefix;
var db = $.couch.db(dbname),
- design = new Design(db, dname, opts.code);
+ design = new Design(db, dname, opts.load_path);
var appExports = $.extend({
db : db,
design : design,
@@ -149,6 +149,11 @@
}
appFun.apply(appExports, [appExports]);
}
+ if (opts.ddoc) {
+ // allow the ddoc to be embedded in the html
+ // to avoid a second http request
+ $.couch.app.ddocs[design.doc_id] = opts.ddoc;
+ }
if ($.couch.app.ddocs[design.doc_id]) {
$(function() {handleDDoc($.couch.app.ddocs[design.doc_id])});
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.