Blur explicit videos + GIF auto-play option
This commit is contained in:
parent
3bc678185e
commit
a856b9d01b
|
@ -124,12 +124,17 @@ func Settings() http.HandlerFunc {
|
||||||
var (
|
var (
|
||||||
explicit = r.PostFormValue("explicit") == "true"
|
explicit = r.PostFormValue("explicit") == "true"
|
||||||
blurExplicit = r.PostFormValue("blur_explicit")
|
blurExplicit = r.PostFormValue("blur_explicit")
|
||||||
|
autoplayGif = r.PostFormValue("autoplay_gif")
|
||||||
)
|
)
|
||||||
|
|
||||||
user.Explicit = explicit
|
user.Explicit = explicit
|
||||||
|
|
||||||
// Set profile field prefs.
|
// Set profile field prefs.
|
||||||
user.SetProfileField("blur_explicit", blurExplicit)
|
user.SetProfileField("blur_explicit", blurExplicit)
|
||||||
|
if autoplayGif != "true" {
|
||||||
|
autoplayGif = "false"
|
||||||
|
}
|
||||||
|
user.SetProfileField("autoplay_gif", autoplayGif)
|
||||||
|
|
||||||
if err := user.Save(); err != nil {
|
if err := user.Save(); err != nil {
|
||||||
session.FlashError(w, r, "Failed to save user to database: %s", err)
|
session.FlashError(w, r, "Failed to save user to database: %s", err)
|
||||||
|
|
|
@ -137,5 +137,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Video tag: autoplay is disabled when blurred, onClick doesn't fire,
|
||||||
|
// set the handler for onPlay.
|
||||||
|
node.addEventListener("play", e => {
|
||||||
|
if (node.classList.contains("blurred-explicit")) {
|
||||||
|
node.classList.remove("blurred-explicit");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -491,10 +491,13 @@
|
||||||
|
|
||||||
<!-- Attached photo? -->
|
<!-- Attached photo? -->
|
||||||
{{if $Body.PhotoID}}
|
{{if $Body.PhotoID}}
|
||||||
<div class="column is-one-quarter">
|
<div class="column is-one-quarter is-clipped">
|
||||||
<!-- GIF video? -->
|
<!-- GIF video? -->
|
||||||
{{if HasSuffix $Body.Photo.Filename ".mp4"}}
|
{{if HasSuffix $Body.Photo.Filename ".mp4"}}
|
||||||
<video autoplay loop controls>
|
<video loop controls
|
||||||
|
{{if BlurExplicit $Body.Photo}}class="blurred-explicit"
|
||||||
|
{{else if (not (eq ($Root.CurrentUser.GetProfileField "autoplay_gif") "false"))}}autoplay
|
||||||
|
{{end}}>
|
||||||
<source src="{{PhotoURL $Body.Photo.Filename}}" type="video/mp4">
|
<source src="{{PhotoURL $Body.Photo.Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
<div>
|
<div>
|
||||||
|
@ -504,7 +507,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="/photo/view?id={{$Body.Photo.ID}}">
|
<a href="/photo/view?id={{$Body.Photo.ID}}">
|
||||||
<img src="{{PhotoURL $Body.Photo.Filename}}">
|
<img src="{{PhotoURL $Body.Photo.Filename}}"{{if BlurExplicit $Body.Photo}} class="blurred-explicit"{{end}}>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
|
@ -347,6 +347,20 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">Display Settings</label>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="autoplay_gif"
|
||||||
|
value="true"
|
||||||
|
{{if not (eq (.CurrentUser.GetProfileField "autoplay_gif") "false")}}checked{{end}}>
|
||||||
|
Automatically play animated GIFs
|
||||||
|
</label>
|
||||||
|
<p class="help">
|
||||||
|
Uncheck this box to disable auto-play on GIFs.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<button type="submit" class="button is-primary">
|
<button type="submit" class="button is-primary">
|
||||||
<i class="fa fa-save mr-2"></i> Save Website Preferences
|
<i class="fa fa-save mr-2"></i> Save Website Preferences
|
||||||
|
|
|
@ -271,6 +271,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
{{define "scripts"}}
|
||||||
|
|
||||||
<!-- Script for photo upload on photo boards -->
|
<!-- Script for photo upload on photo boards -->
|
||||||
{{if .Forum.PermitPhotos}}
|
{{if .Forum.PermitPhotos}}
|
||||||
|
@ -352,9 +355,6 @@
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
{{define "scripts"}}
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const { createApp } = Vue;
|
const { createApp } = Vue;
|
||||||
|
|
||||||
|
|
|
@ -403,7 +403,10 @@
|
||||||
<div class="card-image has-text-centered is-clipped">
|
<div class="card-image has-text-centered is-clipped">
|
||||||
<!-- GIF video? -->
|
<!-- GIF video? -->
|
||||||
{{if HasSuffix .Filename ".mp4"}}
|
{{if HasSuffix .Filename ".mp4"}}
|
||||||
<video autoplay loop controls>
|
<video loop controls
|
||||||
|
{{if BlurExplicit .}}class="blurred-explicit"
|
||||||
|
{{else if (not (eq ($Root.CurrentUser.GetProfileField "autoplay_gif") "false"))}}autoplay
|
||||||
|
{{end}}>
|
||||||
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -509,7 +512,10 @@
|
||||||
<div class="card-image has-text-centered is-clipped">
|
<div class="card-image has-text-centered is-clipped">
|
||||||
<!-- GIF video? -->
|
<!-- GIF video? -->
|
||||||
{{if HasSuffix .Filename ".mp4"}}
|
{{if HasSuffix .Filename ".mp4"}}
|
||||||
<video autoplay loop controls>
|
<video loop controls
|
||||||
|
{{if BlurExplicit .}}class="blurred-explicit"
|
||||||
|
{{else if (not (eq ($Root.CurrentUser.GetProfileField "autoplay_gif") "false"))}}autoplay
|
||||||
|
{{end}}>
|
||||||
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
@ -71,7 +71,10 @@
|
||||||
<div class="card-image has-text-centered is-clipped">
|
<div class="card-image has-text-centered is-clipped">
|
||||||
<!-- GIF video? -->
|
<!-- GIF video? -->
|
||||||
{{if HasSuffix .Photo.Filename ".mp4"}}
|
{{if HasSuffix .Photo.Filename ".mp4"}}
|
||||||
<video autoplay loop controls>
|
<video loop controls
|
||||||
|
{{if BlurExplicit .Photo}}class="blurred-explicit"
|
||||||
|
{{else if (not (eq ($Root.CurrentUser.GetProfileField "autoplay_gif") "false"))}}autoplay
|
||||||
|
{{end}}>
|
||||||
<source src="{{PhotoURL .Photo.Filename}}" type="video/mp4">
|
<source src="{{PhotoURL .Photo.Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user