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:
parent
63bdbb5824
commit
684ff4e692
@ -20,8 +20,9 @@ import (
|
|||||||
var customCSS []byte
|
var customCSS []byte
|
||||||
var defaultLock string
|
var defaultLock string
|
||||||
var debounceTime int
|
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)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
store := sessions.NewCookieStore([]byte("secret"))
|
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
|
// set the debounce time
|
||||||
debounceTime = debounce
|
debounceTime = debounce
|
||||||
|
|
||||||
|
// set diary mode
|
||||||
|
diaryMode = diary
|
||||||
|
|
||||||
if TLS {
|
if TLS {
|
||||||
http.ListenAndServeTLS(host+":"+port, crt_path, key_path, router)
|
http.ListenAndServeTLS(host+":"+port, crt_path, key_path, router)
|
||||||
} else {
|
} else {
|
||||||
@ -340,6 +344,8 @@ func handlePageRequest(c *gin.Context) {
|
|||||||
"IsPublished": p.IsPublished,
|
"IsPublished": p.IsPublished,
|
||||||
"CustomCSS": len(customCSS) > 0,
|
"CustomCSS": len(customCSS) > 0,
|
||||||
"Debounce": debounceTime,
|
"Debounce": debounceTime,
|
||||||
|
"DiaryMode": diaryMode,
|
||||||
|
"Date": time.Now().Format("2006-01-02"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
main.go
6
main.go
@ -38,7 +38,7 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("\nRunning cowyo server (version %s) at http://%s:%s\n\n", version, host, c.GlobalString("port"))
|
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
|
return nil
|
||||||
}
|
}
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
@ -96,6 +96,10 @@ func main() {
|
|||||||
Name: "debug, d",
|
Name: "debug, d",
|
||||||
Usage: "turn on debugging",
|
Usage: "turn on debugging",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "diary",
|
||||||
|
Usage: "turn diary mode (doing New will give a timestamped page)",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
{
|
{
|
||||||
|
@ -499,7 +499,11 @@ body#pad textarea {
|
|||||||
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
|
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
|
||||||
<a href="#" id="menuLink1" class="pure-menu-link">{{ .Page }}</a>
|
<a href="#" id="menuLink1" class="pure-menu-link">{{ .Page }}</a>
|
||||||
<ul class="pure-menu-children">
|
<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>
|
<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>
|
<li class="pure-menu-item"><a href="https://github.com/schollz/cowyo" class="pure-menu-link">Source</a></li>
|
||||||
{{ if .EditPage }}
|
{{ if .EditPage }}
|
||||||
<li class="pure-menu-item"><a href="#" class="pure-menu-link" id="publishPage">
|
<li class="pure-menu-item"><a href="#" class="pure-menu-link" id="publishPage">
|
||||||
|
Loading…
Reference in New Issue
Block a user