-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default values for settings #455
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,한국어", ",") | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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&*(") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? This gets generated for me on the installer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, it's a good idea to give it a default value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But does it still generate a random new string on install? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. generate a random will always on installation and write back to ini file. |
||
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) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This default worked well for me, I had the installer initially.