forked from laktek/realie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (40 loc) · 1.17 KB
/
app.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
require.paths.unshift('./vendor/express/lib')
var sys = require('sys')
require('express')
require('express/plugins')
var redis = require("./vendor/redis-node-client/lib/redis-client");
configure(function(){
use(Logger)
use(MethodOverride)
use(ContentLength)
use(Cookie)
use(Cache, { lifetime: (5).minutes, reapInterval: (1).minute })
use(Session, { lifetime: (15).minutes, reapInterval: (1).minute })
use(Static)
set('root', __dirname)
})
var main_store = redis.createClient();
get('/pad', function(){
self = this;
main_store.get('pad-snapshot', function(err, reply){
if(reply){
sys.puts(JSON.parse(reply.toString('utf8'))["message"]);
sys.puts("parsed");
var reply_lines = JSON.parse(reply.toString('utf8'))["message"].split("\n");
var html_lines = [];
for(var line_no in reply_lines){
html_lines.push("<div>" + reply_lines[line_no] + "</div>");
}
var snapshot_html = html_lines.join("");
}
else
var snapshot_html = "";
self.render('pad.html.ejs', {
encoding: 'utf8',
locals: {
snapshot: snapshot_html,
}
});
});
});
run()