Permalink
Browse files

v0.2.0: preview blog posts

The version includes:

* API path: GET /post/:postid/preview
* HTML template for a blog post
* vendor lib for rendering markdown to HTML
* vendor lib for HTML templates
  • Loading branch information...
llabball committed Jan 26, 2014
1 parent f9a52bb commit 6c0036d0c676b275c13078d10f71325f61e3f0f0
Showing with 1,847 additions and 2 deletions.
  1. +1 −1 couchapp.json
  2. +6 −1 rewrites.json
  3. +27 −0 shows/preview.js
  4. +16 −0 templates/post.html
  5. +1,227 −0 vendor/marked.js
  6. +570 −0 vendor/mustache.js
@@ -1,5 +1,5 @@
{
"name": "StaticCouchBlog",
"description": "A web blog system to create, edit, preview and publish posts. The application is performance orienteted for the reads - it serves them finally as static files.",
"version": "0.1.0"
"version": "0.2.0"
}
@@ -3,5 +3,10 @@
"to": "../../:pid",
"from": "post/:pid",
"method": "PUT"
}
},
{
"to": "_show/preview/:pid",
"from": "post/:pid/preview",
"method": "GET"
}
]
@@ -0,0 +1,27 @@
function (doc) {
var Mustache = require('vendor/mustache')
, Marked = require('vendor/marked')
, templates = this.templates
, data = {}
, html = ''
if (doc) {
Marked.setOptions({sanitize: true})
data.title = doc.title
data.teaser = doc.teaser
data.publishing_date = new Date().toLocaleDateString()
data.content = Marked(doc.markdown)
data.rev = doc._rev
html = Mustache.render(templates.post, data, {
'uploadform': templates.uploadform
})
}
return {
code: (doc && html.length > 0) ? 200 : 404,
headers: {'Content-Type': 'text/html'},
body: html
}
}
@@ -0,0 +1,16 @@
<html>
<head>
<title>{{title}}</title>
</head>
<body>
<h1>{{title}}</h1>
<hr/>
<p><small>{{publishing_date}}</small></p>
<p><strong>{{teaser}}</strong></p>
{{{content}}}
</body>
</html>
Oops, something went wrong.

0 comments on commit 6c0036d

Please sign in to comment.