Compare commits

..

3 commits

Author SHA1 Message Date
92a06fb740
feat: disable editor
All checks were successful
/ pre-commit (push) Successful in 1m7s
Signed-off-by: Julien Riou <julien@riou.xyz>
2025-09-22 07:18:38 +02:00
fb3d37e25c
style: Simplify condition to load bootstrap
All checks were successful
/ pre-commit (push) Successful in 1m9s
Signed-off-by: Julien Riou <julien@riou.xyz>
2025-09-21 15:18:08 +02:00
3147306927
feat: replace Monaco by Ace
All checks were successful
/ pre-commit (push) Successful in 1m30s
- Remove the Monaco Editor because it was to heavy and hard to integrate
- Use Ace instead
- Use the lowercase identifier for languages (ex: "Text" -> "text")
- Select automatically the default language in the drop down to create a note
  (like the expiration)
- Add `ace_directory` to serve assets from a local folder instead of a CDN
- "hcl" syntax highlighting has been removed
- "go" syntax highlighting has been renamed to "golang"

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-09-21 15:07:19 +02:00
3 changed files with 1 additions and 17 deletions

View file

@ -9,7 +9,6 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings" "strings"
"time"
) )
func ReadConfig(file string, config interface{}) error { func ReadConfig(file string, config interface{}) error {
@ -103,15 +102,6 @@ func HumanDuration(i int) string {
return fmt.Sprintf("%d %s", i, w) return fmt.Sprintf("%d %s", i, w)
} }
// TimeDiff to return the number of seconds between this time and now
func TimeDiff(ts time.Time) int {
diff := int(time.Since(ts).Seconds())
if diff < 0 {
return diff * -1
}
return diff
}
func ReturnError(logger *slog.Logger, message string, err error) int { func ReturnError(logger *slog.Logger, message string, err error) int {
if err != nil { if err != nil {
logger.Error(message, slog.Any("error", err)) logger.Error(message, slog.Any("error", err))

View file

@ -106,7 +106,6 @@ func (s *Server) Start() error {
// Web pages // Web pages
funcs := template.FuncMap{ funcs := template.FuncMap{
"HumanDuration": internal.HumanDuration, "HumanDuration": internal.HumanDuration,
"TimeDiff": internal.TimeDiff,
"lower": strings.ToLower, "lower": strings.ToLower,
"string": func(b []byte) string { return string(b) }, "string": func(b []byte) string { return string(b) },
} }

View file

@ -19,18 +19,13 @@
<div class="d-flex flex-wrap py-2"> <div class="d-flex flex-wrap py-2">
<span class="fs-4 d-flex mb-3 mb-md-0 me-md-auto text-decoration-none">Note {{.Note.ID}}</span> <span class="fs-4 d-flex mb-3 mb-md-0 me-md-auto text-decoration-none">Note {{.Note.ID}}</span>
<ul class="nav nav-pills align-items-center"> <ul class="nav nav-pills align-items-center">
<li class="nav-item px-2"> <li class="nav-item">
<a href="" id="rawURL">raw</a> <a href="" id="rawURL">raw</a>
<script>document.getElementById("rawURL").href = window.location.href.replace(".html", "");</script> <script>document.getElementById("rawURL").href = window.location.href.replace(".html", "");</script>
</li> </li>
<li class="nav-item px-2"> <li class="nav-item px-2">
{{.Note.Language}} {{.Note.Language}}
</li> </li>
{{if eq .Note.DeleteAfterRead false}}
<li class="nav-item px-2">
expires in {{HumanDuration (TimeDiff .Note.ExpiresAt)}}
</li>
{{end}}
</ul> </ul>
</div> </div>
{{if .DisableEditor}} {{if .DisableEditor}}