This repository was archived by the owner on Sep 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
1313 haikunator "github.com/atrox/haikunatorgo"
1414 "github.com/gin-contrib/sessions"
1515 "github.com/gin-gonic/gin"
16+ "github.com/msoedov/hacker-slides/files"
1617)
1718
1819const sessionHeader = "slide-session"
@@ -75,15 +76,23 @@ func NewApp() *gin.Engine {
7576
7677 r .GET ("/" , func (c * gin.Context ) {
7778
78- fname := c . Param ( "name " )
79+ latest := files . LatestFileIn ( "slides " )
7980 log .WithFields (log.Fields {
80- "name" : fname ,
81- }).Info ("Restore?" )
81+ "name" : latest ,
82+ }).Info ("Restoring latest point" )
83+
84+ var path string
85+ if latest == "" {
86+ haikunator := haikunator .New ()
87+ haikunator .TokenLength = 0
88+ name := haikunator .Haikunate ()
89+ path = fmt .Sprintf ("slides/%s.md" , name )
90+ } else {
91+ name := latest
92+ path = fmt .Sprintf ("slides/%s" , name )
93+
94+ }
8295
83- haikunator := haikunator .New ()
84- haikunator .TokenLength = 0
85- name := haikunator .Haikunate ()
86- path := fmt .Sprintf ("slides/%s.md" , name )
8796 log .WithFields (log.Fields {
8897 "path" : path ,
8998 }).Info ("A new session" )
You can’t perform that action at this time.
0 commit comments