feat(media): unify uploads onto modules/album, add batched srcset enrichment and Media Library picker

This commit is contained in:
Jakub Zych
2026-11-27 13:26:59 +01:00
parent f61c90a326
commit ccd8dc85aa
14 changed files with 781 additions and 79 deletions

View File

@@ -76,15 +76,24 @@ func TestJournal006MediaUpload(t *testing.T) {
}
var body struct {
Data struct {
URL string `json:"url"`
Path string `json:"path"`
URL string `json:"url"`
Path string `json:"path"`
ID uint `json:"id"`
ShortID string `json:"short_id"`
Width *int `json:"width"`
Height *int `json:"height"`
Variants []any `json:"variants"`
Srcset string `json:"srcset"`
} `json:"data"`
}
if err := json.Unmarshal(created.Body.Bytes(), &body); err != nil {
t.Fatalf("upload json: %s err=%v", created.Body.String(), err)
}
if !strings.HasPrefix(body.Data.Path, "/journal/") {
t.Fatalf("path = %q, want prefix /journal/", body.Data.Path)
if !strings.HasPrefix(body.Data.Path, "/media/") {
t.Fatalf("path = %q, want prefix /media/", body.Data.Path)
}
if body.Data.ID == 0 || body.Data.ShortID == "" || body.Data.Width == nil || body.Data.Height == nil {
t.Fatalf("expected additive album metadata (id, short_id, width, height), got %+v", body.Data)
}
trav := env.callMultipart(t, http.MethodPost, "/_journal/api/v1/media/upload", okTok, map[string]string{"folder": "../etc"}, "file", "cover.png", png1x1)