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

View File

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

View File

@ -367,6 +367,7 @@ $(function() {
});
chat.on("msg", ".messages", function(e, target, msg) {
console.log(msg);
var btn = sidebar.find(".chan[data-target=" + target + "]:not(.active)");
var query = btn.hasClass("query");
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();
if (a == b) {
return opt.fn(this);
} else {
return opt.inverse(this);
}
}
);

View File

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

View File

@ -13,6 +13,7 @@ Msg.Type = {
NOTICE: "notice",
PART: "part",
QUIT: "quit",
THUMB: "thumb",
TOPIC: "topic",
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) {
return;
}
var chan = _.findWhere(network.channels, {name: data.nickname});
if (typeof chan === "undefined") {
chan = new Chan({
@ -21,7 +20,6 @@ module.exports = function(irc, network) {
chan: chan
});
}
var prefix = {
hostname: "from",
realname: "is",