1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
Former-commit-id: 209a34ecc2abab0c1a6ef56c9f5e21a79a986de9 [formerly a69b67830e88f14165acd5436297ea4d0e212f67] [formerly 45f25c5bbf87e01ff782cf557365ec954ae19db7 [formerly 205235c4ea]]
Former-commit-id: 60ba3ebd7b02e9f09db200acf0f69b480626d308 [formerly 472f73d442462927668c103eda77bbc818735805]
Former-commit-id: 932fb7186f2a142f2ee69e4f5c8ac4cc47471705
This commit is contained in:
Zack Scholl 2016-02-06 23:16:16 -05:00
parent b94c81da30
commit affe633053

12
main.go
View File

@ -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)
}