diff --git a/handlers.go b/handlers.go index b93cb9c..8e2af88 100755 --- a/handlers.go +++ b/handlers.go @@ -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"), }) } diff --git a/main.go b/main.go index 1702bad..22471b3 100755 --- a/main.go +++ b/main.go @@ -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{ { diff --git a/templates/index.tmpl b/templates/index.tmpl index 448ba95..38ebbe2 100755 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -499,7 +499,11 @@ body#pad textarea {