render.jsView |
---|
14 | 14 … | exports.renderThread = renderThread; |
15 | 15 … | exports.renderAbout = renderAbout; |
16 | 16 … | exports.renderRssItem = renderRssItem; |
17 | 17 … | exports.wrapRss = wrapRss; |
18 | | -exports.renderRssContent = renderRssContent; |
19 | 18 … | |
20 | 19 … | function MdRenderer(opts) { |
21 | 20 … | marked.Renderer.call(this, {}); |
22 | 21 … | this.opts = opts; |
366 | 365 … | "</article>" |
367 | 366 … | ); |
368 | 367 … | } |
369 | 368 … | |
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 | | - |
404 | | - } |
405 | | - else if (c.type == "about") { |
406 | | - |
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 | | - |
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 | | - |
432 | 369 … | function renderRss(opts, msg) { |
433 | 370 … | var c = msg.value.content || {}; |
434 | 371 … | var name = encodeURIComponent(msg.key); |
435 | 372 … | |
436 | | - let content = renderRssContent(opts, c); |
| 373 … | + let content = render(opts, c); |
437 | 374 … | |
|
438 | 375 … | if (!content) { |
439 | 376 … | return null; |
440 | 377 … | } |
441 | 378 … | |
442 | 379 … | return ( |
443 | 380 … | '<item>' + |
444 | | - '<title>' + msg.author.name + ' - ' + escape(content.substring(0, 25)) + '... </title>' + |
| 381 … | + '<title>' + msg.author.name + ' | ' + c.type + '</title>' + |
445 | 382 … | '<description><![CDATA[' + content + ']]></description>' + |
446 | 383 … | '<link>' + opts.base + escape(name) + '</link>' + |
447 | 384 … | '<pubDate>' + new Date(msg.value.timestamp).toUTCString() + '</pubDate>' + |
448 | 385 … | '<guid>' + msg.key + '</guid>' + |