diff --git a/handler/episode.go b/handler/episode.go index d5d78db..b932108 100644 --- a/handler/episode.go +++ b/handler/episode.go @@ -84,6 +84,7 @@ func (h *EpisodeHandler) ServeDashboard(w http.ResponseWriter, r *http.Request) "PodcastSlug": user.PodcastSlug, "PodcastImageURL": podcastImageURL, "PodcastAuthor": user.PodcastAuthor, + "PodcastEmail": user.PodcastEmail, "RSSURL": template.URL(h.BaseURL + "/rss/" + user.PodcastSlug), }) } diff --git a/handler/rss.go b/handler/rss.go index 4cd3907..12202b6 100644 --- a/handler/rss.go +++ b/handler/rss.go @@ -26,11 +26,18 @@ type rssChannel struct { Description string `xml:"description"` Language string `xml:"language"` Author string `xml:"itunes:author,omitempty"` + ItunesOwner *rssItunesOwner `xml:"itunes:owner,omitempty"` Image *rssImage `xml:"image,omitempty"` ItunesImage *rssItunesImage `xml:"itunes:image,omitempty"` + ItunesType string `xml:"itunes:type,omitempty"` Items []rssItem `xml:"item"` } +type rssItunesOwner struct { + Name string `xml:"itunes:name"` + Email string `xml:"itunes:email"` +} + type rssImage struct { URL string `xml:"url"` Title string `xml:"title"` @@ -132,6 +139,14 @@ func (h *RSSHandler) ServeRSS(w http.ResponseWriter, r *http.Request) { chanItunesImage = &rssItunesImage{Href: h.fullURL(user.PodcastImage)} } + var owner *rssItunesOwner + if user.PodcastEmail != "" || author != "" { + owner = &rssItunesOwner{ + Name: author, + Email: user.PodcastEmail, + } + } + feed := rssFeed{ Version: "2.0", ItunesNS: "http://www.itunes.com/dtds/podcast-1.0.dtd", @@ -141,6 +156,7 @@ func (h *RSSHandler) ServeRSS(w http.ResponseWriter, r *http.Request) { Description: title, Language: "en-us", Author: author, + ItunesOwner: owner, Image: chanImage, ItunesImage: chanItunesImage, Items: items, diff --git a/handler/settings.go b/handler/settings.go index a515163..dfc1669 100644 --- a/handler/settings.go +++ b/handler/settings.go @@ -64,6 +64,11 @@ func (h *SettingsHandler) ServeSettings(w http.ResponseWriter, r *http.Request) author = user.PodcastAuthor } + email := r.FormValue("podcast_email") + if email == "" { + email = user.PodcastEmail + } + image := user.PodcastImage // Handle podcast image upload @@ -90,6 +95,6 @@ func (h *SettingsHandler) ServeSettings(w http.ResponseWriter, r *http.Request) } } - h.Store.UpdateUserPodcast(userID, title, slug, image, author) + h.Store.UpdateUserPodcast(userID, title, slug, image, author, email) http.Redirect(w, r, "/?success=podcast+settings+saved", http.StatusSeeOther) } diff --git a/store/store.go b/store/store.go index 5eb92b1..48431d7 100644 --- a/store/store.go +++ b/store/store.go @@ -14,6 +14,7 @@ type User struct { PodcastSlug string PodcastImage string PodcastAuthor string + PodcastEmail string CreatedAt string } @@ -56,6 +57,7 @@ func migrate(db *sql.DB) error { podcast_slug TEXT NOT NULL DEFAULT '', podcast_image TEXT NOT NULL DEFAULT '', podcast_author TEXT NOT NULL DEFAULT '', + podcast_email TEXT NOT NULL DEFAULT '', created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ); @@ -96,8 +98,8 @@ func (s *Store) CreateUser(email, passwordHash string) (int64, error) { func (s *Store) UserByEmail(email string) (*User, error) { u := &User{} - err := s.db.QueryRow("SELECT id, email, password_hash, podcast_title, podcast_slug, podcast_image, podcast_author, created_at FROM users WHERE email = ?", email). - Scan(&u.ID, &u.Email, &u.PasswordHash, &u.PodcastTitle, &u.PodcastSlug, &u.PodcastImage, &u.PodcastAuthor, &u.CreatedAt) + err := s.db.QueryRow("SELECT id, email, password_hash, podcast_title, podcast_slug, podcast_image, podcast_author, podcast_email, created_at FROM users WHERE email = ?", email). + Scan(&u.ID, &u.Email, &u.PasswordHash, &u.PodcastTitle, &u.PodcastSlug, &u.PodcastImage, &u.PodcastAuthor, &u.PodcastEmail, &u.CreatedAt) if err != nil { return nil, err } @@ -106,8 +108,8 @@ func (s *Store) UserByEmail(email string) (*User, error) { func (s *Store) GetUser(id int64) (*User, error) { u := &User{} - err := s.db.QueryRow("SELECT id, email, password_hash, podcast_title, podcast_slug, podcast_image, podcast_author, created_at FROM users WHERE id = ?", id). - Scan(&u.ID, &u.Email, &u.PasswordHash, &u.PodcastTitle, &u.PodcastSlug, &u.PodcastImage, &u.PodcastAuthor, &u.CreatedAt) + err := s.db.QueryRow("SELECT id, email, password_hash, podcast_title, podcast_slug, podcast_image, podcast_author, podcast_email, created_at FROM users WHERE id = ?", id). + Scan(&u.ID, &u.Email, &u.PasswordHash, &u.PodcastTitle, &u.PodcastSlug, &u.PodcastImage, &u.PodcastAuthor, &u.PodcastEmail, &u.CreatedAt) if err != nil { return nil, err } @@ -116,8 +118,8 @@ func (s *Store) GetUser(id int64) (*User, error) { func (s *Store) UserBySlug(slug string) (*User, error) { u := &User{} - err := s.db.QueryRow("SELECT id, email, password_hash, podcast_title, podcast_slug, podcast_image, podcast_author, created_at FROM users WHERE podcast_slug = ?", slug). - Scan(&u.ID, &u.Email, &u.PasswordHash, &u.PodcastTitle, &u.PodcastSlug, &u.PodcastImage, &u.PodcastAuthor, &u.CreatedAt) + err := s.db.QueryRow("SELECT id, email, password_hash, podcast_title, podcast_slug, podcast_image, podcast_author, podcast_email, created_at FROM users WHERE podcast_slug = ?", slug). + Scan(&u.ID, &u.Email, &u.PasswordHash, &u.PodcastTitle, &u.PodcastSlug, &u.PodcastImage, &u.PodcastAuthor, &u.PodcastEmail, &u.CreatedAt) if err != nil { return nil, err } @@ -136,9 +138,9 @@ func (s *Store) SlugTaken(slug string, excludeUserID int64) (bool, error) { return true, nil } -func (s *Store) UpdateUserPodcast(id int64, title, slug, image, author string) error { - _, err := s.db.Exec("UPDATE users SET podcast_title=?, podcast_slug=?, podcast_image=?, podcast_author=? WHERE id=?", - title, slug, image, author, id) +func (s *Store) UpdateUserPodcast(id int64, title, slug, image, author, email string) error { + _, err := s.db.Exec("UPDATE users SET podcast_title=?, podcast_slug=?, podcast_image=?, podcast_author=?, podcast_email=? WHERE id=?", + title, slug, image, author, email, id) return err } diff --git a/template/dashboard.html b/template/dashboard.html index a44582c..dbb7214 100644 --- a/template/dashboard.html +++ b/template/dashboard.html @@ -42,6 +42,11 @@ +