Merge branch 'master' of ssb://%MeCTQrz9uszf9EZoTnKCeFeIedhnKWuB3JHW2l1g9NA=.sha256 into render_rss

This commit is contained in:
Angelo DiNardi
2017-06-09 12:52:41 -07:00
2 changed files with 18 additions and 10 deletions
+3 -3
View File
@@ -184,13 +184,13 @@ exports.init = function (sbot, config) {
function serveFeeds(req, res, following, channelSubscriptions, feedId, name) {
pull(
sbot.createLogStream({ reverse: true, limit: 2500 }),
sbot.createLogStream({ reverse: true, limit: 5000 }),
pull.filter((msg) => {
return !msg.value ||
(msg.value.author in following ||
msg.value.content.channel in channelSubscriptions)
}),
pull.take(100),
pull.take(150),
pull.collect(function (err, logs) {
if (err) return respond(res, 500, err.stack || err)
res.writeHead(200, {
@@ -273,7 +273,7 @@ exports.init = function (sbot, config) {
if (format === null) return respond(res, 415, 'Invalid format')
pull(
sbot.links({dest: id, values: true, rel: 'root'}),
sbot.links({dest: id, values: true }),
includeRoot && prepend(getMsg, id),
pull.unique('key'),
pull.collect(function (err, links) {
+15 -7
View File
@@ -32,6 +32,7 @@ MdRenderer.prototype.urltransform = function(href) {
case "%":
return this.opts.msg_base + encodeURIComponent(href);
case "@":
href = this.opts.mentions[href.substr(1)] || href;
return this.opts.feed_base + encodeURIComponent(href);
case "&":
return this.opts.blob_base + encodeURIComponent(href);
@@ -56,11 +57,14 @@ MdRenderer.prototype.image = function(href, title, text) {
function renderEmoji(emoji) {
var opts = this.renderer.opts;
return emoji in emojis
var mentions = opts.mentions;
var url = mentions[emoji]
? opts.blob_base + encodeURIComponent(mentions[emoji])
: emoji in emojis && opts.emoji_base + escape(emoji) + '.png';
return url
? '<img src="' +
opts.emoji_base +
escape(emoji) +
'.png"' +
url +
'"' +
' alt=":' +
escape(emoji) +
':"' +
@@ -354,7 +358,7 @@ function renderMsg(opts, msg) {
escape(msg.value.author) +
'"' +
">" + msg.author.name + "</a>" +
msgTimestamp(msg, name) +
msgTimestamp(msg, opts.base + name) +
'</figcaption>' +
'</figure>' +
'</header>' +
@@ -446,13 +450,13 @@ function renderRss(opts, msg) {
);
}
function msgTimestamp(msg, name) {
function msgTimestamp(msg, link) {
var date = new Date(msg.value.timestamp);
var isoStr = date.toISOString();
return (
'<time class="ssb-timestamp" datetime="' + isoStr + '">' +
'<a ' +
'href="#' + name + '" ' +
'href="' + link + '" ' +
'title="' + isoStr + '" ' +
'>' + formatDate(date) + '</a>' +
'</time>'
@@ -561,6 +565,10 @@ function render(opts, c) {
}
function renderPost(opts, c) {
opts.mentions = {};
if (Array.isArray(c.mentions)) c.mentions.forEach(function (link) {
if (link && link.name && link.link) opts.mentions[link.name] = link.link;
});
return '<section>' + marked(String(c.text), opts.marked) + "</section>";
}