Skip to content
Myr

Refactored blog example

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent ffca2de · Browse files · 13 files+54 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

13 files+54 added−57 removed

  • other:+54 added−57 removed

13 files+54 added−57 removed

added:examples/blog/blog/views/partials/post.ejs+2 added
1<h3><a href="/blog/post/<%= id %>"><%= title %></a></h3>2<p><%= body %></p>
added:examples/blog/blog/views/index.ejs+2 added
1<h2>Posts</h2>2<%- partial('post', { collection: posts, as: global }) %>
added:examples/blog/blog/views/layout.ejs+9 added
1<html>2 <head>3 <title>Blog Example</title>4 </head>5 <body>6 <h1>Best Blog Ever</h1>7 <%- body %>8 </body>9</html>
added:examples/blog/blog/views/post.ejs+1 added
1<%- partial('post', { object: post, as: global }) %>
added:examples/blog/blog/index.js+35 added
added:examples/blog/blog/posts.json+4 added
deleted:examples/blog/views/partials/post.ejs-2 removed
1<h3><a href="/blog/post/<%= id %>"><%= title %></a></h3>2<p><%= body %></p>
deleted:examples/blog/views/index.ejs-2 removed
1<h2>Posts</h2>2<%- partial('post', { collection: posts, as: global }) %>
deleted:examples/blog/views/layout.ejs-9 removed
1<html>2 <head>3 <title>Blog Example</title>4 </head>5 <body>6 <h1>Best Blog Ever</h1>7 <%- body %>8 </body>9</html>
deleted:examples/blog/views/post.ejs-1 removed
1<%- partial('post', { object: post, as: global }) %>
modified:examples/blog/app.js+1 added-4 removed
3 unmodified lines
4 */56var express = require('./../../lib/express');78// Load our blog app9var blog = require('./blog');108// Define our main application910var app = express.createServer();11
1 unmodified line
13 res.send('<p>Visit /blog</p>');14});1516// "mount" our blog app to the /blog path20app.use('/blog', blog);17app.use('/blog', require('./blog'));1819app.listen(3000);
deleted:examples/blog/blog.js-35 removed
12/**3 * Module dependencies.4 */56var express = require('./../../lib/express'),7 fs = require('fs');89// Export our app as the module10var app = module.exports = express.createServer();1112// Set views directory13app.set('views', __dirname + '/views');1415// Load our posts16var posts = JSON.parse(fs.readFileSync(__dirname + '/posts.json', 'utf8'));1718// Set our default view engine to "ejs"19app.set('view engine', 'ejs');2021app.get('/', function(req, res){22 res.render('index', {23 locals: {24 posts: posts25 }26 });27});2829app.get('/post/:id', function(req, res, params){30 res.render('post', {31 locals: {32 post: posts[params.id]33 }34 });35});
deleted:examples/blog/posts.json-4 removed
1[2 { "id": 0, "title": "Post one", "body": "Just some lame post" },3 { "id": 1, "title": "Post two", "body": "Just another lame post" }4]