From 205235c4eaafd4ecdbc27275ebe9cded0390dc39 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sat, 6 Feb 2016 23:16:16 -0500 Subject: [PATCH] Edit --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index 1648c29..7c9f806 100755 --- a/main.go +++ b/main.go @@ -13,6 +13,8 @@ import ( "github.com/boltdb/bolt" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" + "github.com/microcosm-cc/bluemonday" + "github.com/russross/blackfriday" ) var db *bolt.DB @@ -140,6 +142,16 @@ func main() { option := c.Param("option") fmt.Println(title, "["+option+"]") if option == "/view" { + p := CowyoData{title, ""} + err := p.load() + if err != nil { + panic(err) + } + + unsafe := blackfriday.MarkdownCommon([]byte(p.Text)) + html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) + c.Data(200, "text/html", html) + } else { c.Redirect(302, "/"+title) }