1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Add -diary for diary mode

New creates a new page with a timestamp
This commit is contained in:
Zack Scholl 2017-11-04 16:09:10 -06:00
parent 63bdbb5824
commit 684ff4e692
3 changed files with 16 additions and 2 deletions

View File

@ -20,8 +20,9 @@ import (
var customCSS []byte
var defaultLock string
var debounceTime int
var diaryMode bool
func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defaultPage string, defaultPassword string, debounce int) {
func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defaultPage string, defaultPassword string, debounce int, diary bool) {
gin.SetMode(gin.ReleaseMode)
router := gin.Default()
store := sessions.NewCookieStore([]byte("secret"))
@ -73,6 +74,9 @@ func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defa
// set the debounce time
debounceTime = debounce
// set diary mode
diaryMode = diary
if TLS {
http.ListenAndServeTLS(host+":"+port, crt_path, key_path, router)
} else {
@ -340,6 +344,8 @@ func handlePageRequest(c *gin.Context) {
"IsPublished": p.IsPublished,
"CustomCSS": len(customCSS) > 0,
"Debounce": debounceTime,
"DiaryMode": diaryMode,
"Date": time.Now().Format("2006-01-02"),
})
}

View File

@ -38,7 +38,7 @@ func main() {
} else {
fmt.Printf("\nRunning cowyo server (version %s) at http://%s:%s\n\n", version, host, c.GlobalString("port"))
}
serve(c.GlobalString("host"), c.GlobalString("port"), c.GlobalString("cert"), c.GlobalString("key"), TLS, c.GlobalString("css"), c.GlobalString("default-page"), c.GlobalString("lock"), c.GlobalInt("debounce"))
serve(c.GlobalString("host"), c.GlobalString("port"), c.GlobalString("cert"), c.GlobalString("key"), TLS, c.GlobalString("css"), c.GlobalString("default-page"), c.GlobalString("lock"), c.GlobalInt("debounce"), c.GlobalBool("diary"))
return nil
}
app.Flags = []cli.Flag{
@ -96,6 +96,10 @@ func main() {
Name: "debug, d",
Usage: "turn on debugging",
},
cli.BoolFlag{
Name: "diary",
Usage: "turn diary mode (doing New will give a timestamped page)",
},
}
app.Commands = []cli.Command{
{

View File

@ -499,7 +499,11 @@ body#pad textarea {
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
<a href="#" id="menuLink1" class="pure-menu-link">{{ .Page }}</a>
<ul class="pure-menu-children">
{{ if .DiaryMode }}
<li class="pure-menu-item"><a href="/{{ .Date }}/edit" class="pure-menu-link">New</a></li>
{{ else }}
<li class="pure-menu-item"><a href="/" class="pure-menu-link">New</a></li>
{{ end }}
<li class="pure-menu-item"><a href="https://github.com/schollz/cowyo" class="pure-menu-link">Source</a></li>
{{ if .EditPage }}
<li class="pure-menu-item"><a href="#" class="pure-menu-link" id="publishPage">