mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-25 21:31:27 +00:00
Add option to mask nsfw attachments
This commit is contained in:
parent
9e556721c5
commit
1aff0569bf
|
@ -55,6 +55,7 @@ type Status struct {
|
||||||
ReplyMap map[string][]ReplyInfo `json:"reply_map"`
|
ReplyMap map[string][]ReplyInfo `json:"reply_map"`
|
||||||
ReplyNumber int `json:"reply_number"`
|
ReplyNumber int `json:"reply_number"`
|
||||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||||
|
MaskNSFW bool `json:"mask_nsfw"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context hold information for mastodon context.
|
// Context hold information for mastodon context.
|
||||||
|
|
|
@ -4,6 +4,7 @@ type Settings struct {
|
||||||
DefaultVisibility string `json:"default_visibility"`
|
DefaultVisibility string `json:"default_visibility"`
|
||||||
CopyScope bool `json:"copy_scope"`
|
CopyScope bool `json:"copy_scope"`
|
||||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||||
|
MaskNSFW bool `json:"mask_nfsw"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSettings() *Settings {
|
func NewSettings() *Settings {
|
||||||
|
@ -11,5 +12,6 @@ func NewSettings() *Settings {
|
||||||
DefaultVisibility: "public",
|
DefaultVisibility: "public",
|
||||||
CopyScope: true,
|
CopyScope: true,
|
||||||
ThreadInNewTab: false,
|
ThreadInNewTab: false,
|
||||||
|
MaskNSFW: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,6 +280,11 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
||||||
|
|
||||||
for i := range statuses {
|
for i := range statuses {
|
||||||
statuses[i].ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
statuses[i].ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
||||||
|
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
|
if statuses[i].Reblog != nil {
|
||||||
|
statuses[i].Reblog.ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
||||||
|
statuses[i].Reblog.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(maxID) > 0 && len(statuses) > 0 {
|
if len(maxID) > 0 && len(statuses) > 0 {
|
||||||
|
@ -394,6 +399,7 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *mo
|
||||||
for i := range statuses {
|
for i := range statuses {
|
||||||
statuses[i].ShowReplies = true
|
statuses[i].ShowReplies = true
|
||||||
statuses[i].ReplyMap = replyMap
|
statuses[i].ReplyMap = replyMap
|
||||||
|
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
addToReplyMap(replyMap, statuses[i].InReplyToID, statuses[i].ID, i+1)
|
addToReplyMap(replyMap, statuses[i].InReplyToID, statuses[i].ID, i+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,9 +440,10 @@ func (svc *service) ServeNotificationPage(ctx context.Context, client io.Writer,
|
||||||
|
|
||||||
var unreadCount int
|
var unreadCount int
|
||||||
for i := range notifications {
|
for i := range notifications {
|
||||||
switch notifications[i].Type {
|
if notifications[i].Status != nil {
|
||||||
case "reblog", "favourite":
|
notifications[i].Status.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
if notifications[i].Status != nil {
|
switch notifications[i].Type {
|
||||||
|
case "reblog", "favourite":
|
||||||
notifications[i].Status.HideAccountInfo = true
|
notifications[i].Status.HideAccountInfo = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,6 +503,13 @@ func (svc *service) ServeUserPage(ctx context.Context, client io.Writer, c *mode
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i := range statuses {
|
||||||
|
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
|
if statuses[i].Reblog != nil {
|
||||||
|
statuses[i].Reblog.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(pg.MaxID) > 0 {
|
if len(pg.MaxID) > 0 {
|
||||||
hasNext = true
|
hasNext = true
|
||||||
nextLink = "/user/" + id + "?max_id=" + pg.MaxID
|
nextLink = "/user/" + id + "?max_id=" + pg.MaxID
|
||||||
|
@ -666,7 +680,6 @@ func (svc *service) ServeFollowersPage(ctx context.Context, client io.Writer, c
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(len(followers), pg.MaxID)
|
|
||||||
if len(followers) == 20 && len(pg.MaxID) > 0 {
|
if len(followers) == 20 && len(pg.MaxID) > 0 {
|
||||||
hasNext = true
|
hasNext = true
|
||||||
nextLink = "/followers/" + id + "?max_id=" + pg.MaxID
|
nextLink = "/followers/" + id + "?max_id=" + pg.MaxID
|
||||||
|
@ -706,6 +719,10 @@ func (svc *service) ServeSearchPage(ctx context.Context, client io.Writer, c *mo
|
||||||
hasNext = len(results.Accounts) == 20
|
hasNext = len(results.Accounts) == 20
|
||||||
case "statuses":
|
case "statuses":
|
||||||
hasNext = len(results.Statuses) == 20
|
hasNext = len(results.Statuses) == 20
|
||||||
|
for i := range results.Statuses {
|
||||||
|
results.Statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasNext {
|
if hasNext {
|
||||||
|
|
|
@ -355,10 +355,12 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
||||||
visibility := req.FormValue("visibility")
|
visibility := req.FormValue("visibility")
|
||||||
copyScope := req.FormValue("copy_scope") == "true"
|
copyScope := req.FormValue("copy_scope") == "true"
|
||||||
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
|
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
|
||||||
|
maskNSFW := req.FormValue("mask_nsfw") == "true"
|
||||||
settings := &model.Settings{
|
settings := &model.Settings{
|
||||||
DefaultVisibility: visibility,
|
DefaultVisibility: visibility,
|
||||||
CopyScope: copyScope,
|
CopyScope: copyScope,
|
||||||
ThreadInNewTab: threadInNewTab,
|
ThreadInNewTab: threadInNewTab,
|
||||||
|
MaskNSFW: maskNSFW,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.SaveSettings(ctx, w, nil, settings)
|
err := s.SaveSettings(ctx, w, nil, settings)
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
<input id="thread-tab" name="thread_in_new_tab" type="checkbox" value="true" {{if .Settings.ThreadInNewTab}}checked{{end}}>
|
<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>
|
<label for="thread-tab"> Open threads in new tab from timeline </label>
|
||||||
</div>
|
</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>
|
||||||
|
</div>
|
||||||
<button type="submit"> Save </button>
|
<button type="submit"> Save </button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
{{if eq .Type "image"}}
|
{{if eq .Type "image"}}
|
||||||
<a class="img-link" href="{{.URL}}" target="_blank">
|
<a class="img-link" href="{{.URL}}" target="_blank">
|
||||||
<img class="status-image" src="{{.URL}}" alt="status-image" />
|
<img class="status-image" src="{{.URL}}" alt="status-image" />
|
||||||
{{if $.Sensitive}}
|
{{if (and $.MaskNSFW $.Sensitive)}}
|
||||||
<div class="status-nsfw-overlay"></div>
|
<div class="status-nsfw-overlay"></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
<source src="{{.URL}}">
|
<source src="{{.URL}}">
|
||||||
<p> Your browser doesn't support HTML5 video </p>
|
<p> Your browser doesn't support HTML5 video </p>
|
||||||
</video>
|
</video>
|
||||||
{{if $.Sensitive}}
|
{{if (and $.MaskNSFW $.Sensitive)}}
|
||||||
<div class="status-nsfw-overlay"></div>
|
<div class="status-nsfw-overlay"></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue