dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 8427db68bfe5fdff5d54d03dd39e250c8094fd7b
parent 946a8cd3761d8df7bea6f34ee22dd0b977be0d98
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 22 Dec 2022 22:07:36 -0800

option to enable spellcheck on chat input

Diffstat:
Acmd/dkf/migrations/116.sql | 4++++
Mpkg/database/tableUsers.go | 1+
Mpkg/web/handlers/data.go | 1+
Mpkg/web/handlers/handlers.go | 3+++
Mpkg/web/public/views/pages/chat-top-bar.gohtml | 4++--
Mpkg/web/public/views/pages/settings/chat.gohtml | 7+++++++
6 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/cmd/dkf/migrations/116.sql b/cmd/dkf/migrations/116.sql @@ -0,0 +1,4 @@ +-- +migrate Up +ALTER TABLE users ADD COLUMN spellcheck_enabled TINYINT(1) NOT NULL DEFAULT 0; + +-- +migrate Down diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go @@ -94,6 +94,7 @@ type User struct { HideRightColumn bool ChatBarAtBottom bool AutocompleteCommandsEnabled bool + SpellcheckEnabled bool AfkIndicatorEnabled bool SignupMetadata string CollectMetadata bool diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go @@ -618,6 +618,7 @@ type settingsChatData struct { HideRightColumn bool ChatBarAtBottom bool AutocompleteCommandsEnabled bool + SpellcheckEnabled bool AfkIndicatorEnabled bool DisplayDeleteButton bool DisplayKickButton bool diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -2486,6 +2486,7 @@ func SettingsChatHandler(c echo.Context) error { data.HideRightColumn = authUser.HideRightColumn data.ChatBarAtBottom = authUser.ChatBarAtBottom data.AutocompleteCommandsEnabled = authUser.AutocompleteCommandsEnabled + data.SpellcheckEnabled = authUser.SpellcheckEnabled data.AfkIndicatorEnabled = authUser.AfkIndicatorEnabled data.HideIgnoredUsersFromList = authUser.HideIgnoredUsersFromList data.RefreshRate = authUser.RefreshRate @@ -3106,6 +3107,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error { data.HideRightColumn = utils.DoParseBool(c.Request().PostFormValue("hide_right_column")) data.ChatBarAtBottom = utils.DoParseBool(c.Request().PostFormValue("chat_bar_at_bottom")) data.AutocompleteCommandsEnabled = utils.DoParseBool(c.Request().PostFormValue("autocomplete_commands_enabled")) + data.SpellcheckEnabled = utils.DoParseBool(c.Request().PostFormValue("spellcheck_enabled")) data.AfkIndicatorEnabled = utils.DoParseBool(c.Request().PostFormValue("afk_indicator_enabled")) data.ChatItalic = utils.DoParseBool(c.Request().PostFormValue("chat_italic")) data.NotifyNewMessage = utils.DoParseBool(c.Request().PostFormValue("notify_new_message")) @@ -3146,6 +3148,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error { authUser.HideRightColumn = data.HideRightColumn authUser.ChatBarAtBottom = data.ChatBarAtBottom authUser.AutocompleteCommandsEnabled = data.AutocompleteCommandsEnabled + authUser.SpellcheckEnabled = data.SpellcheckEnabled authUser.AfkIndicatorEnabled = data.AfkIndicatorEnabled authUser.NotifyNewMessage = data.NotifyNewMessage authUser.NotifyTagged = data.NotifyTagged diff --git a/pkg/web/public/views/pages/chat-top-bar.gohtml b/pkg/web/public/views/pages/chat-top-bar.gohtml @@ -69,9 +69,9 @@ <td> <div class="wrapper"> {{ if .Data.Multiline }} - <textarea name="message" maxlength="10000" autocomplete="off" autofocus>{{ .Data.Message }}</textarea> + <textarea name="message" maxlength="10000" autocomplete="off"{{ if .AuthUser.SpellcheckEnabled }} spellcheck="true"{{ end }} autofocus>{{ .Data.Message }}</textarea> {{ else }} - <input value="{{ .Data.Message }}" type="text" name="message" maxlength="10000" autocomplete="off" autofocus{{ if .AuthUser.AutocompleteCommandsEnabled }} list="commands"{{ end }} /> + <input value="{{ .Data.Message }}" type="text" name="message" maxlength="10000" autocomplete="off"{{ if .AuthUser.SpellcheckEnabled }} spellcheck="true"{{ end }} autofocus{{ if .AuthUser.AutocompleteCommandsEnabled }} list="commands"{{ end }} /> {{ if .AuthUser.AutocompleteCommandsEnabled }} <datalist id="commands"> {{ range .Data.CommandsList }}<option value="{{ . }}">{{ end }} diff --git a/pkg/web/public/views/pages/settings/chat.gohtml b/pkg/web/public/views/pages/settings/chat.gohtml @@ -136,6 +136,13 @@ </div> <div class="form-check form-check-1"> <div class="checkbox-wrapper form-check-input"> + <input class="my-cbx" type="checkbox" name="spellcheck_enabled" id="spellcheck_enabled" value="1"{{ if .Data.SpellcheckEnabled }} checked{{ end }} /> + <label for="spellcheck_enabled" class="toggle"><span></span></label> + </div> + <label class="form-check-label" for="spellcheck_enabled">{{ t "Enable spellcheck in chat input" . }}</label> + </div> + <div class="form-check form-check-1"> + <div class="checkbox-wrapper form-check-input"> <input class="my-cbx" type="checkbox" name="afk_indicator_enabled" id="afk_indicator_enabled" value="1"{{ if .Data.AfkIndicatorEnabled }} checked{{ end }} /> <label for="afk_indicator_enabled" class="toggle"><span></span></label> </div>