1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Versioning works with /edit

This commit is contained in:
Zack Scholl
2016-02-09 18:38:25 -05:00
parent 594360fe7a
commit c15ac624b8
5 changed files with 176 additions and 114 deletions

View File

@@ -34,14 +34,29 @@ func editNote(c *gin.Context) {
if locked {
c.Redirect(302, "/"+title+"/view")
} else {
currentText := getCurrentText(title)
version := c.DefaultQuery("version", "-1")
versionNum, _ := strconv.Atoi(version)
currentText, versions, currentVersion := getCurrentText(title, versionNum)
numRows := len(strings.Split(currentText, "\n")) + 10
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"Title": title,
"ExternalIP": RuntimeArgs.ExternalIP,
"CurrentText": currentText,
"NumRows": numRows,
})
if currentVersion {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"Title": title,
"ExternalIP": RuntimeArgs.ExternalIP,
"CurrentText": currentText,
"NumRows": numRows,
"Versions": versions,
})
} else {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"Title": title,
"ExternalIP": RuntimeArgs.ExternalIP,
"CurrentText": currentText,
"NumRows": numRows,
"Versions": versions,
"NoEdit": true,
})
}
}
}
}