tweetcast/nodejs-bis/tweetcast.js
changeset 380 b3f66379fed7
parent 374 0c4acfa2aea1
--- a/tweetcast/nodejs-bis/tweetcast.js	Wed Nov 16 17:47:11 2011 +0100
+++ b/tweetcast/nodejs-bis/tweetcast.js	Thu Nov 17 19:08:32 2011 +0100
@@ -1,5 +1,5 @@
 READ_OLD_TWEETS = true;
-RECORD_NEW_TWEETS = false;
+RECORD_NEW_TWEETS = true;
 var conf_file = flagOption('-c', 'conf.js');
 console.log('Reading Configuration from ' + conf_file);
 var fs = require('fs');
@@ -77,16 +77,17 @@
         'utc_offset'
     ],
     content_types = {
-        css : "text/css",
-        html : "text/html",
-        js : "text/javascript",
+        css : "text/css; charset=utf-8",
+        html : "text/html; charset=utf-8",
+        js : "text/javascript; charset=utf-8",
         png : "image/png"
     };
 
 function httpHandler(req, res) {
     console.log("HTTP Request for URL "+req.url);
-    var url = ( req.url == "/config" ? conf_file : __dirname + "/client" + req.url + ( req.url[req.url.length - 1] == "/" ? "index.html" : "" ) ),
-        ext = url.split('.').slice(-1)[0].toLowerCase();
+    var url = req.url.split('?')[0];
+    url = ( url == "/config.js" ? conf_file : __dirname + "/client" + url + ( url[url.length - 1] == "/" ? "index.html" : "" ) );
+    var ext = url.split('.').slice(-1)[0].toLowerCase();
     fs.readFile( url, function(err, data) {
         if (err) {
             console.log("Error 404");
@@ -110,7 +111,6 @@
         console.log("Error: Tweet already in list");
         return false;
     }
-    tweet.date_value = new Date(tweet.created_at).valueOf();
     tweets.push(tweet);
     tweet_ids.push(tweet.id);
     return true;
@@ -188,6 +188,7 @@
                                 delete tweet.retweeted_status[keys_to_delete[j]];
                             }
                         }
+                    /*    tweet.date_value = Date.parse(tweet.created_at); */
                         if (addToList(tweet)) {
                             writestream.write(JSON.stringify(tweet)+'\n');
                         }
@@ -213,10 +214,14 @@
 
 if (READ_OLD_TWEETS) {
     readTweetsFromFile(tweet_file);
+} else {
+    console.log("Reading old tweets disabled !");
 }
 
 if (RECORD_NEW_TWEETS) {
     requestTweets();
+} else {
+    console.log("Recording new tweets disabled !");
 }
 
 io.set('log level', 0);