cpolis/cmd/handlers/editor.go

26 lines
645 B
Go

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