mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Add raw
Former-commit-id: 4789ed45d9449fea9db6c01c171736d1c20044a2 [formerly 62d03a41e8978454b14e4ff156e5e4cbc6de6149] [formerly f68618c11a4e02f37b14215352a305d5ee9fb65c [formerly 29460a6c26
]]
Former-commit-id: d108a21904309b99e95b1d485f48234f78865d0f [formerly b22903c4191a97d021858fb6bb26ca57b09bd571]
Former-commit-id: 4ad94bd008e7cc3532a68f472cfac29e133e7572
This commit is contained in:
parent
6031590d87
commit
64b3fdb0d4
18
handlers.go
18
handlers.go
@ -61,6 +61,18 @@ func handlePageRequest(c *gin.Context) {
|
||||
for i, v := range versionsInt64 {
|
||||
versionsText[i] = time.Unix(v/1000000000, 0).String()
|
||||
}
|
||||
|
||||
if command == "raw" {
|
||||
c.Writer.Header().Set("Content-Type", contentType(p.Name))
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
c.Writer.Header().Set("Access-Control-Max-Age", "86400")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Max")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
c.Data(200, contentType(p.Name), []byte(rawText))
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "index.html", gin.H{
|
||||
"EditPage": command == "edit",
|
||||
"ViewPage": command == "view",
|
||||
@ -83,7 +95,11 @@ func handlePageUpdate(c *gin.Context) {
|
||||
}
|
||||
var json QueryJSON
|
||||
if c.BindJSON(&json) != nil {
|
||||
c.String(http.StatusBadRequest, "Problem binding keys")
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong JSON"})
|
||||
return
|
||||
}
|
||||
if len(json.NewText) > 100000 {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Too much"})
|
||||
return
|
||||
}
|
||||
log.Trace("Update: %v", json)
|
||||
|
@ -262,6 +262,7 @@
|
||||
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
|
||||
<a href="#" id="menuLink1" class="pure-menu-link">Other</a>
|
||||
<ul class="pure-menu-children">
|
||||
<li class="pure-menu-item"><a href="/{{ .Page }}/raw" class="pure-menu-link">Raw</a></li>
|
||||
<li class="pure-menu-item"><a href="/{{ .Page }}/history" class="pure-menu-link">History</a></li>
|
||||
<hr>
|
||||
<li class="pure-menu-item"><a href="#" class="pure-menu-link" id="selfDestructPage">Self-destruct</a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user