-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.coffee
39 lines (33 loc) · 1.12 KB
/
app.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
fs = require 'fs'
flatiron = require 'flatiron'
plates = require 'plates'
crawler = require './crawl'
app = flatiron.app
app.use flatiron.plugins.http
main_plate = '''
<html style="background:#eee;">
<head>
<title>Pekterest</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="/js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
<style>
#ct{margin-left:auto; margin-right: auto; font: 12px sans; width: 1000px;}
.col{float:left; margin:4px; width: 182px}
.box{margin-bottom:8px; padding:4px; border-radius:4px; background: #fff;}
</style>
</head>
<body onload="view_init()"><div id="ct"><div style="clear:both"></div></div></body>
</html>
'''
app.router.get '/', ->
@res.writeHead 200, 'Content-Type': 'text/html'
@res.end main_plate
app.router.get '/js', ->
@res.writeHead 200, 'Content-Type': 'text/javascript'
for f in ['node_modules/plates/lib/plates.js', 'view.js']
@res.write fs.readFileSync f
@res.end ''
app.router.get '/moar', ->
crawler.crawl (data) => @res.end JSON.stringify data
app.start 8080