Missing content!
- {% endblock %} -diff --git a/examples/blog/index.js b/examples/blog/index.js deleted file mode 100644 index 3ed8886..0000000 --- a/examples/blog/index.js +++ /dev/null @@ -1,71 +0,0 @@ - -/** - * Module dependencies. - */ - -var render = require('./lib/render'); -var logger = require('koa-logger'); -var route = require('koa-route'); -var views = require('co-views'); -var parse = require('co-body'); -var koa = require('../..'); -var app = koa(); - -// "database" - -var posts = []; - -// middleware - -app.use(logger()); - -// route middleware - -app.use(route.get('/', list)); -app.use(route.get('/post/new', add)); -app.use(route.get('/post/:id', show)); -app.use(route.post('/post', create)); - -// route definitions - -/** - * Post listing. - */ - -function *list() { - this.body = yield render('list', { posts: posts }); -} - -/** - * Show creation form. - */ - -function *add() { - this.body = yield render('new'); -} - -/** - * Show post :id. - */ - -function *show(id) { - var post = posts[id]; - if (!post) this.throw(404, 'invalid post id'); - this.body = yield render('show', { post: post }); -} - -/** - * Create a post. - */ - -function *create() { - var post = yield parse(this); - var id = posts.push(post) - 1; - post.created_at = new Date; - post.id = id; - this.redirect('/'); -} - -// listen - -app.listen(3000); diff --git a/examples/blog/lib/render.js b/examples/blog/lib/render.js deleted file mode 100644 index f018cac..0000000 --- a/examples/blog/lib/render.js +++ /dev/null @@ -1,13 +0,0 @@ - -/** - * Module dependencies. - */ - -var views = require('co-views'); - -// setup views mapping .html -// to the swig template engine - -module.exports = views(__dirname + '/../views', { - map: { html: 'swig' } -}); \ No newline at end of file diff --git a/examples/blog/views/index.html b/examples/blog/views/index.html deleted file mode 100644 index 392e0ba..0000000 --- a/examples/blog/views/index.html +++ /dev/null @@ -1,9 +0,0 @@ - -
-Missing content!
- {% endblock %} -You have {{ posts.length }} posts!
- -Create a new post.
- -{% endblock %} \ No newline at end of file diff --git a/examples/blog/views/show.html b/examples/blog/views/show.html deleted file mode 100644 index d06164e..0000000 --- a/examples/blog/views/show.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends 'layout.html' %} - -{% block title %}{{ post.title }}{% endblock %} - -{% block content %} -{{ post.body }}
-{% endblock %} \ No newline at end of file