-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
77 lines (70 loc) · 1.89 KB
/
server.js
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
var fab = require("./vendor/fab")
, app = require('./lib/app')
, sys = require('sys')
, qs = require('querystring')
, Slide = require('./lib/slide').Slide
, Presentation = require('./lib/presentation').Presentation
with(fab)
(fab)
(listen, +process.env.PORT || 0xFAB)
(route, /^\/stylesheets/)
(route, /^\/theme\/images\/(.*)$/)
(app.static.png, "public/stylesheets/theme/images")
()
(route, /^\/(.*)/)
(app.static.css)
()
('Not found!')
()
(route, /^\/javascripts/)
(route, /^\/(.*)/)
(app.static.js)
()
('Not found!')
()
(route, /^\/talks/)
(require('./lib/app-talks'))
()
(route, /^\/create/)
(method.POST)
(function (app) {
return app(function(write, head, body) {
return fab.stream(function(stream) {
var s = ''
body(function(chunk) {
if(chunk) {
s += chunk
} else {
var params = qs.parse(s)
var db = Model.couch.db('slides')
Presentation.save(
{ db: db
, author: params.author || "Anonymous"
, title: params.title || "Untitled"
})(function(err, pres) {
Slide.save(
{ db: db
, presentation: pres.id
, number: params.number || 1
, body: params.body
})(function(err, s) {
stream(write(sys.inspect(params) + "\n\n"))
stream(write(sys.inspect(s)))
stream(write())
})
})
}
})
})
})
})
()
(app.mu, 'form', function(cb, head) {
cb({edit_pres: true, number: 1})
})
()
(route, /^\/favicon.ico$/)
(app.static, 'public', null, 'ico', 'favicon')
()
('Hi')
()