diff --git a/main.go b/main.go index cccab19..6946657 100644 --- a/main.go +++ b/main.go @@ -109,10 +109,6 @@ Options:`) r.GET("/:title", editNote) r.PUT("/:title", func(c *gin.Context) { 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 var reader io.Reader reader = c.Request.Body @@ -154,10 +150,9 @@ Options:`) buf := new(bytes.Buffer) buf.ReadFrom(reader) fmt.Println("---------------") - fmt.Println(buf.String()) + fmt.Println(filename) fmt.Println("---------------") - fmt.Println(c.ContentType()) - fmt.Println(c.Request.Header) + fmt.Println(buf.String()) fmt.Println("---------------") p := WikiData{filename, "", []string{}, []string{}, false, ""} p.save(buf.String()) diff --git a/routes.go b/routes.go index d471c28..8ce9b6b 100644 --- a/routes.go +++ b/routes.go @@ -158,37 +158,31 @@ func editNote(c *gin.Context) { } else if strings.ToLower(title) == "help" { //}&& strings.Contains(AllowedIPs, c.ClientIP()) != true { c.Redirect(302, "/Help/view") } else { - locked, _ := hasPassword(title) - if locked { + 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") - } 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, + }) } }