Commit ca9ab26ec6f4f060a9ef89bec77537aa46a99707
Show content warnings
cel committed on 8/29/2019, 8:10:59 PMParent: 332c09b046eddbc3f31c2105251afcf185d868b0
Files changed
index.js | changed |
render.js | changed |
index.js | ||
---|---|---|
@@ -341,8 +341,9 @@ | ||
341 | 341 | }) |
342 | 342 | pull( |
343 | 343 | pull.values(sort(links)), |
344 | 344 | paramap(addAuthorAbout, 8), |
345 | + paramap(addVoteMessage, 8), | |
345 | 346 | paramap(addBlog, 8), |
346 | 347 | paramap(addGatheringAbout, 8), |
347 | 348 | format, |
348 | 349 | toPull(res, function (err) { |
@@ -382,10 +383,13 @@ | ||
382 | 383 | |
383 | 384 | function addVoteMessage(msg, cb) { |
384 | 385 | if (msg.value.content.type == 'vote' && msg.value.content.vote && msg.value.content.vote.link[0] == '%') |
385 | 386 | getMsg(msg.value.content.vote.link, function (err, linkedMsg) { |
387 | + var linkedC = linkedMsg && linkedMsg.value.content | |
386 | 388 | if (linkedMsg) |
387 | - msg.value.content.vote.linkedText = linkedMsg.value.content.text | |
389 | + msg.value.content.vote.linkedText = | |
390 | + (typeof linkedC.contentWarning === 'string' ? '[CW: ' + linkedC.contentWarning + '] ' : '') + | |
391 | + linkedC.text | |
388 | 392 | cb(null, msg) |
389 | 393 | }) |
390 | 394 | else |
391 | 395 | cb(null, msg) |
render.js | ||
---|---|---|
@@ -577,9 +577,16 @@ | ||
577 | 577 | if (c.root && c.root != id) |
578 | 578 | content += 'Re: ' + h('a', |
579 | 579 | { href: '/' + encodeURIComponent(c.root) }, |
580 | 580 | c.root.substring(0, 10)).outerHTML + '<br>' |
581 | - s.innerHTML = content + marked(String(c.text), opts.marked) | |
581 | + var textHTML = marked(String(c.text), opts.marked) | |
582 | + if (typeof c.contentWarning === 'string') { | |
583 | + textHTML = h('details', | |
584 | + h('summary', 'Content warning: ' + c.contentWarning), | |
585 | + h('div', {innerHTML: textHTML}) | |
586 | + ).outerHTML | |
587 | + } | |
588 | + s.innerHTML = content + textHTML | |
582 | 589 | return s |
583 | 590 | } |
584 | 591 | |
585 | 592 | function renderDefault(c) { |
Built with git-ssb-web