Persist inline links
This commit is contained in:
parent
7a0e572100
commit
6c6e76afda
@ -278,7 +278,7 @@ $(function() {
|
|||||||
|
|
||||||
socket.on("toggle", function(data) {
|
socket.on("toggle", function(data) {
|
||||||
var toggle = $("#toggle-" + data.id);
|
var toggle = $("#toggle-" + data.id);
|
||||||
toggle.parent().after(render("toggle", data));
|
toggle.parent().after(render("toggle", {toggle: data}));
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "link":
|
case "link":
|
||||||
if (options.links) {
|
if (options.links) {
|
||||||
|
@ -84,7 +84,7 @@ templates['msg'] = template({"1":function(depth0,helpers,partials,data) {
|
|||||||
buffer += " </span>\n <span class=\"text\">\n <em class=\"type\">"
|
buffer += " </span>\n <span class=\"text\">\n <em class=\"type\">"
|
||||||
+ escapeExpression(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"type","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"type","hash":{},"data":data}) : helper)))
|
||||||
+ "</em>\n";
|
+ "</em>\n";
|
||||||
stack1 = ((helpers.equal || (depth0 && depth0.equal) || helperMissing).call(depth0, (depth0 != null ? depth0.type : depth0), "toggle", {"name":"equal","hash":{},"fn":this.program(6, data),"inverse":this.program(8, data),"data":data}));
|
stack1 = ((helpers.equal || (depth0 && depth0.equal) || helperMissing).call(depth0, (depth0 != null ? depth0.type : depth0), "toggle", {"name":"equal","hash":{},"fn":this.program(6, data),"inverse":this.program(9, data),"data":data}));
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
return buffer + " </span>\n</div>\n";
|
return buffer + " </span>\n</div>\n";
|
||||||
},"2":function(depth0,helpers,partials,data) {
|
},"2":function(depth0,helpers,partials,data) {
|
||||||
@ -95,12 +95,19 @@ templates['msg'] = template({"1":function(depth0,helpers,partials,data) {
|
|||||||
+ escapeExpression(((helper = (helper = helpers.from || (depth0 != null ? depth0.from : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"from","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.from || (depth0 != null ? depth0.from : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"from","hash":{},"data":data}) : helper)))
|
||||||
+ "</button>\n";
|
+ "</button>\n";
|
||||||
},"6":function(depth0,helpers,partials,data) {
|
},"6":function(depth0,helpers,partials,data) {
|
||||||
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <div class=\"force-newline\">\n <button id=\"toggle-"
|
||||||
return " <div class=\"force-newline\">\n <button id=\"toggle-"
|
|
||||||
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
|
||||||
+ "\" class=\"toggle-button\">···</button>\n </div>\n";
|
+ "\" class=\"toggle-button\">···</button>\n </div>\n";
|
||||||
},"8":function(depth0,helpers,partials,data) {
|
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.toggle : depth0), {"name":"if","hash":{},"fn":this.program(7, data),"inverse":this.noop,"data":data});
|
||||||
var stack1, helperMissing=helpers.helperMissing, buffer = " ";
|
if (stack1 != null) { buffer += stack1; }
|
||||||
|
return buffer;
|
||||||
|
},"7":function(depth0,helpers,partials,data) {
|
||||||
|
var helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
||||||
|
return " "
|
||||||
|
+ escapeExpression(((helpers.partial || (depth0 && depth0.partial) || helperMissing).call(depth0, "toggle", {"name":"partial","hash":{},"data":data})))
|
||||||
|
+ "\n";
|
||||||
|
},"9":function(depth0,helpers,partials,data) {
|
||||||
|
var stack1, helperMissing=helpers.helperMissing, buffer = " ";
|
||||||
stack1 = ((helpers.parse || (depth0 && depth0.parse) || helperMissing).call(depth0, (depth0 != null ? depth0.text : depth0), {"name":"parse","hash":{},"data":data}));
|
stack1 = ((helpers.parse || (depth0 && depth0.parse) || helperMissing).call(depth0, (depth0 != null ? depth0.text : depth0), {"name":"parse","hash":{},"data":data}));
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
return buffer + "\n";
|
return buffer + "\n";
|
||||||
@ -128,13 +135,18 @@ templates['network'] = template({"1":function(depth0,helpers,partials,data) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
},"useData":true});
|
},"useData":true});
|
||||||
templates['toggle'] = template({"1":function(depth0,helpers,partials,data) {
|
templates['toggle'] = template({"1":function(depth0,helpers,partials,data) {
|
||||||
|
var stack1, helperMissing=helpers.helperMissing, buffer = "<div class=\"toggle-content\">\n";
|
||||||
|
stack1 = ((helpers.equal || (depth0 && depth0.equal) || helperMissing).call(depth0, (depth0 != null ? depth0.type : depth0), "image", {"name":"equal","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data}));
|
||||||
|
if (stack1 != null) { buffer += stack1; }
|
||||||
|
return buffer + " </div>\n</div>\n";
|
||||||
|
},"2":function(depth0,helpers,partials,data) {
|
||||||
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
||||||
return " <a href=\""
|
return " <a href=\""
|
||||||
+ escapeExpression(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"link","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"link","hash":{},"data":data}) : helper)))
|
||||||
+ "\" target=\"_blank\">\n <img src=\""
|
+ "\" target=\"_blank\">\n <img src=\""
|
||||||
+ escapeExpression(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"link","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"link","hash":{},"data":data}) : helper)))
|
||||||
+ "\">\n </a>\n";
|
+ "\">\n </a>\n";
|
||||||
},"3":function(depth0,helpers,partials,data) {
|
},"4":function(depth0,helpers,partials,data) {
|
||||||
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <a href=\""
|
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <a href=\""
|
||||||
+ escapeExpression(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"link","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"link","hash":{},"data":data}) : helper)))
|
||||||
+ "\" target=\"_blank\">\n <div class=\"head\">";
|
+ "\" target=\"_blank\">\n <div class=\"head\">";
|
||||||
@ -144,10 +156,11 @@ templates['toggle'] = template({"1":function(depth0,helpers,partials,data) {
|
|||||||
+ 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)))
|
+ 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 </div>\n </a>\n";
|
+ "\n </div>\n </a>\n";
|
||||||
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
|
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
|
||||||
var stack1, helperMissing=helpers.helperMissing, buffer = "<div class=\"toggle-content\">\n";
|
var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, blockHelperMissing=helpers.blockHelperMissing, buffer = "";
|
||||||
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}));
|
stack1 = ((helper = (helper = helpers.toggle || (depth0 != null ? depth0.toggle : depth0)) != null ? helper : helperMissing),(options={"name":"toggle","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}),(typeof helper === functionType ? helper.call(depth0, options) : helper));
|
||||||
|
if (!helpers.toggle) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
return buffer + " </div>\n</div>\n";
|
return buffer;
|
||||||
},"useData":true});
|
},"useData":true});
|
||||||
templates['user'] = template({"1":function(depth0,helpers,partials,data) {
|
templates['user'] = template({"1":function(depth0,helpers,partials,data) {
|
||||||
var stack1, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
var stack1, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
||||||
|
@ -11,11 +11,14 @@
|
|||||||
<span class="text">
|
<span class="text">
|
||||||
<em class="type">{{type}}</em>
|
<em class="type">{{type}}</em>
|
||||||
{{#equal type "toggle"}}
|
{{#equal type "toggle"}}
|
||||||
<div class="force-newline">
|
<div class="force-newline">
|
||||||
<button id="toggle-{{id}}" class="toggle-button">···</button>
|
<button id="toggle-{{id}}" class="toggle-button">···</button>
|
||||||
</div>
|
</div>
|
||||||
|
{{#if toggle}}
|
||||||
|
{{partial "toggle"}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{{parse text}}}
|
{{{parse text}}}
|
||||||
{{/equal}}
|
{{/equal}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{{#toggle}}
|
||||||
<div class="toggle-content">
|
<div class="toggle-content">
|
||||||
{{#equal type "image"}}
|
{{#equal type "image"}}
|
||||||
<a href="{{link}}" target="_blank">
|
<a href="{{link}}" target="_blank">
|
||||||
@ -13,3 +14,4 @@
|
|||||||
{{/equal}}
|
{{/equal}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{/toggle}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "shout",
|
"name": "shout",
|
||||||
"description": "The self-hosted web IRC client",
|
"description": "The self-hosted web IRC client",
|
||||||
"version": "0.38.1",
|
"version": "0.38.2",
|
||||||
"author": "Mattias Erming",
|
"author": "Mattias Erming",
|
||||||
"preferGlobal": true,
|
"preferGlobal": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -37,42 +37,41 @@ module.exports = function(irc, network) {
|
|||||||
|
|
||||||
_.each(links, function(url) {
|
_.each(links, function(url) {
|
||||||
fetch(url, function(res) {
|
fetch(url, function(res) {
|
||||||
parse(msg.id, url, res, client);
|
parse(msg, url, res, client);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function parse(id, url, res, client) {
|
function parse(msg, url, res, client) {
|
||||||
var type = "";
|
var toggle = msg.toggle = {
|
||||||
var head = "";
|
id: msg.id,
|
||||||
var body = "";
|
type: "",
|
||||||
var link = url;
|
head: "",
|
||||||
|
body: "",
|
||||||
|
link: url
|
||||||
|
};
|
||||||
|
|
||||||
switch (res.type) {
|
switch (res.type) {
|
||||||
case "text/html":
|
case "text/html":
|
||||||
var $ = cheerio.load(res.res.text);
|
var $ = cheerio.load(res.res.text);
|
||||||
type = "link";
|
toggle.type = "link";
|
||||||
head = $("title").text();
|
toggle.head = $("title").text();
|
||||||
body = "No description found.";
|
toggle.body = "No description found.";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "image/png":
|
case "image/png":
|
||||||
case "image/gif":
|
case "image/gif":
|
||||||
case "image/jpg":
|
case "image/jpg":
|
||||||
case "image/jpeg":
|
case "image/jpeg":
|
||||||
type = "image";
|
toggle.type = "image";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.emit("toggle", {
|
|
||||||
id: id,
|
client.emit("toggle", toggle);
|
||||||
type: type,
|
|
||||||
head: head,
|
|
||||||
body: body,
|
|
||||||
link: link,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch(url, cb) {
|
function fetch(url, cb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user