-
Notifications
You must be signed in to change notification settings - Fork 1
/
route.js
54 lines (45 loc) · 1.23 KB
/
route.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
/*jshint node:true*/
var Twitter = require('./public/js/twitter'), // returns singleton instance
Cloudify = require('./public/js/cloudify'),
LoremIpsum = require('./public/js/loremipsum');
exports.index = function(req, res) {
res.render("index.html");
}
exports.twitter = function(req, res){
queryString = req.param("query");
if (!queryString) {
queryString = "from:breakingnews";
}
//TODO lang: 'en', result_type: 'popular'
Twitter.search(queryString+" exclude:retweets", { count: 100 }, function(data) {
parameters = {
data: data.statuses,
textExtractFn: function(s) { return s.text; },
idExtractFn: function(s) { return s.id; }
};
cloudified = Cloudify(parameters);
cloudified.data = data.statuses;
res.json(cloudified);
});
}
exports.loremipsum = function(req, res){
queryString = req.param("query");
if (queryString) {
queryArray = queryString.split(' ');
} else {
queryArray = [];
}
content = LoremIpsum();
parameters = {
data: content,
query: queryArray,
textExtractFn: function(s) { return s; },
idExtractFn: function(s) { return s; }
};
cloudified = Cloudify(parameters);
cloudified.data = content;
res.json(cloudified);
}
exports.login = function(req, res){
res.json("login"); //TODO
}