Added filter reactions settings; Change allowed emoji filter; Emoji module correct commit

This commit is contained in:
localhost_frssoft 2022-10-20 02:15:50 +03:00
parent 9cdac3e623
commit c5d552e7d8
11 changed files with 29 additions and 5 deletions

1
go.mod
View File

@ -1,6 +1,7 @@
module bloat
require (
github.com/enescakir/emoji v1.0.0 // indirect
github.com/gorilla/mux v1.7.3
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
)

2
go.sum
View File

@ -1,3 +1,5 @@
github.com/enescakir/emoji v1.0.0 h1:W+HsNql8swfCQFtioDGDHCHri8nudlK1n5p2rHCJoog=
github.com/enescakir/emoji v1.0.0/go.mod h1:Bt1EKuLnKDTYpLALApstIkAjdDrS/8IAgTkKp+WKFD0=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=

View File

@ -12,6 +12,7 @@ type Settings struct {
DarkMode bool `json:"dark_mode"`
AntiDopamineMode bool `json:"anti_dopamine_mode"`
HideUnsupportedNotifs bool `json:"hide_unsupported_notifs"`
AddReactionsFilter string `json:"add_reactions_filter"`
CSS string `json:"css"`
}
@ -28,6 +29,7 @@ func NewSettings() *Settings {
DarkMode: false,
AntiDopamineMode: false,
HideUnsupportedNotifs: false,
AddReactionsFilter: "",
CSS: "",
}
}

View File

@ -14,6 +14,7 @@ type Context struct {
CSRFToken string
UserID string
AntiDopamineMode bool
AddReactionsFilter string
UserCSS string
Referrer string
}

View File

@ -43,8 +43,9 @@ type TemplateData struct {
}
func allowed_emoji_page(emoj string, codes ...string) bool {
for _, code := range codes {
func allowed_emoji_page(emoj string, codes string) bool {
s := strings.Split(codes, " ")
for _, code := range s {
if strings.Contains(emoj, code) {
return true
}

View File

@ -66,6 +66,7 @@ func (s *service) authenticate(c *client, sid string, csrf string, ref string, t
UserID: c.s.UserID,
AntiDopamineMode: sett.AntiDopamineMode,
UserCSS: sett.CSS,
AddReactionsFilter: sett.AddReactionsFilter,
Referrer: ref,
}
}()

View File

@ -519,6 +519,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
darkMode := c.r.FormValue("dark_mode") == "true"
antiDopamineMode := c.r.FormValue("anti_dopamine_mode") == "true"
hideUnsupportedNotifs := c.r.FormValue("hide_unsupported_notifs") == "true"
addReactionsFilter := c.r.FormValue("pleroma-reactions-filter")
css := c.r.FormValue("css")
settings := &model.Settings{
@ -533,6 +534,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
DarkMode: darkMode,
AntiDopamineMode: antiDopamineMode,
HideUnsupportedNotifs: hideUnsupportedNotifs,
AddReactionsFilter: addReactionsFilter,
CSS: css,
}

View File

@ -4,7 +4,7 @@
<div class="emoji-list-container">
{{range .Emojis}}
{{if Allowed_emoji_page .ShortCode "blobfox" "senko" "shiro" "cirno" "pleroma" "udongein"}}
{{if Allowed_emoji_page .ShortCode "blobfox senko shiro cirno pleroma udongein"}}
<div class="emoji-item-container">
<div class="emoji-item">
<img class="emoji" src="{{.URL}}" alt="{{.ShortCode}}" height="32" loading="lazy" />

View File

@ -1,18 +1,24 @@
{{with .Data}}
{{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
<div class="page-title"> Reactions </div>
{{$st_id := .ID}}
<div class="scrollable-emoji" style="overflow-y: scroll; height:400px;">
<div class="page-title"> Add reaction </div>
<div class="scrollable-emoji" style="overflow-y: scroll; height:200px;">
<div class="pleroma-reactions">
{{$emoji_filter := $.Ctx.AddReactionsFilter}}
{{range $shortcode, $code := .ReactionEmojis}}
{{if Allowed_emoji_page $shortcode $emoji_filter}}
<form action="/react-with/{{$st_id}}?emoji={{$code}}" method="post" target="_self" title="{{$shortcode}}">
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
<input type="submit" value="{{$code}}" class="pleroma-emoji">
</form>
{{end}}
{{end}}
</div>
</div>
<div class="page-title"> Who reacted </div>
{{range .Reactions}}
<div class="page-title">{{.Name}}</div>
{{template "userlist.tmpl" (WithContext .Accounts $.Ctx)}}

View File

@ -70,6 +70,12 @@
<input id="dark-mode" name="dark_mode" type="checkbox" value="true" {{if .Settings.DarkMode}}checked{{end}}>
<label for="dark-mode"> Use dark theme </label>
</div>
<div class="settings-form-field">
<label for=""> Reactions filter (example_allowed anotherexample ...): </label>
</div>
<div>
<textarea id="pleroma-reactions-filter" name="pleroma-reactions-filter" cols="80" rows="1">{{.Settings.AddReactionsFilter}}</textarea>
</div>
<div class="settings-form-field">
<label for="css"> Custom CSS: </label>
</div>

2
vendor/modules.txt vendored
View File

@ -1,3 +1,5 @@
# github.com/enescakir/emoji v1.0.0
github.com/enescakir/emoji
# github.com/gorilla/mux v1.7.3
github.com/gorilla/mux
# github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80