Skip to content

Commit

Permalink
ddoc is embedded in the html
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Aug 23, 2010
1 parent 1e8cfba commit db18601
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions shows/page.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion vendor/couchapp/_attachments/jquery.couch.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit db18601

Please sign in to comment.