Blur explicit photos option
This commit is contained in:
parent
6acdd22d4b
commit
50ce31f6ac
|
@ -65,7 +65,7 @@ var (
|
||||||
"hide_age",
|
"hide_age",
|
||||||
|
|
||||||
// Site prefs
|
// Site prefs
|
||||||
// "dm_privacy",
|
// "dm_privacy", "blur_explicit",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choices for the Contact Us subject
|
// Choices for the Contact Us subject
|
||||||
|
|
|
@ -123,10 +123,14 @@ func Settings() http.HandlerFunc {
|
||||||
hashtag = "#prefs"
|
hashtag = "#prefs"
|
||||||
var (
|
var (
|
||||||
explicit = r.PostFormValue("explicit") == "true"
|
explicit = r.PostFormValue("explicit") == "true"
|
||||||
|
blurExplicit = r.PostFormValue("blur_explicit")
|
||||||
)
|
)
|
||||||
|
|
||||||
user.Explicit = explicit
|
user.Explicit = explicit
|
||||||
|
|
||||||
|
// Set profile field prefs.
|
||||||
|
user.SetProfileField("blur_explicit", blurExplicit)
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,9 @@ func TemplateFuncs(r *http.Request) template.FuncMap {
|
||||||
"QueryPlus": QueryPlus(r),
|
"QueryPlus": QueryPlus(r),
|
||||||
"SimplePager": SimplePager(r),
|
"SimplePager": SimplePager(r),
|
||||||
"HasSuffix": strings.HasSuffix,
|
"HasSuffix": strings.HasSuffix,
|
||||||
|
|
||||||
|
// Test if a photo should be blurred ({{BlurExplicit .Photo}})
|
||||||
|
"BlurExplicit": BlurExplicit(r),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +84,22 @@ func InputCSRF(r *http.Request) func() template.HTML {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlurExplicit returns true if the current user has the blur_explicit setting on and the given Photo is Explicit.
|
||||||
|
func BlurExplicit(r *http.Request) func(*models.Photo) bool {
|
||||||
|
return func(photo *models.Photo) bool {
|
||||||
|
if !photo.Explicit {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
currentUser, err := session.CurrentUser(r)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentUser.GetProfileField("blur_explicit") == "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SincePrettyCoarse formats a time.Duration in plain English. Intended for "joined 2 months ago" type
|
// SincePrettyCoarse formats a time.Duration in plain English. Intended for "joined 2 months ago" type
|
||||||
// strings - returns the coarsest level of granularity.
|
// strings - returns the coarsest level of granularity.
|
||||||
func SincePrettyCoarse() func(time.Time) template.HTML {
|
func SincePrettyCoarse() func(time.Time) template.HTML {
|
||||||
|
|
|
@ -92,6 +92,11 @@ abbr {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Blurred explicit photo */
|
||||||
|
.blurred-explicit {
|
||||||
|
filter: blur(14px);
|
||||||
|
}
|
||||||
|
|
||||||
/* Bulma hack: smaller tag size inside of tab buttons. The default tag height
|
/* Bulma hack: smaller tag size inside of tab buttons. The default tag height
|
||||||
is set to 2em which makes the boxed tabs too tall and the bottom line doesn't
|
is set to 2em which makes the boxed tabs too tall and the bottom line doesn't
|
||||||
draw correctly. Seen on e.g. Profile Pages for the tag # of photos. */
|
draw correctly. Seen on e.g. Profile Pages for the tag # of photos. */
|
||||||
|
|
|
@ -126,5 +126,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// Reveal all blurred images on click.
|
||||||
|
(document.querySelectorAll(".blurred-explicit") || []).forEach(node => {
|
||||||
|
node.addEventListener("click", e => {
|
||||||
|
node.classList.remove("blurred-explicit");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<a href="/settings#prefs" class="nonshy-tab-button">
|
<a href="/settings#prefs" class="nonshy-tab-button">
|
||||||
<strong><i class="fa fa-square-check mr-1"></i> Website Preferences</strong>
|
<strong><i class="fa fa-square-check mr-1"></i> Website Preferences</strong>
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Explicit content filter. <i class="fa fa-fire"></i>
|
Explicit content filter <i class="fa fa-fire"></i>; photo blur.
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -333,6 +333,18 @@
|
||||||
include erections or sexually charged content. These may appear on the Site
|
include erections or sexually charged content. These may appear on the Site
|
||||||
Gallery as well as user profile pages.
|
Gallery as well as user profile pages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="blur_explicit"
|
||||||
|
value="true"
|
||||||
|
{{if eq (.CurrentUser.GetProfileField "blur_explicit") "true"}}checked{{end}}>
|
||||||
|
Blur explicit photos by default
|
||||||
|
</label>
|
||||||
|
<p class="help">
|
||||||
|
Explicit photos on Gallery pages will be blurred by default until clicked. Photos
|
||||||
|
on explicit Forum threads will also be blurred until clicked.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
|
@ -219,8 +219,8 @@
|
||||||
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="image mt-4">
|
<div class="mt-4 is-clipped">
|
||||||
<img src="{{PhotoURL .Filename}}">
|
<img src="{{PhotoURL .Filename}}"{{if and (or $Root.Forum.Explicit $Root.Thread.Explicit) (eq ($Root.CurrentUser.GetProfileField "blur_explicit") "true")}} class="blurred-explicit"{{end}}>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -400,14 +400,14 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="card-image has-text-centered">
|
<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 autoplay loop controls>
|
||||||
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
<source src="{{PhotoURL .Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
<img src="{{PhotoURL .Filename}}">
|
<img src="{{PhotoURL .Filename}}"{{if BlurExplicit .}} class="blurred-explicit"{{end}}>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@
|
||||||
</header>
|
</header>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<div class="card-image has-text-centered">
|
<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 autoplay loop controls>
|
||||||
|
@ -516,7 +516,7 @@
|
||||||
<a href="{{PhotoURL .Filename}}" target="_blank"
|
<a href="{{PhotoURL .Filename}}" target="_blank"
|
||||||
class="js-modal-trigger" data-target="detail-modal"
|
class="js-modal-trigger" data-target="detail-modal"
|
||||||
onclick="setModalImage(this.href)">
|
onclick="setModalImage(this.href)">
|
||||||
<img src="{{PhotoURL .Filename}}">
|
<img src="{{PhotoURL .Filename}}"{{if BlurExplicit .}} class="blurred-explicit"{{end}}>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -68,14 +68,14 @@
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="card-image has-text-centered">
|
<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 autoplay loop controls>
|
||||||
<source src="{{PhotoURL .Photo.Filename}}" type="video/mp4">
|
<source src="{{PhotoURL .Photo.Filename}}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
<img src="{{PhotoURL .Photo.Filename}}">
|
<img src="{{PhotoURL .Photo.Filename}}"{{if BlurExplicit .Photo}} class="blurred-explicit"{{end}}>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user