Exemplo n.º 1
0
func savePostHandler2(ren render.Render, r *http.Request) {
	id := r.FormValue("id")
	title := r.FormValue("title")
	contentMarkdown := r.FormValue("content")
	contentHtml := utils.ConvertMarkdownToHtml(contentMarkdown)

	postDocument := models.PostDocument{id, title, contentHtml, contentMarkdown}

	if id != "" {
		postsCollection.UpdateId(id, postDocument)
	} else {
		id := utils.GeneratId()
		postDocument.Id = id
		postsCollection.Insert(postDocument)
	}

	ren.Redirect("/")
}
func savePostHandler1(ren render.Render, r *http.Request) {
	id := r.FormValue("id")
	title := r.FormValue("title")
	contentMarkdown := r.FormValue("content")
	contentHtml := utils.ConvertMarkdownToHtml(contentMarkdown)

	var post *models.PostMD

	if id != "" {
		post = postsMD[id]
		post.Title = title
		post.ContentHtml = contentHtml
		post.ContentMarkdown = contentMarkdown
	} else {
		id := utils.GeneratId()
		post := models.NewPostMD(id, title, contentHtml, contentMarkdown)
		postsMD[post.Id] = post
	}

	ren.Redirect("/")
}
Exemplo n.º 3
0
func getHtmlHandler2(ren render.Render, r *http.Request) {
	md := r.FormValue("md")
	html := utils.ConvertMarkdownToHtml(md)

	ren.JSON(200, map[string]interface{}{"html": html})
}