-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring repo to have directory-to-chapter mapping.
- Loading branch information
1 parent
d2a8aa1
commit b330a3f
Showing
751 changed files
with
214,105 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var express = require('express'); | ||
|
||
var app = express(); | ||
|
||
// set up handlebars view engine | ||
var handlebars = require('express3-handlebars') | ||
.create({ defaultLayout:'main' }); | ||
app.engine('handlebars', handlebars.engine); | ||
app.set('view engine', 'handlebars'); | ||
|
||
app.set('port', process.env.PORT || 3000); | ||
|
||
app.use(express.static(__dirname + '/public')); | ||
|
||
var fortuneCookies = [ | ||
"Conquer your fears or they will conquer you.", | ||
"Rivers need springs.", | ||
"Do not fear what you don't know.", | ||
"You will have a pleasant surprise.", | ||
"Whenever possible, keep it simple.", | ||
]; | ||
|
||
app.get('/', function(req, res) { | ||
res.render('home'); | ||
}); | ||
app.get('/about', function(req,res){ | ||
var randomFortune = | ||
fortuneCookies[Math.floor(Math.random() * fortuneCookies.length)]; | ||
res.render('about', { fortune: randomFortune }); | ||
}); | ||
|
||
// 404 catch-all handler (middleware) | ||
app.use(function(req, res, next){ | ||
res.status(404); | ||
res.render('404'); | ||
}); | ||
|
||
// 500 error handler (middleware) | ||
app.use(function(err, req, res, next){ | ||
console.error(err.stack); | ||
res.status(500); | ||
res.render('500'); | ||
}); | ||
|
||
app.listen(app.get('port'), function(){ | ||
console.log( 'Express started on http://localhost:' + | ||
app.get('port') + '; press Ctrl-C to terminate.' ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "meadowlarktravel", | ||
"version": "0.0.0", | ||
"description": "Sample website for Web Development with Node and Express (O'Reilly).", | ||
"main": "meadowlark.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/EthanRBrown/web-development-with-node-and-express.git" | ||
}, | ||
"author": "Ethan Brown <e@zepln.com>", | ||
"license": "GPL, MIT", | ||
"bugs": { | ||
"url": "https://github.com/EthanRBrown/web-development-with-node-and-express/issues" | ||
}, | ||
"homepage": "https://github.com/EthanRBrown/web-development-with-node-and-express", | ||
"dependencies": { | ||
"express": "~4.4.2", | ||
"express3-handlebars": "~0.5.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<h1>About Meadowlark Travel</h1> | ||
|
||
<p>Your fortune for the day:</p> | ||
<blockquote>{{fortune}}</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Welcome to Meadowlark Travel</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Meadowlark Travel</title> | ||
</head> | ||
<body> | ||
<header><img src="/img/logo.png" alt="Meadowlark Travel Logo"></header> | ||
{{{body}}} | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var express = require('express'); | ||
var fortune = require('./lib/fortune.js'); | ||
|
||
var app = express(); | ||
|
||
// set up handlebars view engine | ||
var handlebars = require('express3-handlebars') | ||
.create({ defaultLayout:'main' }); | ||
app.engine('handlebars', handlebars.engine); | ||
app.set('view engine', 'handlebars'); | ||
|
||
app.set('port', process.env.PORT || 3000); | ||
|
||
app.use(express.static(__dirname + '/public')); | ||
|
||
app.get('/', function(req, res) { | ||
res.render('home'); | ||
}); | ||
app.get('/about', function(req,res){ | ||
res.render('about', { fortune: fortune.getFortune() } ); | ||
}); | ||
|
||
// 404 catch-all handler (middleware) | ||
app.use(function(req, res, next){ | ||
res.status(404); | ||
res.render('404'); | ||
}); | ||
|
||
// 500 error handler (middleware) | ||
app.use(function(err, req, res, next){ | ||
console.error(err.stack); | ||
res.status(500); | ||
res.render('500'); | ||
}); | ||
|
||
app.listen(app.get('port'), function(){ | ||
console.log( 'Express started on http://localhost:' + | ||
app.get('port') + '; press Ctrl-C to terminate.' ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "meadowlarktravel", | ||
"version": "0.0.0", | ||
"description": "Sample website for Web Development with Node and Express (O'Reilly).", | ||
"main": "meadowlark.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/EthanRBrown/web-development-with-node-and-express.git" | ||
}, | ||
"author": "Ethan Brown <e@zepln.com>", | ||
"license": "GPL, MIT", | ||
"bugs": { | ||
"url": "https://github.com/EthanRBrown/web-development-with-node-and-express/issues" | ||
}, | ||
"homepage": "https://github.com/EthanRBrown/web-development-with-node-and-express", | ||
"dependencies": { | ||
"express": "~4.4.2", | ||
"express3-handlebars": "~0.5.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>404 - Not Found</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>500 - Server Error</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<h1>About Meadowlark Travel</h1> | ||
|
||
<p>Your fortune for the day:</p> | ||
<blockquote>{{fortune}}</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Welcome to Meadowlark Travel</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Meadowlark Travel</title> | ||
</head> | ||
<body> | ||
<header><img src="/img/logo.png" alt="Meadowlark Travel Logo"></header> | ||
{{{body}}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = function(grunt){ | ||
|
||
// load plugins | ||
[ | ||
'grunt-cafe-mocha', | ||
'grunt-contrib-jshint', | ||
'grunt-exec', | ||
].forEach(function(task){ | ||
grunt.loadNpmTasks(task); | ||
}); | ||
|
||
// configure plugins | ||
grunt.initConfig({ | ||
cafemocha: { | ||
all: { src: 'qa/tests-*.js', options: { ui: 'tdd' }, } | ||
}, | ||
jshint: { | ||
app: ['meadowlark.js', 'public/js/**/*.js', 'lib/**/*.js'], | ||
qa: ['Gruntfile.js', 'public/qa/**/*.js', 'qa/**/*.js'], | ||
}, | ||
exec: { | ||
linkchecker: { cmd: 'linkchecker http://localhost:3000' } | ||
}, | ||
}); | ||
|
||
// register tasks | ||
grunt.registerTask('default', ['cafemocha','jshint','exec']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var fortuneCookies = [ | ||
"Conquer your fears or they will conquer you.", | ||
"Rivers need springs.", | ||
"Do not fear what you don't know.", | ||
"You will have a pleasant surprise.", | ||
"Whenever possible, keep it simple.", | ||
]; | ||
|
||
exports.getFortune = function() { | ||
var idx = Math.floor(Math.random() * fortuneCookies.length); | ||
return fortuneCookies[idx]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var express = require('express'); | ||
var fortune = require('./lib/fortune.js'); | ||
|
||
var app = express(); | ||
|
||
// set up handlebars view engine | ||
var handlebars = require('express3-handlebars') | ||
.create({ defaultLayout:'main' }); | ||
app.engine('handlebars', handlebars.engine); | ||
app.set('view engine', 'handlebars'); | ||
|
||
app.set('port', process.env.PORT || 3000); | ||
|
||
app.use(express.static(__dirname + '/public')); | ||
|
||
// set 'showTests' context property if the querystring contains test=1 | ||
app.use(function(req, res, next){ | ||
res.locals.showTests = app.get('env') !== 'production' && | ||
req.query.test === '1'; | ||
next(); | ||
}); | ||
|
||
app.get('/', function(req, res) { | ||
res.render('home'); | ||
}); | ||
app.get('/about', function(req,res){ | ||
res.render('about', { | ||
fortune: fortune.getFortune(), | ||
pageTestScript: '/qa/tests-about.js' | ||
} ); | ||
}); | ||
app.get('/tours/hood-river', function(req, res){ | ||
res.render('tours/hood-river'); | ||
}); | ||
app.get('/tours/oregon-coast', function(req, res){ | ||
res.render('tours/oregon-coast'); | ||
}); | ||
app.get('/tours/request-group-rate', function(req, res){ | ||
res.render('tours/request-group-rate'); | ||
}); | ||
|
||
// 404 catch-all handler (middleware) | ||
app.use(function(req, res, next){ | ||
res.status(404); | ||
res.render('404'); | ||
}); | ||
|
||
// 500 error handler (middleware) | ||
app.use(function(err, req, res, next){ | ||
console.error(err.stack); | ||
res.status(500); | ||
res.render('500'); | ||
}); | ||
|
||
app.listen(app.get('port'), function(){ | ||
console.log( 'Express started on http://localhost:' + | ||
app.get('port') + '; press Ctrl-C to terminate.' ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "meadowlarktravel", | ||
"version": "0.0.0", | ||
"description": "Sample website for Web Development with Node and Express (O'Reilly).", | ||
"main": "meadowlark.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/EthanRBrown/web-development-with-node-and-express.git" | ||
}, | ||
"author": "Ethan Brown <e@zepln.com>", | ||
"license": "GPL, MIT", | ||
"bugs": { | ||
"url": "https://github.com/EthanRBrown/web-development-with-node-and-express/issues" | ||
}, | ||
"homepage": "https://github.com/EthanRBrown/web-development-with-node-and-express", | ||
"dependencies": { | ||
"express": "~4.4.2", | ||
"express3-handlebars": "~0.5.0", | ||
"chai": "~1.9.1" | ||
}, | ||
"devDependencies": { | ||
"grunt": "^0.4.5", | ||
"grunt-cafe-mocha": "^0.1.12", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-exec": "^0.4.5", | ||
"mocha": "~1.20.1", | ||
"zombie": "~2.0.0-alpha31" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var Browser = require('zombie'), | ||
assert = require('chai').assert; | ||
|
||
var browser; | ||
|
||
suite('Cross-Page Tests', function(){ | ||
|
||
setup(function(){ | ||
browser = new Browser(); | ||
}); | ||
|
||
test('requesting a group rate quote from the hood river tour page should ' + | ||
'populate the hidden referrer field correctly', function(done){ | ||
var referrer = 'http://localhost:3000/tours/hood-river'; | ||
browser.visit(referrer, function(){ | ||
browser.clickLink('.requestGroupRate', function(){ | ||
assert(browser.field('referrer').value === referrer); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
test('requesting a group rate from the oregon coast tour page should ' + | ||
'populate the hidden referrer field correctly', function(done){ | ||
var referrer = 'http://localhost:3000/tours/oregon-coast'; | ||
browser.visit(referrer, function(){ | ||
browser.clickLink('.requestGroupRate', function(){ | ||
assert(browser.field('referrer').value === referrer); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
test('visiting the "request group rate" page dirctly should result ' + | ||
'in an empty value for the referrer field', function(done){ | ||
browser.visit('http://localhost:3000/tours/request-group-rate', function(){ | ||
assert(browser.field('referrer').value === ''); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>404 - Not Found</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>500 - Server Error</h1> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Welcome to Meadowlark Travel</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Meadowlark Travel</title> | ||
{{#if showTests}} | ||
<link rel="stylesheet" href="/vendor/mocha.css"> | ||
{{/if}} | ||
<script src="//code.jquery.com/jquery-2.0.2.min.js"></script> | ||
</head> | ||
<body> | ||
<header><img src="/img/logo.png" alt="Meadowlark Travel Logo"></header> | ||
{{{body}}} | ||
{{#if showTests}} | ||
<div id="mocha"></div> | ||
<script src="/vendor/mocha.js"></script> | ||
<script src="/vendor/chai.js"></script> | ||
<script> | ||
mocha.ui('tdd'); | ||
var assert = chai.assert; | ||
</script> | ||
<script src="/qa/tests-global.js"></script> | ||
{{#if pageTestScript}} | ||
<script src="{{pageTestScript}}"></script> | ||
{{/if}} | ||
<script>mocha.run();</script> | ||
{{/if}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Hood River Tour</h1> | ||
<a class="requestGroupRate" href="/tours/request-group-rate">Request group rate.</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Oregon Coast Tour</h1> | ||
<a class="requestGroupRate" href="/tours/request-group-rate">Request group rate.</a> |
Oops, something went wrong.