git ssb

9+

cel / ssb-viewer



Commit ca9ab26ec6f4f060a9ef89bec77537aa46a99707

Show content warnings

cel committed on 8/29/2019, 8:10:59 PM
Parent: 332c09b046eddbc3f31c2105251afcf185d868b0

Files changed

index.jschanged
render.jschanged
index.jsView
@@ -341,8 +341,9 @@
341341 })
342342 pull(
343343 pull.values(sort(links)),
344344 paramap(addAuthorAbout, 8),
345 + paramap(addVoteMessage, 8),
345346 paramap(addBlog, 8),
346347 paramap(addGatheringAbout, 8),
347348 format,
348349 toPull(res, function (err) {
@@ -382,10 +383,13 @@
382383
383384 function addVoteMessage(msg, cb) {
384385 if (msg.value.content.type == 'vote' && msg.value.content.vote && msg.value.content.vote.link[0] == '%')
385386 getMsg(msg.value.content.vote.link, function (err, linkedMsg) {
387 + var linkedC = linkedMsg && linkedMsg.value.content
386388 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
388392 cb(null, msg)
389393 })
390394 else
391395 cb(null, msg)
render.jsView
@@ -577,9 +577,16 @@
577577 if (c.root && c.root != id)
578578 content += 'Re: ' + h('a',
579579 { href: '/' + encodeURIComponent(c.root) },
580580 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
582589 return s
583590 }
584591
585592 function renderDefault(c) {

Built with git-ssb-web