cpolis/cmd/handlers/editor.go

28 lines
727 B
Go
Raw Normal View History

package handlers
import (
"log"
"net/http"
"streifling.com/jason/cpolis/cmd/articles"
2024-02-18 12:41:49 +01:00
"streifling.com/jason/cpolis/cmd/feed"
)
func HandleFinishedEdit(f *feed.Feed) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
2024-02-18 12:41:49 +01:00
title := r.PostFormValue("editor-title")
desc := r.PostFormValue("editor-desc")
2024-02-18 12:41:49 +01:00
mdContent := r.PostFormValue("editor-text")
2024-02-18 12:41:49 +01:00
content, err := articles.ConvertToHTML(mdContent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.Panicln(err)
}
feed.AddToFeed(f, title, desc, content)
feed.SaveFeed(f, "tmp/rss.gob")
2024-02-18 12:41:49 +01:00
// template.Must(template.ParseFiles("web/templates/editor.html")).ExecuteTemplate(w, "html-result", rssItem)
}
}