aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/handlers_posts.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/handlers_posts.go')
-rw-r--r--internal/web/handlers_posts.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/web/handlers_posts.go b/internal/web/handlers_posts.go
index 2ec2b2e..d38c5f2 100644
--- a/internal/web/handlers_posts.go
+++ b/internal/web/handlers_posts.go
@@ -12,6 +12,13 @@ import (
"github.com/gramanas/blogspace/internal/store"
)
+// handlePreview renders Markdown for the editor's Preview toggle, with the same
+// pipeline a save uses; nothing is stored. Login, ownership, CSRF and the body
+// cap are all withBlog's.
+func (s *Server) handlePreview(w http.ResponseWriter, r *http.Request) {
+ writeJSON(w, http.StatusOK, map[string]string{"html": markdown.Render(r.FormValue("body"))})
+}
+
func (s *Server) handlePosts(w http.ResponseWriter, r *http.Request) {
pageID, _ := strconv.ParseInt(r.URL.Query().Get("page"), 10, 64)
pages, err := blogStore(r).ListPages(r.Context())