mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +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:
		| @@ -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) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user