dkforest

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

commit 5f8bc1e84ffc512fb5ffda1f21e6d63df3467fd2
parent d9a571bf2bfeb34432aad7d530e6c4db625aa246
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun,  4 Jun 2023 10:00:46 -0700

customizable code block height

Diffstat:
Acmd/dkf/migrations/135.sql | 4++++
Mpkg/database/tableUsers.go | 1+
Mpkg/web/handlers/api/v1/messages.qtpl | 2+-
Mpkg/web/handlers/api/v1/messages.qtpl.go | 6+++++-
Mpkg/web/handlers/data.go | 1+
Mpkg/web/handlers/handlers.go | 3+++
Mpkg/web/public/views/pages/chat-archive.gohtml | 2+-
Mpkg/web/public/views/pages/settings/chat.gohtml | 4++++
8 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/cmd/dkf/migrations/135.sql b/cmd/dkf/migrations/135.sql @@ -0,0 +1,4 @@ +-- +migrate Up +ALTER TABLE users ADD COLUMN code_block_height INTEGER DEFAULT 300; + +-- +migrate Down diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go @@ -61,6 +61,7 @@ type User struct { PmMode int64 // Normal: 0, Whitelist 1 DisplayPms int64 // deprecated HellbanOpacity int64 + CodeBlockHeight int64 DisplayIgnored bool HideIgnoredUsersFromList bool Verified bool diff --git a/pkg/web/handlers/api/v1/messages.qtpl b/pkg/web/handlers/api/v1/messages.qtpl @@ -149,7 +149,7 @@ .msg p:first-of-type { display: inline; } strong { font-weight: bold; } em { font-style: italic; } - pre { border: 1px solid #2b442b; padding: 2px; margin: 2px 0; max-height: 300px; overflow: auto; background-color: rgba(39,40,34,0.6) !important; + pre { border: 1px solid #2b442b; padding: 2px; margin: 2px 0; max-height: {%dl AuthUser.CodeBlockHeight %}px; overflow: auto; background-color: rgba(39,40,34,0.6) !important; font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace; } .fullscreen { position: absolute; margin-top: -19px; right: 3px; } code { border: 1px solid #2b442b; color: #f92672; padding: 0 2px; margin: 0px 0; background-color: rgba(39,40,34,0.6) !important; } diff --git a/pkg/web/handlers/api/v1/messages.qtpl.go b/pkg/web/handlers/api/v1/messages.qtpl.go @@ -187,7 +187,11 @@ func StreamGenerateStyle(qw422016 *qt422016.Writer, AuthUser *database.User, Dat .msg p:first-of-type { display: inline; } strong { font-weight: bold; } em { font-style: italic; } - pre { border: 1px solid #2b442b; padding: 2px; margin: 2px 0; max-height: 300px; overflow: auto; background-color: rgba(39,40,34,0.6) !important; + pre { border: 1px solid #2b442b; padding: 2px; margin: 2px 0; max-height: `) +//line messages.qtpl:152 + qw422016.N().DL(AuthUser.CodeBlockHeight) +//line messages.qtpl:152 + qw422016.N().S(`px; overflow: auto; background-color: rgba(39,40,34,0.6) !important; font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace; } .fullscreen { position: absolute; margin-top: -19px; right: 3px; } code { border: 1px solid #2b442b; color: #f92672; padding: 0 2px; margin: 0px 0; background-color: rgba(39,40,34,0.6) !important; } diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go @@ -659,6 +659,7 @@ type settingsChatData struct { DisplayModerators bool HideIgnoredUsersFromList bool HellbanOpacity float64 + CodeBlockHeight int64 HideRightColumn bool ChatBarAtBottom bool AutocompleteCommandsEnabled bool diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -2492,6 +2492,7 @@ func SettingsChatHandler(c echo.Context) error { data.AfkIndicatorEnabled = authUser.AfkIndicatorEnabled data.HideIgnoredUsersFromList = authUser.HideIgnoredUsersFromList data.HellbanOpacity = float64(authUser.HellbanOpacity) / 100 + data.CodeBlockHeight = authUser.CodeBlockHeight data.RefreshRate = authUser.RefreshRate data.NotifyNewMessage = authUser.NotifyNewMessage data.NotifyTagged = authUser.NotifyTagged @@ -3127,6 +3128,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error { data.NotifyChessMove = utils.DoParseBool(c.Request().PostFormValue("notify_chess_move")) data.UseStream = utils.DoParseBool(c.Request().PostFormValue("use_stream")) data.HellbanOpacity = utils.DoParseF64(c.Request().PostFormValue("hellban_opacity")) + data.CodeBlockHeight = utils.DoParseInt64(c.Request().PostFormValue("code_block_height")) //data.NotifyNewMessageSound = utils.DoParseInt64(c.Request().PostFormValue("notify_new_message_sound")) //data.NotifyTaggedSound = utils.DoParseInt64(c.Request().PostFormValue("notify_tagged_sound")) //data.NotifyPmmedSound = utils.DoParseInt64(c.Request().PostFormValue("notify_pmmed_sound")) @@ -3173,6 +3175,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error { //authUser.NotifyTaggedSound = data.NotifyTaggedSound //authUser.NotifyPmmedSound = data.NotifyPmmedSound + authUser.CodeBlockHeight = utils.Clamp(data.CodeBlockHeight, 15, 300) if authUser.CanSeeHB() { authUser.HellbanOpacity = utils.Clamp(int64(data.HellbanOpacity*100), 0, 100) } diff --git a/pkg/web/public/views/pages/chat-archive.gohtml b/pkg/web/public/views/pages/chat-archive.gohtml @@ -54,7 +54,7 @@ strong { font-weight: bold; } em { font-style: italic; } ul { list-style-type: disc; margin: 0 0 0 15px; padding: 0; margin-bottom: 0 !important; } - pre { border: 1px solid #2b442b; padding: 2px; margin: 2px 0; max-height: 300px; overflow: auto; background-color: rgba(39,40,34,0.6) !important; } + pre { border: 1px solid #2b442b; padding: 2px; margin: 2px 0; max-height: {{ .AuthUser.CodeBlockHeight }}px; overflow: auto; background-color: rgba(39,40,34,0.6) !important; } code { border: 1px solid #2b442b; color: #f92672; padding: 0 2px; margin: 0px 0; background-color: rgba(39,40,34,0.6) !important; } .o-wrap { overflow-wrap: break-word; } </style> diff --git a/pkg/web/public/views/pages/settings/chat.gohtml b/pkg/web/public/views/pages/settings/chat.gohtml @@ -112,6 +112,10 @@ <hr /> + <div> + <label for="code_block_height" class="toggle"><span>Code block height (15-300px)</span></label> + <input name="code_block_height" id="code_block_height" type="number" min="15" max="300" step="1" value="{{ .Data.CodeBlockHeight }}" /> + </div> {{ if $.AuthUser.CanSeeHB }} <div> <label for="hellban_opacity" class="toggle"><span>Hellban opacity</span></label>