From ac8c79fc2f80a89eb227579ffed0be3cf2dcab65 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Fri, 23 Jun 2017 21:33:44 +0200 Subject: [PATCH 1/6] Fix git update rendering --- render.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/render.js b/render.js index ca4a466..2a5502c 100644 --- a/render.js +++ b/render.js @@ -402,12 +402,13 @@ function render(opts, c) { renderPost(opts, c))]; } else if (c.type == "git-update") { - return h('span.status', - "Did a git update " + - (c.repoName != undefined ? " in repo " + c.repoName : "") + - '
' + - (c.commits != undefined ? - c.commits.map(com => { return "-" +com.title; }).join('
') : "")); + var s = h('span.status'); + s.innerHTML = "Did a git update " + + (c.repoName != undefined ? " in repo " + c.repoName : "") + + '
' + + (c.commits != undefined ? + c.commits.map(com => { return "-" +com.title; }).join('
') : ""); + return s; } else if (c.type == "ssb-dns") { return [h('span.status', 'Updated DNS'), renderDefault(c)]; From 336a39d74fbef28c1b1f707863fb872bcc447a6c Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Fri, 23 Jun 2017 21:37:22 +0200 Subject: [PATCH 2/6] render git repo creation --- render.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/render.js b/render.js index 2a5502c..353f087 100644 --- a/render.js +++ b/render.js @@ -401,6 +401,10 @@ function render(opts, c) { (c.repoName != undefined ? " in repo " + c.repoName : ""), renderPost(opts, c))]; } + else if (c.type == "git-repo") { + return h('span.status', + "Created a git repo " + c.name); + } else if (c.type == "git-update") { var s = h('span.status'); s.innerHTML = "Did a git update " + From b2c03954f07ab2baee3e4a7390bb6bcffe2c6df3 Mon Sep 17 00:00:00 2001 From: Ev Bogue Date: Sat, 24 Jun 2017 16:44:46 -0400 Subject: [PATCH 3/6] Merge: add thread links to posts that have a root And don't render them when rendering the thread --- index.js | 2 +- render.js | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 6db10b7..f59e668 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/render.js b/render.js index 353f087..c4291f5 100644 --- a/render.js +++ b/render.js @@ -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() + '
' + 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() + '
', showAllHTML + '
' + 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 + '
'; + s.innerHTML = content + marked(String(c.text), opts.marked); return s; } From c1d19776608f9708e1117f5c8feb7446d5942c09 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Thu, 29 Jun 2017 21:37:25 +0200 Subject: [PATCH 4/6] Don't die in invalid user-feed link --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f59e668..b332905 100644 --- a/index.js +++ b/index.js @@ -158,7 +158,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 : "")) }) ) }) From d6e3e6a468d96496d2bc2c9f4e092864723d88d2 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Thu, 29 Jun 2017 21:57:42 +0200 Subject: [PATCH 5/6] Better image sizing on profiles --- render.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/render.js b/render.js index c4291f5..b24b9ee 100644 --- a/render.js +++ b/render.js @@ -117,8 +117,7 @@ function renderAbout(opts, about, showAllHTML = "") { h('figure', h('img', { src: opts.img_base + about.image, - height: 200, - width: 200 + style: 'max-height: 200px; max-width: 200px;' }), figCaption) )).outerHTML, From ccc712bad78a439c6287c829554052b9cd943a4b Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Fri, 7 Jul 2017 22:27:14 +0200 Subject: [PATCH 6/6] render svg --- render.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/render.js b/render.js index b24b9ee..75ba668 100644 --- a/render.js +++ b/render.js @@ -41,11 +41,17 @@ MdRenderer.prototype.urltransform = function(href) { }; MdRenderer.prototype.image = function(href, title, text) { - return h('img', - { src: this.opts.img_base + href, - alt: text, - title: title - }).outerHTML; + if (text.endsWith(".svg")) + return h('object', + { type: 'image/svg+xml', + data: href, + alt: text }).outerHTML; + else + return h('img', + { src: this.opts.img_base + href, + alt: text, + title: title + }).outerHTML; }; function renderEmoji(emoji) {