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
|
*.exe
|
||||||
bin/
|
bin/
|
||||||
src/
|
src/
|
||||||
|
slides/
|
||||||
|
|
10
main.go
10
main.go
|
@ -23,10 +23,11 @@ func NewApp() *gin.Engine {
|
||||||
haikunator := haikunator.NewHaikunator()
|
haikunator := haikunator.NewHaikunator()
|
||||||
haikunator.TokenLength = 0
|
haikunator.TokenLength = 0
|
||||||
name := haikunator.Haikunate()
|
name := haikunator.Haikunate()
|
||||||
path := fmt.Sprintf("%s.md", name)
|
path := fmt.Sprintf("slides/%s.md", name)
|
||||||
session := sessions.Default(c)
|
session := sessions.Default(c)
|
||||||
session.Set("name", path)
|
session.Set("name", path)
|
||||||
session.Save()
|
session.Save()
|
||||||
|
|
||||||
c.HTML(200, "users/index.tmpl", gin.H{
|
c.HTML(200, "users/index.tmpl", gin.H{
|
||||||
"pubTo": path,
|
"pubTo": path,
|
||||||
})
|
})
|
||||||
|
@ -37,14 +38,17 @@ func NewApp() *gin.Engine {
|
||||||
val := session.Get("name")
|
val := session.Get("name")
|
||||||
path, ok := val.(string)
|
path, ok := val.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("unlucky")
|
c.String(400, "No context")
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(path); err != nil {
|
if _, err := os.Stat(path); err != nil {
|
||||||
|
// coppy sapmle markdown file to the path
|
||||||
body, err := ioutil.ReadFile("initial-slides.md")
|
body, err := ioutil.ReadFile("initial-slides.md")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ioutil.WriteFile(path, body, 0644)
|
ioutil.WriteFile(path, body, 0644)
|
||||||
|
c.String(200, string(body))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadFile(path)
|
body, err := ioutil.ReadFile(path)
|
||||||
|
@ -59,7 +63,7 @@ func NewApp() *gin.Engine {
|
||||||
val := session.Get("name")
|
val := session.Get("name")
|
||||||
path, ok := val.(string)
|
path, ok := val.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("unlucky")
|
c.String(400, "No context")
|
||||||
}
|
}
|
||||||
body, _ := ioutil.ReadAll(c.Request.Body)
|
body, _ := ioutil.ReadAll(c.Request.Body)
|
||||||
ioutil.WriteFile(path, body, 0644)
|
ioutil.WriteFile(path, body, 0644)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="edit-pane">
|
<div id="edit-pane">
|
||||||
<div id="controls">
|
<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>
|
||||||
<div id="editor"></div>
|
<div id="editor"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue