Merge remote-tracking branch 'origin/hyperscript'
This commit is contained in:
@@ -173,7 +173,7 @@ exports.init = function (sbot, config) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
serveFeeds(req, res, following, channelSubscriptions, feedId, 'user feed ' + about.name)
|
serveFeeds(req, res, following, channelSubscriptions, feedId, 'user feed ' + (about ? about.name : ""))
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -225,7 +225,7 @@ exports.init = function (sbot, config) {
|
|||||||
pull.values(logs),
|
pull.values(logs),
|
||||||
paramap(addAuthorAbout, 8),
|
paramap(addAuthorAbout, 8),
|
||||||
paramap(addVoteMessage, 8),
|
paramap(addVoteMessage, 8),
|
||||||
pull(renderThread(defaultOpts,
|
pull(renderThread(defaultOpts, '',
|
||||||
renderShowAll(showAll, req.url)),
|
renderShowAll(showAll, req.url)),
|
||||||
wrapPage('#' + channelId)),
|
wrapPage('#' + channelId)),
|
||||||
toPull(res, function (err) {
|
toPull(res, function (err) {
|
||||||
|
|||||||
@@ -43,11 +43,17 @@ MdRenderer.prototype.urltransform = function(href) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MdRenderer.prototype.image = function(href, title, text) {
|
MdRenderer.prototype.image = function(href, title, text) {
|
||||||
return h('img',
|
if (text.endsWith(".svg"))
|
||||||
{ src: this.opts.img_base + href,
|
return h('object',
|
||||||
alt: text,
|
{ type: 'image/svg+xml',
|
||||||
title: title
|
data: href,
|
||||||
}).outerHTML;
|
alt: text }).outerHTML;
|
||||||
|
else
|
||||||
|
return h('img',
|
||||||
|
{ src: this.opts.img_base + href,
|
||||||
|
alt: text,
|
||||||
|
title: title
|
||||||
|
}).outerHTML;
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderEmoji(emoji) {
|
function renderEmoji(emoji) {
|
||||||
@@ -77,7 +83,7 @@ function escape(str) {
|
|||||||
function formatMsgs(id, ext, opts) {
|
function formatMsgs(id, ext, opts) {
|
||||||
switch (ext || "html") {
|
switch (ext || "html") {
|
||||||
case "html":
|
case "html":
|
||||||
return pull(renderThread(opts), wrapPage(id));
|
return pull(renderThread(opts, id, ''), wrapPage(id));
|
||||||
case "js":
|
case "js":
|
||||||
return pull(renderThread(opts), wrapJSEmbed(opts));
|
return pull(renderThread(opts), wrapJSEmbed(opts));
|
||||||
case "json":
|
case "json":
|
||||||
@@ -114,15 +120,14 @@ function renderAbout(opts, about, showAllHTML = "") {
|
|||||||
(about.description != undefined ?
|
(about.description != undefined ?
|
||||||
marked(about.description, opts.marked) : '');
|
marked(about.description, opts.marked) : '');
|
||||||
return pull(
|
return pull(
|
||||||
pull.map(renderMsg.bind(this, opts)),
|
pull.map(renderMsg.bind(this, opts, '')),
|
||||||
wrap(toolTipTop() + '<main>' +
|
wrap(toolTipTop() + '<main>' +
|
||||||
h('article',
|
h('article',
|
||||||
h('header',
|
h('header',
|
||||||
h('figure',
|
h('figure',
|
||||||
h('img',
|
h('img',
|
||||||
{ src: opts.img_base + about.image,
|
{ src: opts.img_base + about.image,
|
||||||
height: 200,
|
style: 'max-height: 200px; max-width: 200px;'
|
||||||
width: 200
|
|
||||||
}),
|
}),
|
||||||
figCaption)
|
figCaption)
|
||||||
)).outerHTML,
|
)).outerHTML,
|
||||||
@@ -130,9 +135,9 @@ function renderAbout(opts, about, showAllHTML = "") {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderThread(opts, showAllHTML = "") {
|
function renderThread(opts, id, showAllHTML = "") {
|
||||||
return pull(
|
return pull(
|
||||||
pull.map(renderMsg.bind(this, opts)),
|
pull.map(renderMsg.bind(this, opts, id)),
|
||||||
wrap(toolTipTop() + '<main>',
|
wrap(toolTipTop() + '<main>',
|
||||||
showAllHTML + '</main>' + callToAction())
|
showAllHTML + '</main>' + callToAction())
|
||||||
);
|
);
|
||||||
@@ -333,7 +338,7 @@ function docWrite(str) {
|
|||||||
return "document.write(" + JSON.stringify(str) + ")\n";
|
return "document.write(" + JSON.stringify(str) + ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMsg(opts, msg) {
|
function renderMsg(opts, id, msg) {
|
||||||
var c = msg.value.content || {};
|
var c = msg.value.content || {};
|
||||||
var name = encodeURIComponent(msg.key);
|
var name = encodeURIComponent(msg.key);
|
||||||
return h('article#' + name,
|
return h('article#' + name,
|
||||||
@@ -347,7 +352,7 @@ function renderMsg(opts, msg) {
|
|||||||
{ href: opts.base + escape(msg.value.author) },
|
{ href: opts.base + escape(msg.value.author) },
|
||||||
msg.author.name),
|
msg.author.name),
|
||||||
msgTimestamp(msg, opts.base + name)))),
|
msgTimestamp(msg, opts.base + name)))),
|
||||||
render(opts, c)).outerHTML;
|
render(opts, id, c)).outerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderRss(opts, msg) {
|
function renderRss(opts, msg) {
|
||||||
@@ -387,7 +392,7 @@ function formatDate(date) {
|
|||||||
return htime(date);
|
return htime(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
function render(opts, c) {
|
function render(opts, id, c) {
|
||||||
var base = opts.base;
|
var base = opts.base;
|
||||||
if (c.type === "post") {
|
if (c.type === "post") {
|
||||||
var channel = c.channel
|
var channel = c.channel
|
||||||
@@ -396,7 +401,7 @@ function render(opts, c) {
|
|||||||
{ href: base + 'channel/' + c.channel },
|
{ href: base + 'channel/' + c.channel },
|
||||||
'#' + c.channel))
|
'#' + c.channel))
|
||||||
: "";
|
: "";
|
||||||
return [channel, renderPost(opts, c)];
|
return [channel, renderPost(opts, id, c)];
|
||||||
} else if (c.type == "vote" && c.vote.expression == "Dig") {
|
} else if (c.type == "vote" && c.vote.expression == "Dig") {
|
||||||
var channel = c.channel
|
var channel = c.channel
|
||||||
? [' in ',
|
? [' in ',
|
||||||
@@ -443,15 +448,20 @@ function render(opts, c) {
|
|||||||
return [h('span.status',
|
return [h('span.status',
|
||||||
"Created a git issue" +
|
"Created a git issue" +
|
||||||
(c.repoName != undefined ? " in repo " + c.repoName : ""),
|
(c.repoName != undefined ? " in repo " + c.repoName : ""),
|
||||||
renderPost(opts, c))];
|
renderPost(opts, id, c))];
|
||||||
|
}
|
||||||
|
else if (c.type == "git-repo") {
|
||||||
|
return h('span.status',
|
||||||
|
"Created a git repo " + c.name);
|
||||||
}
|
}
|
||||||
else if (c.type == "git-update") {
|
else if (c.type == "git-update") {
|
||||||
return h('span.status',
|
var s = h('span.status');
|
||||||
"Did a git update " +
|
s.innerHTML = "Did a git update " +
|
||||||
(c.repoName != undefined ? " in repo " + c.repoName : "") +
|
(c.repoName != undefined ? " in repo " + c.repoName : "") +
|
||||||
'<br>' +
|
'<br>' +
|
||||||
(c.commits != undefined ?
|
(c.commits != undefined ?
|
||||||
c.commits.map(com => { return "-" +com.title; }).join('<br>') : ""));
|
c.commits.map(com => { return "-" +com.title; }).join('<br>') : "");
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
else if (c.type == "ssb-dns") {
|
else if (c.type == "ssb-dns") {
|
||||||
return [h('span.status', 'Updated DNS'), renderDefault(c)];
|
return [h('span.status', 'Updated DNS'), renderDefault(c)];
|
||||||
@@ -474,7 +484,7 @@ function render(opts, c) {
|
|||||||
else return renderDefault(c);
|
else return renderDefault(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPost(opts, c) {
|
function renderPost(opts, id, c) {
|
||||||
opts.mentions = {};
|
opts.mentions = {};
|
||||||
if (Array.isArray(c.mentions)) {
|
if (Array.isArray(c.mentions)) {
|
||||||
c.mentions.forEach(function (link) {
|
c.mentions.forEach(function (link) {
|
||||||
@@ -483,7 +493,12 @@ function renderPost(opts, c) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
var s = h('section');
|
var s = h('section');
|
||||||
s.innerHTML = marked(String(c.text), opts.marked);
|
var content = '';
|
||||||
|
if (c.root && c.root != id)
|
||||||
|
content += 'Re: ' + h('a',
|
||||||
|
{ href: '/' + encodeURIComponent(c.root) },
|
||||||
|
c.root.substring(0, 10)).outerHTML + '<br>';
|
||||||
|
s.innerHTML = content + marked(String(c.text), opts.marked);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user