diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-23 15:18:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-23 15:18:05 +0800 |
commit | a822bba3e1a598bf17a17d1d03cf7f1544b6de42 (patch) | |
tree | 5162b8c697e794abe21a24643b77dcb05839bf91 /modules/setting | |
parent | ec1fe1183d78b64d6687226fa59c7107f7a07940 (diff) | |
download | gitea-a822bba3e1a598bf17a17d1d03cf7f1544b6de42.tar.gz gitea-a822bba3e1a598bf17a17d1d03cf7f1544b6de42.zip |
Add default values for settings (#455)
* add default values for settings
* more default values
* more default settings and labels resource
* mv locale to options
Diffstat (limited to 'modules/setting')
-rw-r--r-- | modules/setting/defaults.go | 10 | ||||
-rw-r--r-- | modules/setting/setting.go | 156 |
2 files changed, 142 insertions, 24 deletions
diff --git a/modules/setting/defaults.go b/modules/setting/defaults.go new file mode 100644 index 0000000000..ac7a34b45d --- /dev/null +++ b/modules/setting/defaults.go @@ -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,한국어", ",") +) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 3dca675ecc..c82fa9ae6d 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -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) |