mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Don't need this password checking now
Former-commit-id: 1951dfcb6292d6a9bad533f2cfb28a97e108eb8b [formerly cb098a5f59a9a4c00a3b6db270fea0716d7d5c60] [formerly b4f9bee32bc08a279397a714af9c2230070c00fc [formerly 600dd685f1
]]
Former-commit-id: c1fbbb182163aee133d42475f14dc0ac207b49ad [formerly 465d4f43772c7146419e2a4bd4ef13ec1567ec01]
Former-commit-id: d39d6f868cbeae584c105bc50ad8b7df3172e833
This commit is contained in:
parent
eb8bd29dd7
commit
80d4772b7f
9
main.go
9
main.go
@ -109,10 +109,6 @@ Options:`)
|
|||||||
r.GET("/:title", editNote)
|
r.GET("/:title", editNote)
|
||||||
r.PUT("/:title", func(c *gin.Context) {
|
r.PUT("/:title", func(c *gin.Context) {
|
||||||
filename := c.Param("title")
|
filename := c.Param("title")
|
||||||
fmt.Println(filename)
|
|
||||||
fmt.Println(c.Request.Body)
|
|
||||||
fmt.Println(c.Request.ContentLength)
|
|
||||||
fmt.Println(c.Request.Header)
|
|
||||||
contentLength := c.Request.ContentLength
|
contentLength := c.Request.ContentLength
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
reader = c.Request.Body
|
reader = c.Request.Body
|
||||||
@ -154,10 +150,9 @@ Options:`)
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
buf.ReadFrom(reader)
|
buf.ReadFrom(reader)
|
||||||
fmt.Println("---------------")
|
fmt.Println("---------------")
|
||||||
fmt.Println(buf.String())
|
fmt.Println(filename)
|
||||||
fmt.Println("---------------")
|
fmt.Println("---------------")
|
||||||
fmt.Println(c.ContentType())
|
fmt.Println(buf.String())
|
||||||
fmt.Println(c.Request.Header)
|
|
||||||
fmt.Println("---------------")
|
fmt.Println("---------------")
|
||||||
p := WikiData{filename, "", []string{}, []string{}, false, ""}
|
p := WikiData{filename, "", []string{}, []string{}, false, ""}
|
||||||
p.save(buf.String())
|
p.save(buf.String())
|
||||||
|
52
routes.go
52
routes.go
@ -158,37 +158,31 @@ func editNote(c *gin.Context) {
|
|||||||
} else if strings.ToLower(title) == "help" { //}&& strings.Contains(AllowedIPs, c.ClientIP()) != true {
|
} else if strings.ToLower(title) == "help" { //}&& strings.Contains(AllowedIPs, c.ClientIP()) != true {
|
||||||
c.Redirect(302, "/Help/view")
|
c.Redirect(302, "/Help/view")
|
||||||
} else {
|
} else {
|
||||||
locked, _ := hasPassword(title)
|
version := c.DefaultQuery("version", "-1")
|
||||||
if locked {
|
versionNum, _ := strconv.Atoi(version)
|
||||||
|
currentText, versions, currentVersion, totalTime, encrypted, locked := getCurrentText(title, versionNum)
|
||||||
|
if encrypted || len(locked) > 0 {
|
||||||
c.Redirect(302, "/"+title+"/view")
|
c.Redirect(302, "/"+title+"/view")
|
||||||
} else {
|
|
||||||
version := c.DefaultQuery("version", "-1")
|
|
||||||
versionNum, _ := strconv.Atoi(version)
|
|
||||||
currentText, versions, currentVersion, totalTime, encrypted, locked := getCurrentText(title, versionNum)
|
|
||||||
if encrypted || len(locked) > 0 {
|
|
||||||
c.Redirect(302, "/"+title+"/view")
|
|
||||||
}
|
|
||||||
if strings.Contains(currentText, "self-destruct\n") || strings.Contains(currentText, "\nself-destruct") {
|
|
||||||
c.Redirect(302, "/"+title+"/view")
|
|
||||||
}
|
|
||||||
numRows := len(strings.Split(currentText, "\n")) + 10
|
|
||||||
totalTimeString := totalTime.String()
|
|
||||||
if totalTime.Seconds() < 1 {
|
|
||||||
totalTimeString = "< 1 s"
|
|
||||||
}
|
|
||||||
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
|
||||||
"Title": title,
|
|
||||||
"WikiName": RuntimeArgs.WikiName,
|
|
||||||
"ExternalIP": RuntimeArgs.ExternalIP,
|
|
||||||
"CurrentText": currentText,
|
|
||||||
"NumRows": numRows,
|
|
||||||
"Versions": versions,
|
|
||||||
"TotalTime": totalTimeString,
|
|
||||||
"SocketType": RuntimeArgs.Socket,
|
|
||||||
"NoEdit": !currentVersion,
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if strings.Contains(currentText, "self-destruct\n") || strings.Contains(currentText, "\nself-destruct") {
|
||||||
|
c.Redirect(302, "/"+title+"/view")
|
||||||
|
}
|
||||||
|
numRows := len(strings.Split(currentText, "\n")) + 10
|
||||||
|
totalTimeString := totalTime.String()
|
||||||
|
if totalTime.Seconds() < 1 {
|
||||||
|
totalTimeString = "< 1 s"
|
||||||
|
}
|
||||||
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||||
|
"Title": title,
|
||||||
|
"WikiName": RuntimeArgs.WikiName,
|
||||||
|
"ExternalIP": RuntimeArgs.ExternalIP,
|
||||||
|
"CurrentText": currentText,
|
||||||
|
"NumRows": numRows,
|
||||||
|
"Versions": versions,
|
||||||
|
"TotalTime": totalTimeString,
|
||||||
|
"SocketType": RuntimeArgs.Socket,
|
||||||
|
"NoEdit": !currentVersion,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user