28 lines
727 B
Go
28 lines
727 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")
|
|
desc := r.PostFormValue("editor-desc")
|
|
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, desc, content)
|
|
feed.SaveFeed(f, "tmp/rss.gob")
|
|
// template.Must(template.ParseFiles("web/templates/editor.html")).ExecuteTemplate(w, "html-result", rssItem)
|
|
}
|
|
}
|