Add default values for settings (#455)
* add default values for settings * more default values * more default settings and labels resource * mv locale to options
This commit is contained in:
parent
ec1fe1183d
commit
a822bba3e1
@ -843,6 +843,8 @@ func getRepoInitFile(tp, name string) ([]byte, error) {
|
||||
return options.Gitignore(cleanedName)
|
||||
case "license":
|
||||
return options.License(cleanedName)
|
||||
case "label":
|
||||
return options.Labels(cleanedName)
|
||||
default:
|
||||
return []byte{}, fmt.Errorf("Invalid init file type")
|
||||
}
|
||||
|
@ -76,6 +76,11 @@ func License(name string) ([]byte, error) {
|
||||
return fileFromDir(path.Join("license", name))
|
||||
}
|
||||
|
||||
// Labels eads the content of a specific labels from static or custom path.
|
||||
func Labels(name string) ([]byte, error) {
|
||||
return fileFromDir(path.Join("label", name))
|
||||
}
|
||||
|
||||
// fileFromDir is a helper to read files from static or custom path.
|
||||
func fileFromDir(name string) ([]byte, error) {
|
||||
customPath := path.Join(setting.CustomPath, "options", name)
|
||||
|
@ -72,6 +72,11 @@ func License(name string) ([]byte, error) {
|
||||
return fileFromDir(path.Join("license", name))
|
||||
}
|
||||
|
||||
// Labels eads the content of a specific labels from static or custom path.
|
||||
func Labels(name string) ([]byte, error) {
|
||||
return fileFromDir(path.Join("label", name))
|
||||
}
|
||||
|
||||
// fileFromDir is a helper to read files from bindata or custom path.
|
||||
func fileFromDir(name string) ([]byte, error) {
|
||||
customPath := path.Join(setting.CustomPath, "options", name)
|
||||
|
10
modules/setting/defaults.go
Normal file
10
modules/setting/defaults.go
Normal file
@ -0,0 +1,10 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultLangs = strings.Split("en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR", ",")
|
||||
defaultLangNames = strings.Split("English,简体中文,繁體中文(香港),繁體中文(台湾),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano,Suomalainen,Türkçe,čeština,Српски,Svenska,한국어", ",")
|
||||
)
|
@ -104,16 +104,21 @@ var (
|
||||
UseTiDB bool
|
||||
|
||||
// Webhook settings
|
||||
Webhook struct {
|
||||
Webhook = struct {
|
||||
QueueLength int
|
||||
DeliverTimeout int
|
||||
SkipTLSVerify bool
|
||||
Types []string
|
||||
PagingNum int
|
||||
}{
|
||||
QueueLength: 1000,
|
||||
DeliverTimeout: 5,
|
||||
SkipTLSVerify: false,
|
||||
PagingNum: 10,
|
||||
}
|
||||
|
||||
// Repository settings
|
||||
Repository struct {
|
||||
Repository = struct {
|
||||
AnsiCharset string
|
||||
ForcePrivate bool
|
||||
MaxCreationLimit int
|
||||
@ -136,12 +141,44 @@ var (
|
||||
FileMaxSize int64
|
||||
MaxFiles int
|
||||
} `ini:"-"`
|
||||
}{
|
||||
AnsiCharset: "",
|
||||
ForcePrivate: false,
|
||||
MaxCreationLimit: -1,
|
||||
MirrorQueueLength: 1000,
|
||||
PullRequestQueueLength: 1000,
|
||||
PreferredLicenses: []string{"Apache License 2.0,MIT License"},
|
||||
DisableHTTPGit: false,
|
||||
|
||||
// Repository editor settings
|
||||
Editor: struct {
|
||||
LineWrapExtensions []string
|
||||
PreviewableFileModes []string
|
||||
}{
|
||||
LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
|
||||
PreviewableFileModes: []string{"markdown"},
|
||||
},
|
||||
|
||||
// Repository upload settings
|
||||
Upload: struct {
|
||||
Enabled bool
|
||||
TempPath string
|
||||
AllowedTypes []string `delim:"|"`
|
||||
FileMaxSize int64
|
||||
MaxFiles int
|
||||
}{
|
||||
Enabled: true,
|
||||
TempPath: "data/tmp/uploads",
|
||||
AllowedTypes: []string{},
|
||||
FileMaxSize: 3,
|
||||
MaxFiles: 5,
|
||||
},
|
||||
}
|
||||
RepoRootPath string
|
||||
ScriptType string
|
||||
ScriptType = "bash"
|
||||
|
||||
// UI settings
|
||||
UI struct {
|
||||
UI = struct {
|
||||
ExplorePagingNum int
|
||||
IssuePagingNum int
|
||||
FeedMaxCommitNum int
|
||||
@ -157,13 +194,38 @@ var (
|
||||
User struct {
|
||||
RepoPagingNum int
|
||||
} `ini:"ui.user"`
|
||||
}{
|
||||
ExplorePagingNum: 20,
|
||||
IssuePagingNum: 10,
|
||||
FeedMaxCommitNum: 5,
|
||||
ThemeColorMetaTag: `#6cc644`,
|
||||
MaxDisplayFileSize: 8388608,
|
||||
Admin: struct {
|
||||
UserPagingNum int
|
||||
RepoPagingNum int
|
||||
NoticePagingNum int
|
||||
OrgPagingNum int
|
||||
}{
|
||||
UserPagingNum: 50,
|
||||
RepoPagingNum: 50,
|
||||
NoticePagingNum: 25,
|
||||
OrgPagingNum: 50,
|
||||
},
|
||||
User: struct {
|
||||
RepoPagingNum int
|
||||
}{
|
||||
RepoPagingNum: 15,
|
||||
},
|
||||
}
|
||||
|
||||
// Markdown sttings
|
||||
Markdown struct {
|
||||
Markdown = struct {
|
||||
EnableHardLineBreak bool
|
||||
CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
|
||||
FileExtensions []string
|
||||
}{
|
||||
EnableHardLineBreak: false,
|
||||
FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
|
||||
}
|
||||
|
||||
// Picture settings
|
||||
@ -198,7 +260,7 @@ var (
|
||||
CSRFCookieName = "_csrf"
|
||||
|
||||
// Cron tasks
|
||||
Cron struct {
|
||||
Cron = struct {
|
||||
UpdateMirror struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
@ -216,10 +278,37 @@ var (
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
} `ini:"cron.check_repo_stats"`
|
||||
}{
|
||||
UpdateMirror: struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
}{
|
||||
Schedule: "@every 10m",
|
||||
},
|
||||
RepoHealthCheck: struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
Timeout time.Duration
|
||||
Args []string `delim:" "`
|
||||
}{
|
||||
Schedule: "@every 24h",
|
||||
Timeout: 60 * time.Second,
|
||||
Args: []string{},
|
||||
},
|
||||
CheckRepoStats: struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
}{
|
||||
RunAtStart: true,
|
||||
Schedule: "@every 24h",
|
||||
},
|
||||
}
|
||||
|
||||
// Git settings
|
||||
Git struct {
|
||||
Git = struct {
|
||||
DisableDiffHighlight bool
|
||||
MaxGitDiffLines int
|
||||
MaxGitDiffLineCharacters int
|
||||
@ -232,16 +321,39 @@ var (
|
||||
Pull int
|
||||
GC int `ini:"GC"`
|
||||
} `ini:"git.timeout"`
|
||||
}{
|
||||
DisableDiffHighlight: false,
|
||||
MaxGitDiffLines: 1000,
|
||||
MaxGitDiffLineCharacters: 500,
|
||||
MaxGitDiffFiles: 100,
|
||||
GCArgs: []string{},
|
||||
Timeout: struct {
|
||||
Migrate int
|
||||
Mirror int
|
||||
Clone int
|
||||
Pull int
|
||||
GC int `ini:"GC"`
|
||||
}{
|
||||
Migrate: 600,
|
||||
Mirror: 300,
|
||||
Clone: 300,
|
||||
Pull: 300,
|
||||
GC: 60,
|
||||
},
|
||||
}
|
||||
|
||||
// Mirror settings
|
||||
Mirror struct {
|
||||
Mirror = struct {
|
||||
DefaultInterval int
|
||||
}{
|
||||
DefaultInterval: 8,
|
||||
}
|
||||
|
||||
// API settings
|
||||
API struct {
|
||||
API = struct {
|
||||
MaxResponseItems int
|
||||
}{
|
||||
MaxResponseItems: 50,
|
||||
}
|
||||
|
||||
// I18n settings
|
||||
@ -470,11 +582,11 @@ please consider changing to GITEA_CUSTOM`)
|
||||
}
|
||||
|
||||
sec = Cfg.Section("security")
|
||||
InstallLock = sec.Key("INSTALL_LOCK").MustBool()
|
||||
SecretKey = sec.Key("SECRET_KEY").String()
|
||||
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt()
|
||||
CookieUserName = sec.Key("COOKIE_USERNAME").String()
|
||||
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").String()
|
||||
InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
|
||||
SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
|
||||
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
|
||||
CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
|
||||
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
|
||||
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
|
||||
|
||||
sec = Cfg.Section("attachment")
|
||||
@ -597,21 +709,17 @@ please consider changing to GITEA_CUSTOM`)
|
||||
|
||||
Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
|
||||
if len(Langs) == 0 {
|
||||
Langs = []string{
|
||||
"en-US",
|
||||
}
|
||||
Langs = defaultLangs
|
||||
}
|
||||
Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
|
||||
if len(Names) == 0 {
|
||||
Names = []string{
|
||||
"English",
|
||||
}
|
||||
Names = defaultLangNames
|
||||
}
|
||||
dateLangs = Cfg.Section("i18n.datelang").KeysHash()
|
||||
|
||||
ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool()
|
||||
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool()
|
||||
ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool()
|
||||
ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
|
||||
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
|
||||
ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
|
||||
|
||||
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
|
||||
}
|
||||
@ -738,7 +846,7 @@ func newSessionService() {
|
||||
SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
|
||||
SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gogits")
|
||||
SessionConfig.CookiePath = AppSubURL
|
||||
SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool()
|
||||
SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
|
||||
SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
|
||||
SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user