Permalink
Browse files

Added website thumbnails

  • Loading branch information...
1 parent c452dd8 commit f512a5d82262694f56e4d04f6c97a6a91514a27f @orktes committed Apr 15, 2012
@@ -270,8 +270,6 @@ exports.saveMessage = function (message, callback) {
data.id = id;
data.ts = time;
- eventEmitter.trigger('new_message', data);
-
var multi = redis.multi();
var hash = 'message:' + id;
@@ -312,7 +310,30 @@ exports.saveMessage = function (message, callback) {
return;
}
- callback(null, true);
+
+ (function nextUrl(i) {
+ var url = data.urls[i];
+ if (url == null) {
+ eventEmitter.trigger('new_message', data);
+ callback(null, true);
+ return;
+ }
+
+ if (url.type != 'website') {
+ nextUrl(++i);
+ return;
+ }
+
+ utils.makeWebPageThumbnail(url.url, __dirname + "/../../public/img/thumbnails/" + id + ".png", function (err) {
+ if (err) {
+ eventEmitter.trigger('new_message', data);
+ callback(err);
+ return;
+ }
+ nextUrl(++i);
+ });
+
+ })(0);
});
});
View
@@ -3,6 +3,9 @@ var tagRegex = /[#]+[ÄäÅåÖöA-Za-z0-9-_]+/;
var types = require('./mediatypes').media;
+var Thumbbot = require('thumbbot');
+
+
exports.parseMessage = function (message, callback) {
var msg = message.toString();
var urls = [];
@@ -55,5 +58,11 @@ exports.parseMessage = function (message, callback) {
});
})(0);
})(0);
+};
+exports.makeWebPageThumbnail = function (url, target, callback) {
+ console.log("Creating thumbnail", url, target);
+ var bot = new Thumbbot(url, target);
+ bot.set({width: 200, height: 150, method: 'resize'});
+ bot.snap(callback);
};
View
@@ -8,6 +8,7 @@
"redis":"0.7.1"
, "irc":"0.3.3"
, "express":"2.5.9"
+ , "thumbbot":"0.1.0"
, "request":"2.9.202"
, "reds":"0.1.3"
, "socket.io":"0.9.5"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f512a5d

Please sign in to comment.