Added thumbnail plugin

This commit is contained in:
Mattias Erming 2014-08-16 12:49:28 -07:00
parent 68922365d5
commit 0fcdbeadec
10 changed files with 57 additions and 11 deletions

View File

@ -433,6 +433,7 @@ button {
#chat .text { #chat .text {
display: table-cell; display: table-cell;
padding: 4px 0; padding: 4px 0;
vertical-align: top;
} }
#chat .time { #chat .time {
background: #fcfdfd; background: #fcfdfd;
@ -491,6 +492,10 @@ button {
#chat .action .user:before { #chat .action .user:before {
content: '* '; content: '* ';
} }
#chat .thumb {
max-height: 120px;
max-width: 240px;
}
#chat .count { #chat .count {
background: #fcfcfc; background: #fcfcfc;
background: #fff; background: #fff;

View File

@ -223,7 +223,11 @@
</span> </span>
<span class="text"> <span class="text">
<em class="type">{{type}}</em> <em class="type">{{type}}</em>
{{#equal type "thumb"}}
<img src="{{text}}" class="thumb">
{{else}}
{{{uri text}}} {{{uri text}}}
{{/equal}}
</span> </span>
</div> </div>
{{/each}} {{/each}}

View File

@ -367,6 +367,7 @@ $(function() {
}); });
chat.on("msg", ".messages", function(e, target, msg) { chat.on("msg", ".messages", function(e, target, msg) {
console.log(msg);
var btn = sidebar.find(".chan[data-target=" + target + "]:not(.active)"); var btn = sidebar.find(".chan[data-target=" + target + "]:not(.active)");
var query = btn.hasClass("query"); var query = btn.hasClass("query");
var type = msg.type; var type = msg.type;

16
client/js/libs.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,8 @@ Handlebars.registerHelper(
b = b.toString(); b = b.toString();
if (a == b) { if (a == b) {
return opt.fn(this); return opt.fn(this);
} else {
return opt.inverse(this);
} }
} }
); );

View File

@ -9,7 +9,7 @@ module.exports = Client;
var id = 0; var id = 0;
var events = [ var events = [
"errors", "error",
"join", "join",
"kick", "kick",
"mode", "mode",
@ -20,6 +20,7 @@ var events = [
"notice", "notice",
"part", "part",
"quit", "quit",
"thumb",
"topic", "topic",
"welcome", "welcome",
"whois" "whois"

View File

@ -13,6 +13,7 @@ Msg.Type = {
NOTICE: "notice", NOTICE: "notice",
PART: "part", PART: "part",
QUIT: "quit", QUIT: "quit",
THUMB: "thumb",
TOPIC: "topic", TOPIC: "topic",
WHOIS: "whois" WHOIS: "whois"
}; };

View File

@ -0,0 +1,34 @@
var _ = require("lodash");
var Msg = require("../../models/msg");
module.exports = function(irc, network) {
var client = this;
irc.on("message", function(data) {
var image = "";
var split = data.message.split(" ");
_.each(split, function(w) {
var match = w.match(/^(http|https).*\.(gif|png|jpg|jpeg)$/i);
if (match !== null) {
image = w;
}
});
if (image === "") {
return;
}
var target = data.to;
var chan = _.findWhere(network.channels, {name: target.charAt(0) == "#" ? target : data.from});
if (typeof chan === "undefined") {
return;
}
var msg = new Msg({
type: Msg.Type.THUMB,
from: data.from,
text: "http://placehold.it/320x320" // image
});
chan.messages.push(msg);
client.emit("msg", {
chan: chan.id,
msg: msg
});
});
};

View File

@ -8,7 +8,6 @@ module.exports = function(irc, network) {
if (data === null) { if (data === null) {
return; return;
} }
var chan = _.findWhere(network.channels, {name: data.nickname}); var chan = _.findWhere(network.channels, {name: data.nickname});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
@ -21,7 +20,6 @@ module.exports = function(irc, network) {
chan: chan chan: chan
}); });
} }
var prefix = { var prefix = {
hostname: "from", hostname: "from",
realname: "is", realname: "is",