Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gomugomu committed Jul 2, 2014
0 parents commit 9b64498
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ignore packages installed by npm
node_modules
bower_components
33 changes: 33 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var express = require('express');
var path = require('path');

// Loads the various route files
var routes = require('./routes/index');
var about = require('./routes/about');
var handlebars = require('express3-handlebars').create({defaultLayout: 'main'});

var app = express();
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');

// Specifies a path for static files and views for client side
app.use(express.static(path.join(__dirname, 'public')));
app.use('/bower_components', express.static(__dirname + '/bower_components'));

// Defines the routes to use given the URL path
app.use('/', routes);
app.use('/about', about);

// custom 404 page
app.use(function(req, res) {
res.status(404);
res.render('404');
});

// custom 500 page
app.use(function(req, res) {
res.status(500);
res.render('500');
});

module.exports = app;
20 changes: 20 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "hakman",
"version": "0.0.1",
"authors": [
"hakman"
],
"description": "hakman - Govhack 2014",
"main": "server.js",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.2.0"
}
}
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "hakman",
"version": "0.0.1",
"description": "Hakman - Govhack 2014",
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "bower install"
},
"author": "hakman",
"license": "ISC",
"dependencies": {
"d3": "^3.4.9",
"express": "^4.4.5",
"express3-handlebars": "^0.5.0"
}
}
11 changes: 11 additions & 0 deletions routes/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res) {
res.render('about');
// You can pass in Json to the template (can be used in the template as {{name}})
// res.render('about', {name: 'value'});
});

module.exports = router;
9 changes: 9 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res) {
res.render('home');
});

module.exports = router;
8 changes: 8 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node
var app = require('./app');

app.set('port', process.env.PORT || 3000);

var server = app.listen(app.get('port'), function() {
console.log('Express server listening on port ' + server.address().port);
});
1 change: 1 addition & 0 deletions views/404.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>404 - Not Found</h1>
1 change: 1 addition & 0 deletions views/500.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>500 - Server Error</h1>
1 change: 1 addition & 0 deletions views/about.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>About Hakman</h1>
1 change: 1 addition & 0 deletions views/home.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Welcome to Hakman!<h1>
11 changes: 11 additions & 0 deletions views/layouts/main.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<title>HAKMAN - Govhack 2014</title>
</head>
<body>
{{{body}}}

</body>
</html>

0 comments on commit 9b64498

Please sign in to comment.