Show content warnings

This commit is contained in:
cel
2019-08-29 13:10:59 -07:00
parent 332c09b046
commit ca9ab26ec6
2 changed files with 13 additions and 2 deletions
+5 -1
View File
@@ -342,6 +342,7 @@ exports.init = function (sbot, config) {
pull(
pull.values(sort(links)),
paramap(addAuthorAbout, 8),
paramap(addVoteMessage, 8),
paramap(addBlog, 8),
paramap(addGatheringAbout, 8),
format,
@@ -383,8 +384,11 @@ exports.init = function (sbot, config) {
function addVoteMessage(msg, cb) {
if (msg.value.content.type == 'vote' && msg.value.content.vote && msg.value.content.vote.link[0] == '%')
getMsg(msg.value.content.vote.link, function (err, linkedMsg) {
var linkedC = linkedMsg && linkedMsg.value.content
if (linkedMsg)
msg.value.content.vote.linkedText = linkedMsg.value.content.text
msg.value.content.vote.linkedText =
(typeof linkedC.contentWarning === 'string' ? '[CW: ' + linkedC.contentWarning + '] ' : '') +
linkedC.text
cb(null, msg)
})
else
+8 -1
View File
@@ -578,7 +578,14 @@ function renderPost(opts, id, c) {
content += 'Re: ' + h('a',
{ href: '/' + encodeURIComponent(c.root) },
c.root.substring(0, 10)).outerHTML + '<br>'
s.innerHTML = content + marked(String(c.text), opts.marked)
var textHTML = marked(String(c.text), opts.marked)
if (typeof c.contentWarning === 'string') {
textHTML = h('details',
h('summary', 'Content warning: ' + c.contentWarning),
h('div', {innerHTML: textHTML})
).outerHTML
}
s.innerHTML = content + textHTML
return s
}