mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Added self-destructing messages https://github.com/schollz/awwkoala/issues/30
Former-commit-id: 85c1bb9080d38319a177c5a3280bf787646cdbb6 [formerly 031b62247892aeb88767ace1da5c46fdc956ff55] [formerly 33bfd5df1c8da72cb068ace2bdb6cae78b4410aa [formerly 0b8a2737fc0034de6cc9c6ec8a16e5f724aa25c0 [formerly7fb8834284
]]] Former-commit-id: 90290f5a2f51a52ec71491baba14d4211462be0a [formerly 032a61675ff8bf3c6b61b26021ab71ac62ca6e3e] Former-commit-id: 6897a2246cee59b67abf36999c300763341d2ae2 Former-commit-id:e0ec6ba810
This commit is contained in:
parent
32abcbcde7
commit
fc908fb04d
15
routes.go
15
routes.go
@ -39,6 +39,9 @@ func editNote(c *gin.Context) {
|
|||||||
version := c.DefaultQuery("version", "-1")
|
version := c.DefaultQuery("version", "-1")
|
||||||
versionNum, _ := strconv.Atoi(version)
|
versionNum, _ := strconv.Atoi(version)
|
||||||
currentText, versions, currentVersion, totalTime := getCurrentText(title, versionNum)
|
currentText, versions, currentVersion, totalTime := getCurrentText(title, versionNum)
|
||||||
|
if strings.Contains(currentText, "self-destruct\n") || strings.Contains(currentText, "\nself-destruct") {
|
||||||
|
c.Redirect(302, "/"+title+"/view")
|
||||||
|
}
|
||||||
numRows := len(strings.Split(currentText, "\n")) + 10
|
numRows := len(strings.Split(currentText, "\n")) + 10
|
||||||
if currentVersion {
|
if currentVersion {
|
||||||
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||||
@ -79,6 +82,12 @@ func everythingElse(c *gin.Context) {
|
|||||||
versionNum = -1
|
versionNum = -1
|
||||||
}
|
}
|
||||||
currentText, versions, _, totalTime := getCurrentText(title, versionNum)
|
currentText, versions, _, totalTime := getCurrentText(title, versionNum)
|
||||||
|
if (strings.Contains(currentText, "self-destruct\n") || strings.Contains(currentText, "\nself-destruct")) && strings.ToLower(title) != "about" {
|
||||||
|
currentText = strings.Replace(currentText, "self-destruct\n", `> *This page has been deleted, you cannot return after closing.*`+"\n", 1)
|
||||||
|
currentText = strings.Replace(currentText, "\nself-destruct", "\n"+`> *This page has been deleted, you cannot return after closing.*`, 1)
|
||||||
|
p := WikiData{strings.ToLower(title), "", []string{}, []string{}}
|
||||||
|
p.save("")
|
||||||
|
}
|
||||||
renderMarkdown(c, currentText, title, versions, "", totalTime)
|
renderMarkdown(c, currentText, title, versions, "", totalTime)
|
||||||
} else if title == "ls" && option == "/"+RuntimeArgs.AdminKey && len(RuntimeArgs.AdminKey) > 1 {
|
} else if title == "ls" && option == "/"+RuntimeArgs.AdminKey && len(RuntimeArgs.AdminKey) > 1 {
|
||||||
renderMarkdown(c, listEverything(), "ls", nil, RuntimeArgs.AdminKey, time.Now().Sub(time.Now()))
|
renderMarkdown(c, listEverything(), "ls", nil, RuntimeArgs.AdminKey, time.Now().Sub(time.Now()))
|
||||||
@ -201,7 +210,11 @@ func renderList(c *gin.Context, title string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(p.CurrentText)
|
currentText := p.CurrentText
|
||||||
|
if strings.Contains(currentText, "self-destruct\n") || strings.Contains(currentText, "\nself-destruct") {
|
||||||
|
c.Redirect(302, "/"+title+"/view")
|
||||||
|
}
|
||||||
|
|
||||||
pClean := bluemonday.UGCPolicy()
|
pClean := bluemonday.UGCPolicy()
|
||||||
pClean.AllowElements("img")
|
pClean.AllowElements("img")
|
||||||
pClean.AllowAttrs("alt").OnElements("img")
|
pClean.AllowAttrs("alt").OnElements("img")
|
||||||
|
Loading…
Reference in New Issue
Block a user