-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
83 lines (67 loc) · 2.15 KB
/
app.js
File metadata and controls
83 lines (67 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Module dependencies.
*/
var express = require('express'),
app = express();
// Configuration
app.configure(function(){
app.set('port', process.env.PORT || 8000)
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static('public'));
app.use(app.router);
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
app.get('*', function(req, res, next){
res.locals.subdomains = {
'annarbor': 'Ann Arbor',
'detroit': 'Detroit',
'downriver': 'Downriver',
'royaloak': 'Royal Oak'
}
var matches = req.headers.host.match(/^([^\.]*)\.?(coffeehousecoders.*)$/);
if (matches) {
res.locals.subdomain = matches[1];
res.locals.domain = matches[2];
req.url = '/' + matches[1] + req.url;
}
next();
});
// Routes
app.get('/www/', function(req, res) {
res.render('index', { title: 'Coffee House Coders' });
});
app.get('/annarbor/', function(req, res) {
res.render('annarbor/index', { title: 'Ann Arbor Coffee House Coders' });
});
app.get('/annarbor/events', function(req, res) {
res.render('annarbor/events', { title: 'Events' })
});
app.get('/annarbor/about', function(req, res) {
res.render('annarbor/about', { title: 'About CHC' })
});
app.get('/annarbor/organizers', function(req, res) {
res.render('annarbor/organizers', { title: 'Meet the organizers' })
});
app.get('/annarbor/workshops', function(req, res) {
res.render('annarbor/workshops', { title: 'Workshops' })
});
app.get('/annarbor/discussions', function(req, res) {
res.render('annarbor/discussions', { title: 'Discussions' })
});
app.get('/detroit/', function(req, res) {
res.render('detroit/index', { title: 'Detroit Coffee House Coders' })
})
app.get('/downriver/', function(req, res) {
res.render('downriver/index', { title: 'Downriver Coffee House Coders' })
})
app.listen(app.get('port'), function(){
console.log("Express server listening on port %d in %s mode", app.get('port'), app.settings.env);
});