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

Fixup: Debug mode broken

This commit is contained in:
Daniel Heath 2018-04-30 20:19:11 +10:00
parent 180a28cda6
commit a976007642
2 changed files with 16 additions and 20 deletions

View File

@ -13,7 +13,6 @@ import (
) )
var version string var version string
var hotTemplateReloading bool
var pathToData string var pathToData string
func main() { func main() {
@ -23,7 +22,6 @@ func main() {
app.Version = version app.Version = version
app.Compiled = time.Now() app.Compiled = time.Now()
app.Action = func(c *cli.Context) error { app.Action = func(c *cli.Context) error {
pathToData = c.GlobalString("data") pathToData = c.GlobalString("data")
os.MkdirAll(pathToData, 0755) os.MkdirAll(pathToData, 0755)
host := c.GlobalString("host") host := c.GlobalString("host")
@ -57,7 +55,6 @@ func main() {
c.GlobalString("cookie-secret"), c.GlobalString("cookie-secret"),
c.GlobalString("access-code"), c.GlobalString("access-code"),
c.GlobalBool("allow-insecure-markup"), c.GlobalBool("allow-insecure-markup"),
hotTemplateReloading,
c.GlobalBool("allow-file-uploads"), c.GlobalBool("allow-file-uploads"),
c.GlobalUint("max-upload-mb"), c.GlobalUint("max-upload-mb"),
logger(c.GlobalBool("debug")), logger(c.GlobalBool("debug")),

View File

@ -26,19 +26,18 @@ import (
const minutesToUnlock = 10.0 const minutesToUnlock = 10.0
type Site struct { type Site struct {
PathToData string PathToData string
Css []byte Css []byte
DefaultPage string DefaultPage string
DefaultPassword string DefaultPassword string
Debounce int Debounce int
Diary bool Diary bool
SessionStore sessions.Store SessionStore sessions.Store
SecretCode string SecretCode string
AllowInsecure bool AllowInsecure bool
HotTemplateReloading bool Fileuploads bool
Fileuploads bool MaxUploadSize uint
MaxUploadSize uint Logger *lumber.ConsoleLogger
Logger *lumber.ConsoleLogger
saveMut sync.Mutex saveMut sync.Mutex
sitemapUpToDate bool // TODO this makes everything use a pointer sitemapUpToDate bool // TODO this makes everything use a pointer
@ -51,6 +50,8 @@ func (s *Site) defaultLock() string {
return HashPassword(s.DefaultPassword) return HashPassword(s.DefaultPassword)
} }
var hotTemplateReloading bool
func Serve( func Serve(
filepathToData, filepathToData,
host, host,
@ -66,7 +67,6 @@ func Serve(
secret string, secret string,
secretCode string, secretCode string,
allowInsecure bool, allowInsecure bool,
hotTemplateReloading bool,
fileuploads bool, fileuploads bool,
maxUploadSize uint, maxUploadSize uint,
logger *lumber.ConsoleLogger, logger *lumber.ConsoleLogger,
@ -93,7 +93,6 @@ func Serve(
sessions.NewCookieStore([]byte(secret)), sessions.NewCookieStore([]byte(secret)),
secretCode, secretCode,
allowInsecure, allowInsecure,
hotTemplateReloading,
fileuploads, fileuploads,
maxUploadSize, maxUploadSize,
logger, logger,
@ -113,7 +112,7 @@ func (s Site) Router() *gin.Engine {
s.Logger = lumber.NewConsoleLogger(lumber.TRACE) s.Logger = lumber.NewConsoleLogger(lumber.TRACE)
} }
if s.HotTemplateReloading { if hotTemplateReloading {
gin.SetMode(gin.DebugMode) gin.SetMode(gin.DebugMode)
} else { } else {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
@ -124,7 +123,7 @@ func (s Site) Router() *gin.Engine {
"sniffContentType": s.sniffContentType, "sniffContentType": s.sniffContentType,
}) })
if s.HotTemplateReloading { if hotTemplateReloading {
router.LoadHTMLGlob("templates/*.tmpl") router.LoadHTMLGlob("templates/*.tmpl")
} else { } else {
router.HTMLRender = s.loadTemplates("index.tmpl") router.HTMLRender = s.loadTemplates("index.tmpl")