-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.coffee
83 lines (66 loc) · 1.98 KB
/
settings.coffee
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
express = require("express")
gzippo = require("gzippo")
mongoStore = require("connect-mongodb")
mongooseAuth = require("mongoose-auth")
url = require("url")
require "coffee-script"
exports.boot = (app) ->
bootApplication app
bootApplication = (app) ->
app.configure ->
app.use require('connect-assets')({src: __dirname + "/app/assets"})
app.set "views", __dirname + "/app/views"
app.set "view engine", "jade"
app.set "view options",
layout: "layouts/default"
app.use (req, res, next) ->
res.local "path", url.parse(req.url).pathname
res.local "contentFor", (section, str) ->
res.local section, str
res.local "content", (section) ->
unless typeof res.local(section) is "undefined"
res.local section
else
""
next()
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.cookieParser()
app.use express.session(
secret: "secret"
store: new mongoStore(
url: config.db.uri
collection: "sessions"
)
)
app.use express.logger(":method :url :status")
app.use express.favicon()
app.use mongooseAuth.middleware()
app.dynamicHelpers
request: (req) ->
req
session: (req) ->
req.session
dateformat: (req, res) ->
require("./public/javascripts/lib/dateformat").strftime
base: ->
(if "/" is app.route then "" else app.route)
appName: (req, res) ->
"an app"
slogan: (req, res) ->
"an app"
loggedIn: (req) ->
if req.loggedIn
return true
else
return false
messages: require("express-messages")
app.set "showStackError", false
app.configure "development", ->
app.set("showStackError", true)
app.use(express.static(__dirname + "/public"))
app.configure "staging", ->
app.use(gzippo.staticGzip(__dirname + "/public"))
app.enable("view cache")
app.configure "production", ->
app.use gzippo.staticGzip(__dirname + "/public")