mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
removed blog example
This commit is contained in:
parent
8d7e35b723
commit
379f3ec8dd
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
// Expose modules in ./support for demo purposes
|
||||
require.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 app
|
||||
require('./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');
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var express = require('./../../../lib/express'),
|
||||
fs = require('fs');
|
||||
|
||||
// Export our app as the module
|
||||
var app = module.exports = express.createServer();
|
||||
|
||||
// Set views directory
|
||||
app.set('views', __dirname + '/views');
|
||||
|
||||
// Load our posts
|
||||
var 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]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
[
|
||||
{ "id": 0, "title": "Post one", "body": "Just some lame post" },
|
||||
{ "id": 1, "title": "Post two", "body": "Just another lame post" }
|
||||
]
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<h2>Posts</h2>
|
||||
<%- partial('post', { collection: posts, as: global }) %>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Blog Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best Blog Ever</h1>
|
||||
<%- body %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<h3><a href="<%= basepath %>/post/<%= id %>"><%= title %></a></h3>
|
||||
<p><%= body %></p>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<%- partial('post', { object: post, as: global }) %>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
// 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>');
|
||||
});
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
// 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('/', function(req, res){
|
||||
res.send('<p>Visit <a href="/blog">/blog</a>'
|
||||
+ ' or <a href="/contact">/contact</a></p>');
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user