forked from mgingras/fBomb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsApp.js
100 lines (84 loc) · 2.43 KB
/
jsApp.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, newrelic = require('newrelic')
, http = require('http')
, path = require('path')
, util = require('util')
, twitter = require('twitter')
, compressor = require('node-minify')
, grunt = require('grunt');
// grunt.task.init = function() {};
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.tasks([],{}, function() {
grunt.log.ok('Grunt: Done running tasks!');
});
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// Mini-me
new compressor.minify({
type: 'uglifyjs',
fileIn: 'assets/js/fBomb.js',
fileOut: 'public/js/fBomb.min.js',
callback: function(err){
if(err) console.log("minify: " + err);
}
});
new compressor.minify({
type: 'uglifyjs',
fileIn: 'assets/js/add2home.js',
fileOut: 'public/js/add2home.min.js',
callback: function(err){
if(err) console.log("minify: " + err);
}
});
// development only configuration
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.locals.pretty = true;
});
// production configuration
app.configure('production', function(){
app.use(express.errorHandler());
});
var tweets = [];
var twit = new twitter({
consumer_key: process.env.consumer_key,
consumer_secret: process.env.consumer_secret,
access_token_key: process.env.oauth_token,
access_token_secret: process.env.oauth_token_secret
});
twit.stream('statuses/filter', {track:'fuck'}, function(stream) {
var id = 0;
stream.on('data', function(data) {
if(data.geo){
// data.geo.coordinates is an []
// console.log(data.text + " : " + data.geo.coordinates);
tweets.push({text: data.text, coordinates: data.geo.coordinates, id:id++});
}
});
});
getTweets = function(callback){
// console.log(tweets);
callback(tweets);
}
var eraseTweets = function(){
console.log("Erasing tweets");
tweets = [];
}
setInterval(eraseTweets, 10000);
app.get('/', routes.index);
app.get('/data', routes.data);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});