Compare commits

...

4 Commits

Author SHA1 Message Date
Ariadne Conill 2c3644f561 attachment: implement optional blur + internationalized text for sensitive content 2019-09-27 00:22:11 +00:00
Ariadne Conill f6cb0e82fc attachment: make hide string translatable 2019-09-27 00:21:34 +00:00
Ariadne Conill 8ee23a4ff6 blah 2019-09-26 23:13:30 +00:00
Ariadne Conill e6abf4676d configuration: add nsfwUseBlur setting 2019-09-26 23:06:14 +00:00
7 changed files with 59 additions and 4 deletions

View File

@ -74,6 +74,9 @@ Enables [PushAPI](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) - b
### `nsfwCensorImage` ### `nsfwCensorImage`
Use custom image for NSFW'd images Use custom image for NSFW'd images
### `nsfwUseBlur`
Use blur effect instead of placeholder image for NSFW images
### `showFeaturesPanel` ### `showFeaturesPanel`
Show panel showcasing instance features/settings to logged-out visitors Show panel showcasing instance features/settings to logged-out visitors

View File

@ -75,6 +75,7 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
} }
copyInstanceOption('nsfwCensorImage') copyInstanceOption('nsfwCensorImage')
copyInstanceOption('nsfwUseBlur')
copyInstanceOption('background') copyInstanceOption('background')
copyInstanceOption('hidePostStats') copyInstanceOption('hidePostStats')
copyInstanceOption('hideUserStats') copyInstanceOption('hideUserStats')

View File

@ -17,6 +17,7 @@ const Attachment = {
nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage, nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage,
hideNsfwLocal: this.$store.state.config.hideNsfw, hideNsfwLocal: this.$store.state.config.hideNsfw,
preloadImage: this.$store.state.config.preloadImage, preloadImage: this.$store.state.config.preloadImage,
nsfwUseBlur: this.$store.state.instance.nsfwUseBlur,
loading: false, loading: false,
img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'), img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'),
modalOpen: false, modalOpen: false,

View File

@ -24,12 +24,31 @@
:href="attachment.url" :href="attachment.url"
@click.prevent="toggleHidden" @click.prevent="toggleHidden"
> >
<div v-if="nsfwUseBlur && type !== 'video'" class="centered-hider">
<a href="#">
{{$t('general.sensitive')}}<br><small>{{$t('general.sensitive_hint')}}</small>
</a>
</div>
<img <img
v-if="!nsfwUseBlur"
:key="nsfwImage" :key="nsfwImage"
class="nsfw" class="nsfw"
:src="nsfwImage" :src="nsfwImage"
:class="{'small': isSmall}" :class="{'small': isSmall}"
> >
<StillImage
v-else-if="type === 'image' || attachment.large_thumb_url"
class="nsfw-blur"
:referrerpolicy="referrerpolicy"
:mimetype="attachment.mimetype"
:src="attachment.large_thumb_url || attachment.url"
/>
<VideoAttachment
v-else-if="type === 'video'"
class="video nsfw-blur"
:attachment="attachment"
:controls="allowPlay"
/>
<i <i
v-if="type === 'video'" v-if="type === 'video'"
class="play-icon icon-play-circled" class="play-icon icon-play-circled"
@ -42,13 +61,13 @@
<a <a
href="#" href="#"
@click.prevent="toggleHidden" @click.prevent="toggleHidden"
>Hide</a> >{{$t('general.hide')}}</a>
</div> </div>
<a <a
v-if="type === 'image' && (!hidden || preloadImage)" v-if="type === 'image' && (!hidden || preloadImage)"
class="image-attachment" class="image-attachment"
:class="{'hidden': hidden && preloadImage }" :class="{'hidden': hidden && preloadImage && !nsfwUseBlur}"
:href="attachment.url" :href="attachment.url"
target="_blank" target="_blank"
:title="attachment.description" :title="attachment.description"
@ -226,6 +245,28 @@
border-radius: var(--tooltipRadius, $fallback--tooltipRadius); border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
} }
.centered-hider {
position: absolute;
width: 14em;
height: 2em;
top: calc(50% - 1em);
left: calc(50% - 7em);
text-align: center;
white-space: nowrap;
margin: auto;
padding: 5px;
background: rgba(230,230,230,0.6);
font-weight: bold;
z-index: 4;
line-height: 1;
border-radius: $fallback--tooltipRadius;
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
}
.hider a, .centered-hider a {
color: rgba(25,25,25,1.0);
}
video { video {
z-index: 0; z-index: 0;
} }
@ -286,6 +327,10 @@
height: 100%; height: 100%;
} }
.nsfw-blur {
filter: blur(3.0rem);
}
img { img {
image-orientation: from-image; // NOTE: only FF supports this image-orientation: from-image; // NOTE: only FF supports this
} }

View File

@ -31,7 +31,10 @@
"disable": "Disable", "disable": "Disable",
"enable": "Enable", "enable": "Enable",
"confirm": "Confirm", "confirm": "Confirm",
"verify": "Verify" "verify": "Verify",
"sensitive": "Sensitive content",
"sensitive_hint": "Click to show",
"hide": "Hide"
}, },
"image_cropper": { "image_cropper": {
"crop_picture": "Crop picture", "crop_picture": "Crop picture",

View File

@ -27,6 +27,7 @@ const defaultState = {
subjectLineBehavior: 'email', subjectLineBehavior: 'email',
postContentType: 'text/plain', postContentType: 'text/plain',
nsfwCensorImage: undefined, nsfwCensorImage: undefined,
nsfwUseBlur: false,
vapidPublicKey: undefined, vapidPublicKey: undefined,
noAttachmentLinks: false, noAttachmentLinks: false,
showFeaturesPanel: true, showFeaturesPanel: true,

View File

@ -19,5 +19,6 @@
"noAttachmentLinks": false, "noAttachmentLinks": false,
"nsfwCensorImage": "", "nsfwCensorImage": "",
"showFeaturesPanel": true, "showFeaturesPanel": true,
"minimalScopesMode": false "minimalScopesMode": false,
"nsfwUseBlur": false
} }