package main import ( // "html" "net/http" "strings" "git.32bit.cafe/yequari/webweav.ing/feed" ) func (app *application) home(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return } data := newTemplateData(r) data.Title = "Home" app.renderPage(w, http.StatusOK, "home.tmpl.html", data) } func (app *application) feedgenView(w http.ResponseWriter, r *http.Request) { data := newTemplateData(r) data.Title = "Feed Generator" app.renderPage(w, http.StatusOK, "feedgenview.tmpl.html", data) } func (app *application) generateRss(w http.ResponseWriter, r *http.Request) { q := r.URL.Query() siteName := q.Get("site-name") siteUrl := q.Get("site-url") siteDesc := q.Get("site-description") pageUrls := q.Get("page-urls") pages := strings.Split(pageUrls, "\n") for i := range pages { pages[i] = strings.TrimSpace(pages[i]) } feedInfo, err := feed.NewFeedInfo(siteName, siteUrl, siteDesc, "", pages...) if err != nil { app.errorLog.Printf("Error generating feed: %s\n", err.Error()) return } feed := feedInfo.GenerateRSS() data := newTemplateData(r) data.Errors = feedInfo.Errors data.Feeds = append(data.Feeds, feed) app.renderElem(w, http.StatusOK, "feed-output.tmpl.html", data) }