Cleaned up
This commit is contained in:
parent
23ecf33cc1
commit
20d1b189ca
3 changed files with 9 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -22,3 +22,4 @@ _testmain.go
|
|||
*.exe
|
||||
bin/
|
||||
src/
|
||||
slides/
|
||||
|
|
10
main.go
10
main.go
|
@ -23,10 +23,11 @@ func NewApp() *gin.Engine {
|
|||
haikunator := haikunator.NewHaikunator()
|
||||
haikunator.TokenLength = 0
|
||||
name := haikunator.Haikunate()
|
||||
path := fmt.Sprintf("%s.md", name)
|
||||
path := fmt.Sprintf("slides/%s.md", name)
|
||||
session := sessions.Default(c)
|
||||
session.Set("name", path)
|
||||
session.Save()
|
||||
|
||||
c.HTML(200, "users/index.tmpl", gin.H{
|
||||
"pubTo": path,
|
||||
})
|
||||
|
@ -37,14 +38,17 @@ func NewApp() *gin.Engine {
|
|||
val := session.Get("name")
|
||||
path, ok := val.(string)
|
||||
if !ok {
|
||||
panic("unlucky")
|
||||
c.String(400, "No context")
|
||||
}
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
// coppy sapmle markdown file to the path
|
||||
body, err := ioutil.ReadFile("initial-slides.md")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ioutil.WriteFile(path, body, 0644)
|
||||
c.String(200, string(body))
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadFile(path)
|
||||
|
@ -59,7 +63,7 @@ func NewApp() *gin.Engine {
|
|||
val := session.Get("name")
|
||||
path, ok := val.(string)
|
||||
if !ok {
|
||||
panic("unlucky")
|
||||
c.String(400, "No context")
|
||||
}
|
||||
body, _ := ioutil.ReadAll(c.Request.Body)
|
||||
ioutil.WriteFile(path, body, 0644)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<body>
|
||||
<div id="edit-pane">
|
||||
<div id="controls">
|
||||
<a href="{{ .pubTo}}" target="_blank" onclick="save();"> Present</a>
|
||||
<a href="static/slides.html" target="_blank" onclick="save();"> Present</a>
|
||||
</div>
|
||||
<div id="editor"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue