Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit c76136f

Browse files
authored
Merge pull request #1159 from ssbc/feature/content-warning-reading
Show content warnings and allow expand/contract
2 parents fe792f5 + e7736aa commit c76136f

File tree

14 files changed

+58
-18
lines changed

14 files changed

+58
-18
lines changed

lib/context-menu-and-spellcheck.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function setupContextMenuAndSpellCheck (config, { navigate, get }) {
8888

8989
if (ref.isBlob(extractedRef) && menuInfo.hasImageContents) {
9090
const copyEmbed = new MenuItem({
91-
label: `Copy Embed Markdown`,
91+
label: 'Copy Embed Markdown',
9292
click: () => {
9393
// Omit the mailto: portion of the link; we just want the address
9494
clipboard.writeText(`![${menuInfo.titleText}](${extractedRef})`)

lib/depject/message/html/layout/default.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,33 @@ exports.create = function (api) {
7474
classList.push('-unread')
7575
}
7676

77+
let cw = msg.value.content.contentWarning
78+
if (typeof cw !== 'string' || cw.length === 0) {
79+
cw = undefined
80+
} else {
81+
// TODO: emoji shortcodes?
82+
// TODO: truncate very long content warning, maybe use max-height?
83+
classList.push('-hasContentWarning')
84+
}
85+
7786
return h('div', {
7887
classList,
7988
hooks
8089
}, [
8190
messageHeader(msg, { replyInfo, priority }),
82-
h('section', {
91+
cw
92+
? h('a.contentWarning',
93+
{
94+
href: '#',
95+
'ev-click': toggleAndTrack(expanded)
96+
},
97+
cw
98+
)
99+
: undefined,
100+
h('section.content', {
83101
classList: [when(expanded, '-expanded')],
84102
hooks: [ExpanderHook(needsExpand)]
85-
}, [content]),
103+
}, content),
86104
computed(msg.key, (key) => {
87105
if (ref.isMsg(key)) {
88106
return h('footer', [

lib/depject/message/html/layout/mini.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ exports.create = function (api) {
7373
messageHeader(msg, {
7474
replyInfo, priority, miniContent
7575
}),
76-
h('section', {
76+
h('section.content', {
7777
classList: [when(expanded, '-expanded')],
7878
hooks: [ExpanderHook(needsExpand)]
7979
}, [content]),

lib/depject/message/html/markdown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ exports.create = function (api) {
6060
if (link && ref.isBlob(link.link)) {
6161
const url = api.blob.sync.url(link.link)
6262
const query = {}
63-
if (link.query && link.query.unbox) query['unbox'] = link.query.unbox
64-
if (typeLookup[link.link]) query['contentType'] = typeLookup[link.link]
63+
if (link.query && link.query.unbox) query.unbox = link.query.unbox
64+
if (typeLookup[link.link]) query.contentType = typeLookup[link.link]
6565
return url + '?' + querystring.stringify(query)
6666
} else if (link || id.startsWith('#') || id.startsWith('?')) {
6767
return id

lib/depject/message/html/missing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ exports.create = function (api) {
4545
])
4646
]),
4747
h('section', [
48-
h('p', [i18n(`The author of this message could be outside of your follow range or they may be blocked.`)])
48+
h('p', [i18n('The author of this message could be outside of your follow range or they may be blocked.')])
4949
])
5050
])
5151

lib/depject/message/html/render/attending.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports.create = function (api) {
2222
render: function about (msg, opts) {
2323
if (!isRenderable(msg)) return
2424

25-
const action = msg.value.content.attendee.remove ? `can't attend` : 'is attending'
25+
const action = msg.value.content.attendee.remove ? 'can\'t attend' : 'is attending'
2626
const target = msg.value.content.about
2727
const title = api.about.obs.latestValue(target, 'title')
2828
const element = api.message.html.layout(msg, extend({

lib/depject/message/html/render/gathering.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ exports.create = function (api) {
9191
h('button -attend', {
9292
disabled: computed([attending, disableActions], (...args) => args.some(Boolean)),
9393
'ev-click': send(publishAttending, msg)
94-
}, `Attending`),
94+
}, 'Attending'),
9595
h('button -attend', {
9696
disabled: disableActions,
9797
'ev-click': send(publishNotAttending, msg)
98-
}, `Can't Attend`)
98+
}, 'Can\'t Attend')
9999
])
100100
]),
101101
h('div.location', markdown(about.location)),

lib/depject/page/html/render/profile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ exports.create = function (api) {
179179

180180
when(contact.noIncoming,
181181
h('section -distanceWarning', [
182-
h('h1', i18n(`You don't follow anyone who follows this person`)),
182+
h('h1', i18n('You don\'t follow anyone who follows this person')),
183183
h('p', i18n('You might not be seeing their latest messages. You could try joining a pub that they are a member of.')),
184184
when(contact.hasOutgoing,
185185
h('p', i18n('However, since they follow someone that follows you, they should be able to see your posts.')),
186-
h('p', i18n(`They might not be able to see your posts either.`))
186+
h('p', i18n('They might not be able to see your posts either.'))
187187
)
188188
]),
189189
when(contact.noOutgoing,

lib/depject/profile/html/preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ exports.create = function (api) {
6666
]),
6767
when(contact.noIncoming,
6868
h('section -distanceWarning', [
69-
'⚠️ ', i18n(`You don't follow anyone who follows this person`)
69+
'⚠️ ', i18n('You don\'t follow anyone who follows this person')
7070
]),
7171
when(contact.mutualFriendsCount,
7272
h('section -mutualFriends', [

lib/main-window.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ module.exports = function (config) {
157157
document.head.appendChild(
158158
h('style', {
159159
innerHTML: computed(api.settings.obs.get('patchwork.theme', 'light'), themeName => {
160-
return themes[themeName] || themes['light']
160+
return themes[themeName] || themes.light
161161
})
162162
})
163163
)
@@ -170,7 +170,7 @@ module.exports = function (config) {
170170
dark: 'monokai'
171171
}
172172

173-
const syntaxTheme = syntaxThemeOptions[themeName] || syntaxThemeOptions['light']
173+
const syntaxTheme = syntaxThemeOptions[themeName] || syntaxThemeOptions.light
174174
return requireStyle(`highlight.js/styles/${syntaxTheme}.css`)
175175
})
176176
})

0 commit comments

Comments
 (0)