diff --git a/main.go b/main.go index d40e79e..f3fc5a0 100755 --- a/main.go +++ b/main.go @@ -13,7 +13,6 @@ import ( ) var version string -var hotTemplateReloading bool var pathToData string func main() { @@ -23,7 +22,6 @@ func main() { app.Version = version app.Compiled = time.Now() app.Action = func(c *cli.Context) error { - pathToData = c.GlobalString("data") os.MkdirAll(pathToData, 0755) host := c.GlobalString("host") @@ -57,7 +55,6 @@ func main() { c.GlobalString("cookie-secret"), c.GlobalString("access-code"), c.GlobalBool("allow-insecure-markup"), - hotTemplateReloading, c.GlobalBool("allow-file-uploads"), c.GlobalUint("max-upload-mb"), logger(c.GlobalBool("debug")), diff --git a/server/handlers.go b/server/handlers.go index 4b83b30..6fbdaf4 100755 --- a/server/handlers.go +++ b/server/handlers.go @@ -26,19 +26,18 @@ import ( const minutesToUnlock = 10.0 type Site struct { - PathToData string - Css []byte - DefaultPage string - DefaultPassword string - Debounce int - Diary bool - SessionStore sessions.Store - SecretCode string - AllowInsecure bool - HotTemplateReloading bool - Fileuploads bool - MaxUploadSize uint - Logger *lumber.ConsoleLogger + PathToData string + Css []byte + DefaultPage string + DefaultPassword string + Debounce int + Diary bool + SessionStore sessions.Store + SecretCode string + AllowInsecure bool + Fileuploads bool + MaxUploadSize uint + Logger *lumber.ConsoleLogger saveMut sync.Mutex sitemapUpToDate bool // TODO this makes everything use a pointer @@ -51,6 +50,8 @@ func (s *Site) defaultLock() string { return HashPassword(s.DefaultPassword) } +var hotTemplateReloading bool + func Serve( filepathToData, host, @@ -66,7 +67,6 @@ func Serve( secret string, secretCode string, allowInsecure bool, - hotTemplateReloading bool, fileuploads bool, maxUploadSize uint, logger *lumber.ConsoleLogger, @@ -93,7 +93,6 @@ func Serve( sessions.NewCookieStore([]byte(secret)), secretCode, allowInsecure, - hotTemplateReloading, fileuploads, maxUploadSize, logger, @@ -113,7 +112,7 @@ func (s Site) Router() *gin.Engine { s.Logger = lumber.NewConsoleLogger(lumber.TRACE) } - if s.HotTemplateReloading { + if hotTemplateReloading { gin.SetMode(gin.DebugMode) } else { gin.SetMode(gin.ReleaseMode) @@ -124,7 +123,7 @@ func (s Site) Router() *gin.Engine { "sniffContentType": s.sniffContentType, }) - if s.HotTemplateReloading { + if hotTemplateReloading { router.LoadHTMLGlob("templates/*.tmpl") } else { router.HTMLRender = s.loadTemplates("index.tmpl")