1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
This commit is contained in:
Zack Scholl 2016-02-06 23:16:16 -05:00
parent 2be7c500a7
commit 205235c4ea

12
main.go
View File

@ -13,6 +13,8 @@ import (
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday"
) )
var db *bolt.DB var db *bolt.DB
@ -140,6 +142,16 @@ func main() {
option := c.Param("option") option := c.Param("option")
fmt.Println(title, "["+option+"]") fmt.Println(title, "["+option+"]")
if option == "/view" { 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 { } else {
c.Redirect(302, "/"+title) c.Redirect(302, "/"+title)
} }