removed 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 8d7e35b · Browse files · 9 files·+0 added−107 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+0 added−107 removed
- other:+0 added−107 removed
Provenance
- Commit
379f3ec- Tree
d428656- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
8d7e35b
9 files changed+0 added−107 removed
deleted:examples/blog/blog/views/partials/post.ejs-2 removed
1-<h3><a href="<%= basepath %>/post/<%= id %>"><%= title %></a></h3>2-<p><%= body %></p>deleted:examples/blog/blog/views/index.ejs-2 removed
1-<h2>Posts</h2>2-<%- partial('post', { collection: posts, as: global }) %>deleted:examples/blog/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/blog/views/post.ejs-1 removed
1-<%- partial('post', { object: post, as: global }) %>deleted:examples/blog/blog/index.js-45 removed
123456789101112131415161718192021222324252627282930313233343536373839404142434445
/** * Module dependencies. */
var express = require('./../../../lib/express'), fs = require('fs');
// Export our app as the modulevar app = module.exports = express.createServer();
// Set views directoryapp.set('views', __dirname + '/views');
// Load our postsvar posts = JSON.parse(fs.readFileSync(__dirname + '/posts.json', 'utf8'));
// Set our default view engine to "ejs"app.set('view engine', 'ejs');
app.dynamicHelpers({ basepath: function(){ // "this" is the app, we can // dynamically provide the "home" // setting to all views return this.set('home'); }});
app.get('/', function(req, res){ res.render('index', { locals: { posts: posts } });});
app.get('/post/:id', function(req, res){ var id = req.params.id; res.render('post', { locals: { post: posts[id] } });});No newline at end of filedeleted:examples/blog/blog/posts.json-4 removed
1234[ { "id": 0, "title": "Post one", "body": "Just some lame post" }, { "id": 1, "title": "Post two", "body": "Just another lame post" }]No newline at end of filedeleted:examples/blog/app.js-25 removed
12345678910111213141516171819202122232425
// Expose modules in ./support for demo purposesrequire.paths.unshift(__dirname + '/../../support');
/** * Module dependencies. */
var express = require('./../../lib/express');
// Our app IS the exports, this prevents require('./app').app,// instead it is require('./app');var app = module.exports = express.createServer();
// Illustrates that an app can be broken into// several files, but yet extend the same apprequire('./main');require('./contact');
// Illustrates that one app (Server instance) can// be "mounted" to another at the given route.app.use('/blog', require('./blog'));
app.listen(3000);console.log('Express started on port 3000');No newline at end of filedeleted:examples/blog/contact.js-9 removed
123456789
// in ./app.js we did "module.exports", allowing// us to grab the app from the parent module (the one // which required it)var app = module.parent.exports;
app.get('/contact', function(req, res){ res.send('<p>Wahoo contact page</p>');});deleted:examples/blog/main.js-10 removed
1-2-// in ./app.js we did "module.exports", allowing3-// us to grab the app from the parent module (the one 4-// which required it)5-var app = module.parent.exports;6-7-app.get('/', function(req, res){8- res.send('<p>Visit <a href="/blog">/blog</a>'9- + ' or <a href="/contact">/contact</a></p>');10-});