Merge: add thread links to posts that have a root
And don't render them when rendering the thread
This commit is contained in:
committed by
Anders Rune Jensen
parent
336a39d74f
commit
b2c03954f0
@@ -210,7 +210,7 @@ exports.init = function (sbot, config) {
|
||||
pull.values(logs),
|
||||
paramap(addAuthorAbout, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
pull(renderThread(defaultOpts,
|
||||
pull(renderThread(defaultOpts, '',
|
||||
renderShowAll(showAll, req.url)),
|
||||
wrapPage('#' + channelId)),
|
||||
toPull(res, function (err) {
|
||||
|
||||
@@ -75,7 +75,7 @@ function escape(str) {
|
||||
function formatMsgs(id, ext, opts) {
|
||||
switch (ext || "html") {
|
||||
case "html":
|
||||
return pull(renderThread(opts), wrapPage(id));
|
||||
return pull(renderThread(opts, id, ''), wrapPage(id));
|
||||
case "js":
|
||||
return pull(renderThread(opts), wrapJSEmbed(opts));
|
||||
case "json":
|
||||
@@ -110,7 +110,7 @@ function renderAbout(opts, about, showAllHTML = "") {
|
||||
(about.description != undefined ?
|
||||
marked(about.description, opts.marked) : '');
|
||||
return pull(
|
||||
pull.map(renderMsg.bind(this, opts)),
|
||||
pull.map(renderMsg.bind(this, opts, '')),
|
||||
wrap(toolTipTop() + '<main>' +
|
||||
h('article',
|
||||
h('header',
|
||||
@@ -126,9 +126,9 @@ function renderAbout(opts, about, showAllHTML = "") {
|
||||
);
|
||||
}
|
||||
|
||||
function renderThread(opts, showAllHTML = "") {
|
||||
function renderThread(opts, id, showAllHTML = "") {
|
||||
return pull(
|
||||
pull.map(renderMsg.bind(this, opts)),
|
||||
pull.map(renderMsg.bind(this, opts, id)),
|
||||
wrap(toolTipTop() + '<main>',
|
||||
showAllHTML + '</main>' + callToAction())
|
||||
);
|
||||
@@ -311,7 +311,7 @@ function docWrite(str) {
|
||||
return "document.write(" + JSON.stringify(str) + ")\n";
|
||||
}
|
||||
|
||||
function renderMsg(opts, msg) {
|
||||
function renderMsg(opts, id, msg) {
|
||||
var c = msg.value.content || {};
|
||||
var name = encodeURIComponent(msg.key);
|
||||
return h('article#' + name,
|
||||
@@ -325,7 +325,7 @@ function renderMsg(opts, msg) {
|
||||
{ href: opts.base + escape(msg.value.author) },
|
||||
msg.author.name),
|
||||
msgTimestamp(msg, opts.base + name)))),
|
||||
render(opts, c)).outerHTML;
|
||||
render(opts, id, c)).outerHTML;
|
||||
}
|
||||
|
||||
function msgTimestamp(msg, link) {
|
||||
@@ -343,7 +343,7 @@ function formatDate(date) {
|
||||
return htime(date);
|
||||
}
|
||||
|
||||
function render(opts, c) {
|
||||
function render(opts, id, c) {
|
||||
var base = opts.base;
|
||||
if (c.type === "post") {
|
||||
var channel = c.channel
|
||||
@@ -352,7 +352,7 @@ function render(opts, c) {
|
||||
{ href: base + '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") {
|
||||
var channel = c.channel
|
||||
? [' in ',
|
||||
@@ -399,7 +399,7 @@ function render(opts, c) {
|
||||
return [h('span.status',
|
||||
"Created a git issue" +
|
||||
(c.repoName != undefined ? " in repo " + c.repoName : ""),
|
||||
renderPost(opts, c))];
|
||||
renderPost(opts, id, c))];
|
||||
}
|
||||
else if (c.type == "git-repo") {
|
||||
return h('span.status',
|
||||
@@ -435,7 +435,7 @@ function render(opts, c) {
|
||||
else return renderDefault(c);
|
||||
}
|
||||
|
||||
function renderPost(opts, c) {
|
||||
function renderPost(opts, id, c) {
|
||||
opts.mentions = {};
|
||||
if (Array.isArray(c.mentions)) {
|
||||
c.mentions.forEach(function (link) {
|
||||
@@ -444,7 +444,12 @@ function renderPost(opts, c) {
|
||||
});
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user