Per-user podcasts, file uploads, RSS images, Docker support
Build and Deploy / build-and-deploy (push) Failing after 13s
Build and Deploy / build-and-deploy (push) Failing after 13s
- Each user owns a podcast: podcast title/author/image on users table - Episodes scoped by user_id with context-based auth - Audio file upload replaces URL linking, served from /uploads/ - Podcast and per-episode images with itunes:image in RSS - RSS per-user via ?user=N, dashboard shows user-specific feed URL - Settings form for title + author + image per user - Docker multi-stage build (golang:1.25-alpine / alpine:3.21) - Removed PODSTALK_TITLE/AUTHOR env vars
This commit is contained in:
+26
-3
@@ -19,32 +19,55 @@ func (h *SettingsHandler) ServeSettings(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
userID := UserIDFromContext(r)
|
||||
user, err := h.Store.GetUser(userID)
|
||||
if err != nil {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.ParseMultipartForm(10 << 20); err != nil {
|
||||
http.Redirect(w, r, "/?error=file+too+large", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
title := r.FormValue("podcast_title")
|
||||
if title != "" {
|
||||
h.Store.SetSetting("podcast_title", title)
|
||||
if title == "" {
|
||||
title = user.PodcastTitle
|
||||
}
|
||||
|
||||
author := r.FormValue("podcast_author")
|
||||
if author == "" {
|
||||
author = user.PodcastAuthor
|
||||
}
|
||||
|
||||
image := user.PodcastImage
|
||||
|
||||
// Handle podcast image upload
|
||||
file, header, err := r.FormFile("podcast_image")
|
||||
if err == nil {
|
||||
defer file.Close()
|
||||
|
||||
// Remove old image
|
||||
if image != "" {
|
||||
os.Remove(filepath.Join(h.UploadDir, image))
|
||||
}
|
||||
|
||||
catDir := filepath.Join(h.UploadDir, "images")
|
||||
os.MkdirAll(catDir, 0755)
|
||||
|
||||
ext := filepath.Ext(header.Filename)
|
||||
if ext == "" {
|
||||
ext = ".png"
|
||||
}
|
||||
dst, err := os.Create(filepath.Join(catDir, "podcast"+ext))
|
||||
if err == nil {
|
||||
defer dst.Close()
|
||||
dst.ReadFrom(file)
|
||||
h.Store.SetSetting("podcast_image", "images/podcast"+ext)
|
||||
image = "images/podcast" + ext
|
||||
}
|
||||
}
|
||||
|
||||
h.Store.UpdateUserPodcast(userID, title, image, author)
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user