Add TypeScript migration, image resizing, media upload UX, and multimedia support
All checks were successful
Deploy to NAS / deploy (push) Successful in 2m20s

- Migrate static JS to TypeScript (static-ts/ → compiled to internal/api/static/)
- Add image resizing on upload: JPEG/PNG/WebP scaled to max 1920px at quality 80
- Extract shared upload logic into upload.go (saveUpload, saveResizedImage, saveResizedWebP)
- Add POST /media endpoint for drag-drop/paste media uploads with markdown ref return
- Add background music player with video/audio coordination (autoplay.ts)
- Add global nav, public feed, hashtags, visibility, Markdown rendering for entries
- Add Dockerfile stage for TypeScript compilation (static-ts-builder)
- Add goldmark, disintegration/imaging, golang.org/x/image dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christoph K.
2026-04-09 23:03:04 +02:00
parent 8eef933573
commit 17186e7b64
24 changed files with 890 additions and 179 deletions

View File

@@ -13,10 +13,28 @@ import (
"time"
"github.com/go-chi/chi/v5"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer/html"
"github.com/jacek/pamietnik/backend/internal/auth"
"github.com/jacek/pamietnik/backend/internal/db"
)
var md = goldmark.New(
goldmark.WithExtensions(extension.GFM),
goldmark.WithParserOptions(parser.WithAutoHeadingID()),
goldmark.WithRendererOptions(html.WithHardWraps()),
)
func renderMarkdown(src string) template.HTML {
var buf bytes.Buffer
if err := md.Convert([]byte(src), &buf); err != nil {
return template.HTML(template.HTMLEscapeString(src))
}
return template.HTML(buf.String())
}
//go:embed static templates
var assets embed.FS
@@ -28,7 +46,11 @@ var funcMap = template.FuncMap{
}
return *p
},
"join": strings.Join,
"join": strings.Join,
"isVideo": func(mime string) bool { return strings.HasPrefix(mime, "video/") },
"isAudio": func(mime string) bool { return strings.HasPrefix(mime, "audio/") },
"isImage": func(mime string) bool { return strings.HasPrefix(mime, "image/") },
"markdown": renderMarkdown,
}
var tmpls = template.Must(