git ssb

9+

cel / ssb-viewer



Commit 4eee4ae72866afa2e09c9d82babd86152644119e

Stop doing special rendering for RSS items, use HTML!

I missed the part of the RSS docs that allow HTML in the description.
Angelo DiNardi committed on 6/10/2017, 6:13:40 AM
Parent: 17be3231ecbae96676b6c7a35c14740d16ca6500

Files changed

index.jschanged
render.jschanged
index.jsView
@@ -106,11 +106,8 @@
106106 switch (ext) {
107107 case 'rss':
108108 return pull(
109109 // formatMsgs(feedId, ext, defaultOpts)
110- pull.filter( (msg) => {
111- return !!renderRssContent(defaultOpts, msg.value.content || {});
112- }),
113110 renderRssItem(defaultOpts), wrapRss(about.name, defaultOpts)
114111 );
115112 default:
116113 return pull(
render.jsView
@@ -14,9 +14,8 @@
1414 exports.renderThread = renderThread;
1515 exports.renderAbout = renderAbout;
1616 exports.renderRssItem = renderRssItem;
1717 exports.wrapRss = wrapRss;
18-exports.renderRssContent = renderRssContent;
1918
2019 function MdRenderer(opts) {
2120 marked.Renderer.call(this, {});
2221 this.opts = opts;
@@ -366,83 +365,21 @@
366365 "</article>"
367366 );
368367 }
369368
370-function renderRssContent(opts, c) {
371- var base = opts.base;
372- if (c.type === "post") {
373- return (c.channel ? `Posted in #${c.channel}:\n\n` : '') + c.text;
374- } else if (c.type == "vote" && c.vote.expression == "Dig") {
375- var linkedText = "a post";
376- if (typeof c.vote.linkedText != "undefined") {
377- linkedText = c.vote.linkedText.substring(0, 75);
378- }
379-
380- return `Liked ${linkedText}`;
381- } else if (c.type == "vote") {
382- var linkedText = "a post";
383- if (typeof c.vote.linkedText != "undefined") {
384- linkedText = c.vote.linkedText.substring(0, 75);
385- }
386-
387- return `Voted ${linkedText}`;
388- } else if (c.type == "contact" && c.following) {
389- var name = c.contact;
390- if (typeof c.contactAbout != "undefined") {
391- name = c.contactAbout.name;
392- }
393-
394- return `Followed ${name}`;
395- } else if (c.type == "contact" && !c.following) {
396- var name = c.contact;
397- if (typeof c.contactAbout != "undefined") {
398- name = c.contactAbout.name;
399- }
400-
401- return `Unfollowed ${name}`;
402- } else if (typeof c == "string") {
403- // Don't show private messages in RSS.
404- }
405- else if (c.type == "about") {
406- // Don't show about messages in RSS.
407- }
408- else if (c.type == "issue") {
409- return `Created a git issue ${(c.repoName != undefined ? " in repo " + c.repoName : "")}`;
410- }
411- else if (c.type == "git-update") {
412- return `Did a git update ${(c.repoName != undefined ? " in repo " + c.repoName : "")}
413-
414- ${(c.commits != undefined ? c.commits.map(com => { return "-" +com.title; }).join("\n") : "")}
415- `;
416- }
417- else if (c.type == "ssb-dns") {
418- // Don't show for RSS.
419- }
420- else if (c.type == "pub") {
421- return `Connected to the pub ${c.address.host}`;
422- }
423- else if (c.type == "channel" && c.subscribed) {
424- return `Subscribed to channel #${c.channel}`;
425- }
426- else if (c.type == "channel" && !c.subscribed) {
427- return `Unsubscribed from channel #${c.channel}`;
428- }
429-
430-}
431-
432369 function renderRss(opts, msg) {
433370 var c = msg.value.content || {};
434371 var name = encodeURIComponent(msg.key);
435372
436- let content = renderRssContent(opts, c);
373 + let content = render(opts, c);
437374
438375 if (!content) {
439376 return null;
440377 }
441378
442379 return (
443380 '<item>' +
444- '<title>' + msg.author.name + ' - ' + escape(content.substring(0, 25)) + '... </title>' +
381 + '<title>' + msg.author.name + ' | ' + c.type + '</title>' +
445382 '<description><![CDATA[' + content + ']]></description>' +
446383 '<link>' + opts.base + escape(name) + '</link>' +
447384 '<pubDate>' + new Date(msg.value.timestamp).toUTCString() + '</pubDate>' +
448385 '<guid>' + msg.key + '</guid>' +

Built with git-ssb-web