mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 02:17:54 +01:00
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)
|
return options.Gitignore(cleanedName)
|
||||||
case "license":
|
case "license":
|
||||||
return options.License(cleanedName)
|
return options.License(cleanedName)
|
||||||
|
case "label":
|
||||||
|
return options.Labels(cleanedName)
|
||||||
default:
|
default:
|
||||||
return []byte{}, fmt.Errorf("Invalid init file type")
|
return []byte{}, fmt.Errorf("Invalid init file type")
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,11 @@ func License(name string) ([]byte, error) {
|
|||||||
return fileFromDir(path.Join("license", name))
|
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.
|
// fileFromDir is a helper to read files from static or custom path.
|
||||||
func fileFromDir(name string) ([]byte, error) {
|
func fileFromDir(name string) ([]byte, error) {
|
||||||
customPath := path.Join(setting.CustomPath, "options", name)
|
customPath := path.Join(setting.CustomPath, "options", name)
|
||||||
|
@ -72,6 +72,11 @@ func License(name string) ([]byte, error) {
|
|||||||
return fileFromDir(path.Join("license", name))
|
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.
|
// fileFromDir is a helper to read files from bindata or custom path.
|
||||||
func fileFromDir(name string) ([]byte, error) {
|
func fileFromDir(name string) ([]byte, error) {
|
||||||
customPath := path.Join(setting.CustomPath, "options", name)
|
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
|
UseTiDB bool
|
||||||
|
|
||||||
// Webhook settings
|
// Webhook settings
|
||||||
Webhook struct {
|
Webhook = struct {
|
||||||
QueueLength int
|
QueueLength int
|
||||||
DeliverTimeout int
|
DeliverTimeout int
|
||||||
SkipTLSVerify bool
|
SkipTLSVerify bool
|
||||||
Types []string
|
Types []string
|
||||||
PagingNum int
|
PagingNum int
|
||||||
|
}{
|
||||||
|
QueueLength: 1000,
|
||||||
|
DeliverTimeout: 5,
|
||||||
|
SkipTLSVerify: false,
|
||||||
|
PagingNum: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repository settings
|
// Repository settings
|
||||||
Repository struct {
|
Repository = struct {
|
||||||
AnsiCharset string
|
AnsiCharset string
|
||||||
ForcePrivate bool
|
ForcePrivate bool
|
||||||
MaxCreationLimit int
|
MaxCreationLimit int
|
||||||
@ -136,12 +141,44 @@ var (
|
|||||||
FileMaxSize int64
|
FileMaxSize int64
|
||||||
MaxFiles int
|
MaxFiles int
|
||||||
} `ini:"-"`
|
} `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
|
RepoRootPath string
|
||||||
ScriptType string
|
ScriptType = "bash"
|
||||||
|
|
||||||
// UI settings
|
// UI settings
|
||||||
UI struct {
|
UI = struct {
|
||||||
ExplorePagingNum int
|
ExplorePagingNum int
|
||||||
IssuePagingNum int
|
IssuePagingNum int
|
||||||
FeedMaxCommitNum int
|
FeedMaxCommitNum int
|
||||||
@ -157,13 +194,38 @@ var (
|
|||||||
User struct {
|
User struct {
|
||||||
RepoPagingNum int
|
RepoPagingNum int
|
||||||
} `ini:"ui.user"`
|
} `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 sttings
|
||||||
Markdown struct {
|
Markdown = struct {
|
||||||
EnableHardLineBreak bool
|
EnableHardLineBreak bool
|
||||||
CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
|
CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
|
||||||
FileExtensions []string
|
FileExtensions []string
|
||||||
|
}{
|
||||||
|
EnableHardLineBreak: false,
|
||||||
|
FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Picture settings
|
// Picture settings
|
||||||
@ -198,7 +260,7 @@ var (
|
|||||||
CSRFCookieName = "_csrf"
|
CSRFCookieName = "_csrf"
|
||||||
|
|
||||||
// Cron tasks
|
// Cron tasks
|
||||||
Cron struct {
|
Cron = struct {
|
||||||
UpdateMirror struct {
|
UpdateMirror struct {
|
||||||
Enabled bool
|
Enabled bool
|
||||||
RunAtStart bool
|
RunAtStart bool
|
||||||
@ -216,10 +278,37 @@ var (
|
|||||||
RunAtStart bool
|
RunAtStart bool
|
||||||
Schedule string
|
Schedule string
|
||||||
} `ini:"cron.check_repo_stats"`
|
} `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 settings
|
||||||
Git struct {
|
Git = struct {
|
||||||
DisableDiffHighlight bool
|
DisableDiffHighlight bool
|
||||||
MaxGitDiffLines int
|
MaxGitDiffLines int
|
||||||
MaxGitDiffLineCharacters int
|
MaxGitDiffLineCharacters int
|
||||||
@ -232,16 +321,39 @@ var (
|
|||||||
Pull int
|
Pull int
|
||||||
GC int `ini:"GC"`
|
GC int `ini:"GC"`
|
||||||
} `ini:"git.timeout"`
|
} `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 settings
|
||||||
Mirror struct {
|
Mirror = struct {
|
||||||
DefaultInterval int
|
DefaultInterval int
|
||||||
|
}{
|
||||||
|
DefaultInterval: 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
// API settings
|
// API settings
|
||||||
API struct {
|
API = struct {
|
||||||
MaxResponseItems int
|
MaxResponseItems int
|
||||||
|
}{
|
||||||
|
MaxResponseItems: 50,
|
||||||
}
|
}
|
||||||
|
|
||||||
// I18n settings
|
// I18n settings
|
||||||
@ -470,11 +582,11 @@ please consider changing to GITEA_CUSTOM`)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sec = Cfg.Section("security")
|
sec = Cfg.Section("security")
|
||||||
InstallLock = sec.Key("INSTALL_LOCK").MustBool()
|
InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
|
||||||
SecretKey = sec.Key("SECRET_KEY").String()
|
SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
|
||||||
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt()
|
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
|
||||||
CookieUserName = sec.Key("COOKIE_USERNAME").String()
|
CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
|
||||||
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").String()
|
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
|
||||||
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
|
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
|
||||||
|
|
||||||
sec = Cfg.Section("attachment")
|
sec = Cfg.Section("attachment")
|
||||||
@ -597,21 +709,17 @@ please consider changing to GITEA_CUSTOM`)
|
|||||||
|
|
||||||
Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
|
Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
|
||||||
if len(Langs) == 0 {
|
if len(Langs) == 0 {
|
||||||
Langs = []string{
|
Langs = defaultLangs
|
||||||
"en-US",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
|
Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
|
||||||
if len(Names) == 0 {
|
if len(Names) == 0 {
|
||||||
Names = []string{
|
Names = defaultLangNames
|
||||||
"English",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dateLangs = Cfg.Section("i18n.datelang").KeysHash()
|
dateLangs = Cfg.Section("i18n.datelang").KeysHash()
|
||||||
|
|
||||||
ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool()
|
ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
|
||||||
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool()
|
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
|
||||||
ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool()
|
ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
|
||||||
|
|
||||||
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
|
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.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
|
||||||
SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gogits")
|
SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gogits")
|
||||||
SessionConfig.CookiePath = AppSubURL
|
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.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
|
||||||
SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
|
SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user