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 @@ - - - Blog - - - {% for post in posts %} - {% endfor %} - - \ No newline at end of file diff --git a/examples/blog/views/layout.html b/examples/blog/views/layout.html deleted file mode 100644 index 2d2d886..0000000 --- a/examples/blog/views/layout.html +++ /dev/null @@ -1,62 +0,0 @@ - - - {% block title %}Blog{% endblock %} - - - -
- {% block content %} -

Missing content!

- {% endblock %} -
- - \ No newline at end of file diff --git a/examples/blog/views/list.html b/examples/blog/views/list.html deleted file mode 100644 index 5146be3..0000000 --- a/examples/blog/views/list.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends 'layout.html' %} - -{% block title %}Posts{% endblock %} - -{% block content %} -

Posts

-

You have {{ posts.length }} posts!

-

Create a Post

- -{% endblock %} \ No newline at end of file diff --git a/examples/blog/views/new.html b/examples/blog/views/new.html deleted file mode 100644 index 5907d9e..0000000 --- a/examples/blog/views/new.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'layout.html' %} - -{% block title %}New Post{% endblock %} - -{% block content %} -

New Post

-

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.title }}

-

{{ post.body }}

-{% endblock %} \ No newline at end of file