Change / logic
This commit is contained in:
parent
a2c5c788d2
commit
d844211d22
1 changed files with 10 additions and 10 deletions
20
main.go
20
main.go
|
@ -75,23 +75,22 @@ func NewApp() *gin.Engine {
|
||||||
r.Static("/static", "./static")
|
r.Static("/static", "./static")
|
||||||
|
|
||||||
r.GET("/", func(c *gin.Context) {
|
r.GET("/", func(c *gin.Context) {
|
||||||
|
isNew := c.Query("new")
|
||||||
latest := files.LatestFileIn("slides")
|
latest := files.LatestFileIn("slides")
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"name": latest,
|
"name": latest,
|
||||||
|
"isNew": isNew,
|
||||||
}).Info("Restoring latest point")
|
}).Info("Restoring latest point")
|
||||||
|
|
||||||
var path string
|
var path, name string
|
||||||
if latest == "" {
|
if latest == "" || isNew != "" {
|
||||||
haikunator := haikunator.New()
|
haikunator := haikunator.New()
|
||||||
haikunator.TokenLength = 0
|
haikunator.TokenLength = 0
|
||||||
name := haikunator.Haikunate()
|
name = haikunator.Haikunate()
|
||||||
path = fmt.Sprintf("slides/%s.md", name)
|
|
||||||
} else {
|
} else {
|
||||||
name := latest
|
name = strings.Replace(latest, ".md", "", 1)
|
||||||
path = fmt.Sprintf("slides/%s", name)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
path = fmt.Sprintf("slides/%s.md", name)
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"path": path,
|
"path": path,
|
||||||
|
@ -100,7 +99,8 @@ func NewApp() *gin.Engine {
|
||||||
session.Set("name", path)
|
session.Set("name", path)
|
||||||
session.Save()
|
session.Save()
|
||||||
|
|
||||||
c.HTML(200, "index.tmpl", gin.H{
|
c.Writer.Header().Set("Location", fmt.Sprintf("/stash/edit/%s", name))
|
||||||
|
c.HTML(302, "index.tmpl", gin.H{
|
||||||
"pubTo": path,
|
"pubTo": path,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue