diff --git a/client/css/style.css b/client/css/style.css index 1c5a806..e5368bc 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -574,7 +574,7 @@ button { content: '* '; } #chat .toggle-button { - background: #eee; + background: #f5f5f5; border-radius: 2px; display: inline-block; color: #666; @@ -588,16 +588,27 @@ button { display: none; color: #222; font: 12px Lato; - max-width: 220px; + max-width: 480px; padding: 6px 8px; margin-top: 2px; } -#chat .toggle-content.show { - display: inline-block !important; +#chat .toggle-content a { + color: inherit; } #chat .toggle-content img { max-width: 100%; max-height: 100%; + display: block; + margin: 2px 0; +} +#chat .toggle-content .head { + font-weight: bold; +} +#chat .toggle-content .body { + color: #999; +} +#chat .toggle-content.show { + display: inline-block !important; } #chat .count { background: #fafafa; diff --git a/client/js/shout.templates.js b/client/js/shout.templates.js index b394fe5..c080f75 100644 --- a/client/js/shout.templates.js +++ b/client/js/shout.templates.js @@ -130,17 +130,19 @@ templates['network'] = template({"1":function(depth0,helpers,partials,data) { templates['toggle'] = template({"1":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; return " \n \n \n"; },"3":function(depth0,helpers,partials,data) { - var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "
" - + escapeExpression(((helper = (helper = helpers.head || (depth0 != null ? depth0.head : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"head","hash":{},"data":data}) : helper))) - + "
\n
\n " + var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " \n
"; + stack1 = ((helper = (helper = helpers.head || (depth0 != null ? depth0.head : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"head","hash":{},"data":data}) : helper)); + if (stack1 != null) { buffer += stack1; } + return buffer + "
\n
\n " + escapeExpression(((helper = (helper = helpers.body || (depth0 != null ? depth0.body : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"body","hash":{},"data":data}) : helper))) - + "\n
\n"; + + "\n
\n \n"; },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var stack1, helperMissing=helpers.helperMissing, buffer = "
\n"; stack1 = ((helpers.equal || (depth0 && depth0.equal) || helperMissing).call(depth0, (depth0 != null ? depth0.type : depth0), "image", {"name":"equal","hash":{},"fn":this.program(1, data),"inverse":this.program(3, data),"data":data})); diff --git a/client/templates/toggle.tpl b/client/templates/toggle.tpl index 68f674e..e68eb50 100644 --- a/client/templates/toggle.tpl +++ b/client/templates/toggle.tpl @@ -1,13 +1,15 @@
{{#equal type "image"}} - - + + {{else}} -
{{head}}
-
- {{body}} -
+ +
{{{head}}}
+
+ {{body}} +
+
{{/equal}}
diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index 9dd5814..2bf1b3b 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -1,4 +1,5 @@ var _ = require("lodash"); +var cheerio = require("cheerio"); var Msg = require("../../models/msg"); var request = require("superagent"); @@ -43,12 +44,16 @@ module.exports = function(irc, network) { }; function parse(id, url, res, client) { + var type = ""; var head = ""; var body = ""; - var type = ""; + var link = url; switch (res.type) { case "text/html": + var $ = cheerio.load(res.res.text); type = "link"; + head = $("title").text(); + body = "No description found."; break; case "image/png": @@ -56,7 +61,6 @@ function parse(id, url, res, client) { case "image/jpg": case "image/jpeg": type = "image"; - body = url; break; default: @@ -65,8 +69,9 @@ function parse(id, url, res, client) { client.emit("toggle", { id: id, type: type, - head: type, - body: body + head: head, + body: body, + link: link, }); }