Add option to hide attachments

This commit is contained in:
r 2020-04-25 09:35:18 +00:00
parent 1e750f89b1
commit f380371654
6 changed files with 43 additions and 16 deletions

View File

@ -4,6 +4,7 @@ type Settings struct {
DefaultVisibility string `json:"default_visibility"`
CopyScope bool `json:"copy_scope"`
ThreadInNewTab bool `json:"thread_in_new_tab"`
HideAttachments bool `json:"hide_attachments"`
MaskNSFW bool `json:"mask_nfsw"`
AutoRefreshNotifications bool `json:"auto_refresh_notifications"`
FluorideMode bool `json:"fluoride_mode"`
@ -15,6 +16,7 @@ func NewSettings() *Settings {
DefaultVisibility: "public",
CopyScope: true,
ThreadInNewTab: false,
HideAttachments: false,
MaskNSFW: true,
AutoRefreshNotifications: false,
FluorideMode: false,

View File

@ -6,12 +6,13 @@ import (
)
type Context struct {
MaskNSFW bool
FluorideMode bool
ThreadInNewTab bool
DarkMode bool
CSRFToken string
UserID string
HideAttachments bool
MaskNSFW bool
FluorideMode bool
ThreadInNewTab bool
DarkMode bool
CSRFToken string
UserID string
}
type NavData struct {

View File

@ -107,12 +107,13 @@ func getRendererContext(c *model.Client) *renderer.Context {
settings = *model.NewSettings()
}
return &renderer.Context{
MaskNSFW: settings.MaskNSFW,
ThreadInNewTab: settings.ThreadInNewTab,
FluorideMode: settings.FluorideMode,
DarkMode: settings.DarkMode,
CSRFToken: session.CSRFToken,
UserID: session.UserID,
HideAttachments: settings.HideAttachments,
MaskNSFW: settings.MaskNSFW,
ThreadInNewTab: settings.ThreadInNewTab,
FluorideMode: settings.FluorideMode,
DarkMode: settings.DarkMode,
CSRFToken: session.CSRFToken,
UserID: session.UserID,
}
}

View File

@ -615,6 +615,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
visibility := req.FormValue("visibility")
copyScope := req.FormValue("copy_scope") == "true"
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
hideAttachments := req.FormValue("hide_attachments") == "true"
maskNSFW := req.FormValue("mask_nsfw") == "true"
arn := req.FormValue("auto_refresh_notifications") == "true"
fluorideMode := req.FormValue("fluoride_mode") == "true"
@ -624,6 +625,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
DefaultVisibility: visibility,
CopyScope: copyScope,
ThreadInNewTab: threadInNewTab,
HideAttachments: hideAttachments,
MaskNSFW: maskNSFW,
AutoRefreshNotifications: arn,
FluorideMode: fluorideMode,

View File

@ -21,6 +21,10 @@
<input id="thread-tab" name="thread_in_new_tab" type="checkbox" value="true" {{if .Settings.ThreadInNewTab}}checked{{end}}>
<label for="thread-tab"> Open threads in new tab from timeline </label>
</div>
<div class="settings-form-field">
<input id="hide-attachments" name="hide_attachments" type="checkbox" value="true" {{if .Settings.HideAttachments}}checked{{end}}>
<label for="hide-attachments"> Hide attachments </label>
</div>
<div class="settings-form-field">
<input id="mask-nsfw" name="mask_nsfw" type="checkbox" value="true" {{if .Settings.MaskNSFW}}checked{{end}}>
<label for="mask-nsfw"> Mask NSFW attachments </label>

View File

@ -75,31 +75,48 @@
{{end}}
<div class="status-media-container">
{{range .MediaAttachments}}
{{if eq .Type "image"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank"> [image] </a>
{{else}}
<a class="img-link" href="{{.URL}}" target="_blank">
<img class="status-image" src="{{.URL}}" alt="status-image" />
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</a>
{{end}}
{{else if eq .Type "audio"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank"> [audio] </a>
{{else}}
<audio class="status-audio" controls preload="none">
<source src="{{.URL}}">
<p> Your browser doesn't support HTML5 audio </p>
<a href="{{.URL}}" target="_blank"> [audio] </a>
</audio>
{{end}}
{{else if eq .Type "video"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank"> [video] </a>
{{else}}
<div class="status-video-container">
<video class="status-video" controls preload="none">
<source src="{{.URL}}">
<p> Your browser doesn't support HTML5 video </p>
<a href="{{.URL}}" target="_blank"> [video] </a>
</video>
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</div>
{{else}}
<a href="{{.URL}}" target="_blank"> attachment </a>
{{end}}
{{else}}
<a href="{{.URL}}" target="_blank"> [attachment] </a>
{{end}}
{{end}}
</div>
{{if .Poll}}