X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fquery%2Fshows%2Fedit.js;fp=web%2Fquery%2Fshows%2Fedit.js;h=e0488154388eba8f478009c71fc02738e7c76449;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/query/shows/edit.js b/web/query/shows/edit.js new file mode 100644 index 0000000..e048815 --- /dev/null +++ b/web/query/shows/edit.js @@ -0,0 +1,35 @@ +function(doc, req) { + var ddoc = this; + var Mustache = require("lib/mustache"); + var path = require("vendor/couchapp/lib/path").init(req); + + var indexPath = path.list('index','recent-posts',{descending:true, limit:10}); + var feedPath = path.list('index','recent-posts',{descending:true, limit:10, format:"atom"}); + var commentsFeed = path.list('comments','comments',{descending:true, limit:10, format:"atom"}); + + var data = { + header : { + index : indexPath, + blogName : ddoc.blog.title, + feedPath : feedPath, + commentsFeed : commentsFeed + }, + scripts : {}, + pageTitle : doc ? "Edit: "+doc.title : "Create a new post", + assets : path.asset() + }; + + if (doc) { + data.doc = JSON.stringify(doc); + data.title = doc.title; + data.body = doc.body; + data.tags = doc.tags.join(", "); + } else { + data.doc = JSON.stringify({ + type : "post", + format : "markdown" + }); + } + + return Mustache.to_html(ddoc.templates.edit, data, ddoc.templates.partials); +} \ No newline at end of file