From 4d83fd4238e177d9327c760a5386bc53f25dedbb Mon Sep 17 00:00:00 2001 From: Michael Li Date: Mon, 17 Feb 2020 22:48:24 +0800 Subject: Use go-bindata to embed `public` and `templates` files into binary (#5920) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixed private repositories are hidden in the organization's view * use go-bindata integrate public and templates files to gogs binary * optimize Dockerfile don't COPY public and templates files * use kevinburke's go-bindata to generate assets code * reset develepment as default run mode in configure file * optimize generated assets code relayout and help function * fixed code format * Update conf/app.ini * assets: add LICENSE headers * Some housekeeping * assets/public: simplify code logic * assets/templates: simplify code logic * cmd/web: more concise variable names * Minor changes * Add custom public and templates support back Co-authored-by: ᴜɴᴋɴᴡᴏɴ --- internal/setting/setting.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'internal/setting') diff --git a/internal/setting/setting.go b/internal/setting/setting.go index 7166f885..1d4bd107 100644 --- a/internal/setting/setting.go +++ b/internal/setting/setting.go @@ -16,18 +16,18 @@ import ( "strings" "time" - "github.com/unknwon/com" _ "github.com/go-macaron/cache/memcache" _ "github.com/go-macaron/cache/redis" "github.com/go-macaron/session" _ "github.com/go-macaron/session/redis" "github.com/mcuadros/go-version" + "github.com/unknwon/com" log "gopkg.in/clog.v1" "gopkg.in/ini.v1" "github.com/gogs/go-libravatar" - "gogs.io/gogs/internal/bindata" + "gogs.io/gogs/internal/assets/conf" "gogs.io/gogs/internal/process" "gogs.io/gogs/internal/user" ) @@ -50,8 +50,8 @@ const ( var ( // Build information should only be set by -ldflags. - BuildTime string - BuildGitHash string + BuildTime string + BuildCommit string // App settings AppVer string @@ -74,6 +74,7 @@ var ( CertFile string KeyFile string TLSMinVersion string + LoadAssetsFromDisk bool StaticRootPath string EnableGzip bool LandingPageURL LandingPage @@ -416,7 +417,7 @@ func NewContext() { Cfg, err = ini.LoadSources(ini.LoadOptions{ IgnoreInlineComment: true, - }, bindata.MustAsset("conf/app.ini")) + }, conf.MustAsset("conf/app.ini")) if err != nil { log.Fatal(2, "Fail to parse 'conf/app.ini': %v", err) } @@ -489,6 +490,7 @@ func NewContext() { LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/") OfflineMode = sec.Key("OFFLINE_MODE").MustBool() DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool() + LoadAssetsFromDisk = sec.Key("LOAD_ASSETS_FROM_DISK").MustBool() StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir) AppDataPath = sec.Key("APP_DATA_PATH").MustString("data") EnableGzip = sec.Key("ENABLE_GZIP").MustBool() @@ -729,8 +731,8 @@ func newService() { func newLogService() { if len(BuildTime) > 0 { - log.Trace("Build Time: %s", BuildTime) - log.Trace("Build Git Hash: %s", BuildGitHash) + log.Trace("Build time: %s", BuildTime) + log.Trace("Build commit: %s", BuildCommit) } // Because we always create a console logger as primary logger before all settings are loaded, @@ -809,7 +811,7 @@ func newLogService() { } log.New(log.MODE(mode), LogConfigs[i]) - log.Trace("Log Mode: %s (%s)", strings.Title(mode), strings.Title(name)) + log.Trace("Log mode: %s (%s)", strings.Title(mode), strings.Title(name)) } // Make sure everyone gets version info printed. @@ -830,7 +832,7 @@ func newCacheService() { log.Fatal(2, "Unknown cache adapter: %s", CacheAdapter) } - log.Info("Cache Service Enabled") + log.Info("Cache service is enabled") } func newSessionService() { @@ -844,7 +846,7 @@ func newSessionService() { SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400) CSRFCookieName = Cfg.Section("session").Key("CSRF_COOKIE_NAME").MustString("_csrf") - log.Info("Session Service Enabled") + log.Info("Session service is enabled") } // Mailer represents mail service. -- cgit v1.2.3