Skip to content
This repository was archived by the owner on Sep 23, 2021. It is now read-only.

Commit d844211

Browse files
committed
Change / logic
1 parent a2c5c78 commit d844211

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,22 @@ func NewApp() *gin.Engine {
7575
r.Static("/static", "./static")
7676

7777
r.GET("/", func(c *gin.Context) {
78-
78+
isNew := c.Query("new")
7979
latest := files.LatestFileIn("slides")
8080
log.WithFields(log.Fields{
81-
"name": latest,
81+
"name": latest,
82+
"isNew": isNew,
8283
}).Info("Restoring latest point")
8384

84-
var path string
85-
if latest == "" {
85+
var path, name string
86+
if latest == "" || isNew != "" {
8687
haikunator := haikunator.New()
8788
haikunator.TokenLength = 0
88-
name := haikunator.Haikunate()
89-
path = fmt.Sprintf("slides/%s.md", name)
89+
name = haikunator.Haikunate()
9090
} else {
91-
name := latest
92-
path = fmt.Sprintf("slides/%s", name)
93-
91+
name = strings.Replace(latest, ".md", "", 1)
9492
}
93+
path = fmt.Sprintf("slides/%s.md", name)
9594

9695
log.WithFields(log.Fields{
9796
"path": path,
@@ -100,7 +99,8 @@ func NewApp() *gin.Engine {
10099
session.Set("name", path)
101100
session.Save()
102101

103-
c.HTML(200, "index.tmpl", gin.H{
102+
c.Writer.Header().Set("Location", fmt.Sprintf("/stash/edit/%s", name))
103+
c.HTML(302, "index.tmpl", gin.H{
104104
"pubTo": path,
105105
})
106106
})

0 commit comments

Comments
 (0)