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:
parent
180a28cda6
commit
a976007642
3
main.go
3
main.go
@ -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")),
|
||||||
|
@ -35,7 +35,6 @@ type Site struct {
|
|||||||
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
|
||||||
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user