2019-02-10 02:37:37 +01:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-02-10 02:37:37 +01:00
|
|
|
|
|
|
|
package setting
|
|
|
|
|
2019-02-18 17:00:27 +01:00
|
|
|
import (
|
|
|
|
"regexp"
|
2021-06-26 00:38:27 +02:00
|
|
|
"strings"
|
2021-01-22 03:56:19 +01:00
|
|
|
"time"
|
2019-02-18 17:00:27 +01:00
|
|
|
|
2021-03-11 14:40:54 +01:00
|
|
|
"code.gitea.io/gitea/modules/log"
|
2019-02-18 17:00:27 +01:00
|
|
|
"code.gitea.io/gitea/modules/structs"
|
2023-05-22 02:05:44 +02:00
|
|
|
|
|
|
|
"github.com/gobwas/glob"
|
2019-02-18 17:00:27 +01:00
|
|
|
)
|
2019-02-10 02:37:37 +01:00
|
|
|
|
2023-02-19 17:12:01 +01:00
|
|
|
// enumerates all the types of captchas
|
|
|
|
const (
|
|
|
|
ImageCaptcha = "image"
|
|
|
|
ReCaptcha = "recaptcha"
|
|
|
|
HCaptcha = "hcaptcha"
|
|
|
|
MCaptcha = "mcaptcha"
|
|
|
|
CfTurnstile = "cfturnstile"
|
|
|
|
)
|
|
|
|
|
2019-02-10 02:37:37 +01:00
|
|
|
// Service settings
|
2021-06-27 20:47:35 +02:00
|
|
|
var Service = struct {
|
2021-06-26 21:53:14 +02:00
|
|
|
DefaultUserVisibility string
|
|
|
|
DefaultUserVisibilityMode structs.VisibleType
|
2021-06-27 20:47:35 +02:00
|
|
|
AllowedUserVisibilityModes []string
|
|
|
|
AllowedUserVisibilityModesSlice AllowedVisibility `ini:"-"`
|
2019-02-18 17:00:27 +01:00
|
|
|
DefaultOrgVisibility string
|
|
|
|
DefaultOrgVisibilityMode structs.VisibleType
|
2019-02-10 02:37:37 +01:00
|
|
|
ActiveCodeLives int
|
|
|
|
ResetPwdCodeLives int
|
|
|
|
RegisterEmailConfirm bool
|
2020-12-20 02:31:06 +01:00
|
|
|
RegisterManualConfirm bool
|
2023-05-22 02:05:44 +02:00
|
|
|
EmailDomainAllowList []glob.Glob
|
|
|
|
EmailDomainBlockList []glob.Glob
|
2019-02-10 02:37:37 +01:00
|
|
|
DisableRegistration bool
|
2021-05-09 16:13:35 +02:00
|
|
|
AllowOnlyInternalRegistration bool
|
2019-02-10 02:37:37 +01:00
|
|
|
AllowOnlyExternalRegistration bool
|
|
|
|
ShowRegistrationButton bool
|
2019-12-15 15:20:08 +01:00
|
|
|
ShowMilestonesDashboardPage bool
|
2019-02-10 02:37:37 +01:00
|
|
|
RequireSignInView bool
|
|
|
|
EnableNotifyMail bool
|
2019-10-19 16:27:15 +02:00
|
|
|
EnableBasicAuth bool
|
2019-02-10 02:37:37 +01:00
|
|
|
EnableReverseProxyAuth bool
|
|
|
|
EnableReverseProxyAutoRegister bool
|
|
|
|
EnableReverseProxyEmail bool
|
2022-08-16 08:30:27 +02:00
|
|
|
EnableReverseProxyFullName bool
|
2019-02-10 02:37:37 +01:00
|
|
|
EnableCaptcha bool
|
2022-11-22 22:13:18 +01:00
|
|
|
RequireCaptchaForLogin bool
|
2019-07-06 21:48:02 +02:00
|
|
|
RequireExternalRegistrationCaptcha bool
|
|
|
|
RequireExternalRegistrationPassword bool
|
2019-02-10 02:37:37 +01:00
|
|
|
CaptchaType string
|
|
|
|
RecaptchaSecret string
|
|
|
|
RecaptchaSitekey string
|
2019-05-02 15:09:39 +02:00
|
|
|
RecaptchaURL string
|
2023-02-05 08:29:03 +01:00
|
|
|
CfTurnstileSecret string
|
|
|
|
CfTurnstileSitekey string
|
2020-10-03 05:37:53 +02:00
|
|
|
HcaptchaSecret string
|
|
|
|
HcaptchaSitekey string
|
2022-08-10 15:20:10 +02:00
|
|
|
McaptchaSecret string
|
|
|
|
McaptchaSitekey string
|
|
|
|
McaptchaURL string
|
2019-02-10 02:37:37 +01:00
|
|
|
DefaultKeepEmailPrivate bool
|
|
|
|
DefaultAllowCreateOrganization bool
|
2021-07-15 21:19:48 +02:00
|
|
|
DefaultUserIsRestricted bool
|
2023-06-12 13:57:01 +02:00
|
|
|
AllowDotsInUsernames bool
|
2019-02-10 02:37:37 +01:00
|
|
|
EnableTimetracking bool
|
|
|
|
DefaultEnableTimetracking bool
|
|
|
|
DefaultEnableDependencies bool
|
Allow cross-repository dependencies on issues (#7901)
* in progress changes for #7405, added ability to add cross-repo dependencies
* removed unused repolink var
* fixed query that was breaking ci tests; fixed check in issue dependency add so that the id of the issue and dependency is checked rather than the indexes
* reverted removal of string in local files becasue these are done via crowdin, not updated manually
* removed 'Select("issue.*")' from getBlockedByDependencies and getBlockingDependencies based on comments in PR review
* changed getBlockedByDependencies and getBlockingDependencies to use a more xorm-like query, also updated the sidebar as a result
* simplified the getBlockingDependencies and getBlockedByDependencies methods; changed the sidebar to show the dependencies in a different format where you can see the name of the repository
* made some changes to the issue view in the dependencies (issue name on top, repo full name on separate line). Change view of issue in the dependency search results (also showing the full repo name on separate line)
* replace call to FindUserAccessibleRepoIDs with SearchRepositoryByName. The former was hardcoded to use isPrivate = false on the repo search, but this code needed it to be true. The SearchRepositoryByName method is used more in the code including on the user's dashboard
* some more tweaks to the layout of the issues when showing dependencies and in the search box when you add new dependencies
* added Name to the RepositoryMeta struct
* updated swagger doc
* fixed total count for link header on SearchIssues
* fixed indentation
* fixed aligment of remove icon on dependencies in issue sidebar
* removed unnecessary nil check (unnecessary because issue.loadRepo is called prior to this block)
* reverting .css change, somehow missed or forgot that less is used
* updated less file and generated css; updated sidebar template with styles to line up delete and issue index
* added ordering to the blocked by/depends on queries
* fixed sorting in issue dependency search and the depends on/blocks views to show issues from the current repo first, then by created date descending; added a "all cross repository dependencies" setting to allow this feature to be turned off, if turned off, the issue dependency search will work the way it did before (restricted to the current repository)
* re-applied my swagger changes after merge
* fixed split string condition in issue search
* changed ALLOW_CROSS_REPOSITORY_DEPENDENCIES description to sound more global than just the issue dependency search; returning 400 in the cross repo issue search api method if not enabled; fixed bug where the issue count did not respect the state parameter
* when adding a dependency to an issue, added a check to make sure the issue and dependency are in the same repo if cross repo dependencies is not enabled
* updated sortIssuesSession call in PullRequests, another commit moved this method from pull.go to pull_list.go so I had to re-apply my change here
* fixed incorrect setting of user id parameter in search repos call
2019-10-31 06:06:10 +01:00
|
|
|
AllowCrossRepositoryDependencies bool
|
2019-02-10 02:37:37 +01:00
|
|
|
DefaultAllowOnlyContributorsToTrackTime bool
|
|
|
|
NoReplyAddress string
|
[GITEA] Add OpenStreetMap URL to Location field in profile
Not too important, but I think that it'd be a pretty neat touch.
(cherry picked from commit 64de4e02f9ed776bc751354d39fc652ea5c2ef19)
Add placeholder text
(cherry picked from commit 1396e2716b57c8cc3f635837696b6c65edda3ea2)
Add test for OSM feature (doesn't work yet)
(cherry picked from commit 2c94e6d56f6444946bcdff3f24776e4532903b8c)
Lint tests (sorry, I'm a bit tired)
(cherry picked from commit 5731fbb4a4f800e1f38eba34a9db98913287928e)
It finally works, will add more tests later.
(cherry picked from commit 4437292622e689ae7afbada9bcc84186560c1cf9)
Improve testing
(cherry picked from commit 56a028ec96e232cfec32956f7c9908f6a059513d)
Introduce new button for OpenStreetMap URL
(cherry picked from commit 852317b46734ca5c929b4b12fb067c14e51d0f1b)
16, "gt-mr-2" in *all* icons
(cherry picked from commit c2c60a01eb0be9062000bc5b8cf7a4fdb534a2f0)
Wait, I forgot about *that* icon
(cherry picked from commit 9930f9b8f2b06d9593b256e4afee0109970a15f8)
Alright, we just made all the icons in that submenu a bit bolder and more consistent.
(cherry picked from commit d5c0009ad01fbf0486620b7c00351a6d1d01b6aa)
Remove | Safe attribute, it does exactly the opposite of what I intended it to.
(cherry picked from commit 1254f2aa9df3ba046d3067ffa49978cf053cdf39)
Make OSM button configurable
(cherry picked from commit ba3d76f5ba1621356390412a3767fc2daa6bfae7)
Fix tests (tested)
(cherry picked from commit 22983c65f8b143d26600d02b2615d4b36b02000f)
Add more tests
(cherry picked from commit 4bbcbd37e138c68d3b9329cb2dbcfd8aad430c79)
Add tooltip
(cherry picked from commit b906008ff1792f6e6e3acaa6e7c71be30c009dd2)
Revert "16, "gt-mr-2" in *all* icons"
This reverts commit c2c60a01eb0be9062000bc5b8cf7a4fdb534a2f0.
(cherry picked from commit 02bb52617dbf93d96bb69183ea8879e7e2e28d50)
Revert "Wait, I forgot about *that* icon"
This reverts commit 9930f9b8f2b06d9593b256e4afee0109970a15f8.
(cherry picked from commit a36d6575090124cac2b46b288cbb6f5c1df482ea)
Revert "Alright, we just made all the icons in that submenu a bit bolder and more consistent."
This reverts commit d5c0009ad01fbf0486620b7c00351a6d1d01b6aa.
(cherry picked from commit 27d8d1c5fc6418cb55430fc3f093a2e02ffaeb93)
2023-07-19 21:29:19 +02:00
|
|
|
EnableOSMButton bool
|
2019-02-10 02:37:37 +01:00
|
|
|
EnableUserHeatmap bool
|
|
|
|
AutoWatchNewRepos bool
|
2019-11-10 10:22:19 +01:00
|
|
|
AutoWatchOnChanges bool
|
2019-08-24 14:28:59 +02:00
|
|
|
DefaultOrgMemberVisible bool
|
2021-01-22 03:56:19 +01:00
|
|
|
UserDeleteWithCommentsMaxTime time.Duration
|
2021-06-26 00:38:27 +02:00
|
|
|
ValidSiteURLSchemes []string
|
2019-02-10 02:37:37 +01:00
|
|
|
|
|
|
|
// OpenID settings
|
|
|
|
EnableOpenIDSignIn bool
|
|
|
|
EnableOpenIDSignUp bool
|
|
|
|
OpenIDWhitelist []*regexp.Regexp
|
|
|
|
OpenIDBlacklist []*regexp.Regexp
|
2021-03-11 14:40:54 +01:00
|
|
|
|
|
|
|
// Explore page settings
|
|
|
|
Explore struct {
|
|
|
|
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
|
|
|
|
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
|
|
|
|
} `ini:"service.explore"`
|
2021-06-27 20:47:35 +02:00
|
|
|
}{
|
|
|
|
AllowedUserVisibilityModesSlice: []bool{true, true, true},
|
|
|
|
}
|
|
|
|
|
|
|
|
// AllowedVisibility store in a 3 item bool array what is allowed
|
|
|
|
type AllowedVisibility []bool
|
|
|
|
|
|
|
|
// IsAllowedVisibility check if a AllowedVisibility allow a specific VisibleType
|
|
|
|
func (a AllowedVisibility) IsAllowedVisibility(t structs.VisibleType) bool {
|
|
|
|
if int(t) >= len(a) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return a[t]
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToVisibleTypeSlice convert a AllowedVisibility into a VisibleType slice
|
|
|
|
func (a AllowedVisibility) ToVisibleTypeSlice() (result []structs.VisibleType) {
|
|
|
|
for i, v := range a {
|
|
|
|
if v {
|
|
|
|
result = append(result, structs.VisibleType(i))
|
|
|
|
}
|
|
|
|
}
|
2022-06-20 12:02:49 +02:00
|
|
|
return result
|
2019-02-10 02:37:37 +01:00
|
|
|
}
|
|
|
|
|
2023-05-22 02:05:44 +02:00
|
|
|
func CompileEmailGlobList(sec ConfigSection, keys ...string) (globs []glob.Glob) {
|
|
|
|
for _, key := range keys {
|
|
|
|
list := sec.Key(key).Strings(",")
|
|
|
|
for _, s := range list {
|
|
|
|
if g, err := glob.Compile(s); err == nil {
|
|
|
|
globs = append(globs, g)
|
|
|
|
} else {
|
|
|
|
log.Error("Skip invalid email allow/block list expression %q: %v", s, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return globs
|
|
|
|
}
|
|
|
|
|
2023-02-19 17:12:01 +01:00
|
|
|
func loadServiceFrom(rootCfg ConfigProvider) {
|
|
|
|
sec := rootCfg.Section("service")
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
|
|
|
|
Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
|
|
|
|
Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
|
2021-05-09 16:13:35 +02:00
|
|
|
Service.AllowOnlyInternalRegistration = sec.Key("ALLOW_ONLY_INTERNAL_REGISTRATION").MustBool()
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
|
2021-05-09 16:13:35 +02:00
|
|
|
if Service.AllowOnlyExternalRegistration && Service.AllowOnlyInternalRegistration {
|
|
|
|
log.Warn("ALLOW_ONLY_INTERNAL_REGISTRATION and ALLOW_ONLY_EXTERNAL_REGISTRATION are true - disabling registration")
|
|
|
|
Service.DisableRegistration = true
|
|
|
|
}
|
2020-12-20 02:31:06 +01:00
|
|
|
if !sec.Key("REGISTER_EMAIL_CONFIRM").MustBool() {
|
2021-01-26 02:20:59 +01:00
|
|
|
Service.RegisterManualConfirm = sec.Key("REGISTER_MANUAL_CONFIRM").MustBool(false)
|
2020-12-20 02:31:06 +01:00
|
|
|
} else {
|
|
|
|
Service.RegisterManualConfirm = false
|
|
|
|
}
|
2023-05-22 02:05:44 +02:00
|
|
|
if sec.HasKey("EMAIL_DOMAIN_WHITELIST") {
|
|
|
|
deprecatedSetting(rootCfg, "service", "EMAIL_DOMAIN_WHITELIST", "service", "EMAIL_DOMAIN_ALLOWLIST", "1.21")
|
|
|
|
}
|
|
|
|
Service.EmailDomainAllowList = CompileEmailGlobList(sec, "EMAIL_DOMAIN_WHITELIST", "EMAIL_DOMAIN_ALLOWLIST")
|
|
|
|
Service.EmailDomainBlockList = CompileEmailGlobList(sec, "EMAIL_DOMAIN_BLOCKLIST")
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
|
2019-12-15 15:20:08 +01:00
|
|
|
Service.ShowMilestonesDashboardPage = sec.Key("SHOW_MILESTONES_DASHBOARD_PAGE").MustBool(true)
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
|
2019-10-19 16:27:15 +02:00
|
|
|
Service.EnableBasicAuth = sec.Key("ENABLE_BASIC_AUTHENTICATION").MustBool(true)
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
|
|
|
|
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
|
|
|
|
Service.EnableReverseProxyEmail = sec.Key("ENABLE_REVERSE_PROXY_EMAIL").MustBool()
|
2022-08-16 08:30:27 +02:00
|
|
|
Service.EnableReverseProxyFullName = sec.Key("ENABLE_REVERSE_PROXY_FULL_NAME").MustBool()
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool(false)
|
2022-11-22 22:13:18 +01:00
|
|
|
Service.RequireCaptchaForLogin = sec.Key("REQUIRE_CAPTCHA_FOR_LOGIN").MustBool(false)
|
2019-07-06 21:48:02 +02:00
|
|
|
Service.RequireExternalRegistrationCaptcha = sec.Key("REQUIRE_EXTERNAL_REGISTRATION_CAPTCHA").MustBool(Service.EnableCaptcha)
|
|
|
|
Service.RequireExternalRegistrationPassword = sec.Key("REQUIRE_EXTERNAL_REGISTRATION_PASSWORD").MustBool()
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.CaptchaType = sec.Key("CAPTCHA_TYPE").MustString(ImageCaptcha)
|
|
|
|
Service.RecaptchaSecret = sec.Key("RECAPTCHA_SECRET").MustString("")
|
|
|
|
Service.RecaptchaSitekey = sec.Key("RECAPTCHA_SITEKEY").MustString("")
|
2019-05-02 15:09:39 +02:00
|
|
|
Service.RecaptchaURL = sec.Key("RECAPTCHA_URL").MustString("https://www.google.com/recaptcha/")
|
2023-02-05 08:29:03 +01:00
|
|
|
Service.CfTurnstileSecret = sec.Key("CF_TURNSTILE_SECRET").MustString("")
|
|
|
|
Service.CfTurnstileSitekey = sec.Key("CF_TURNSTILE_SITEKEY").MustString("")
|
2020-10-03 05:37:53 +02:00
|
|
|
Service.HcaptchaSecret = sec.Key("HCAPTCHA_SECRET").MustString("")
|
|
|
|
Service.HcaptchaSitekey = sec.Key("HCAPTCHA_SITEKEY").MustString("")
|
2022-08-10 15:20:10 +02:00
|
|
|
Service.McaptchaURL = sec.Key("MCAPTCHA_URL").MustString("https://demo.mcaptcha.org/")
|
|
|
|
Service.McaptchaSecret = sec.Key("MCAPTCHA_SECRET").MustString("")
|
|
|
|
Service.McaptchaSitekey = sec.Key("MCAPTCHA_SITEKEY").MustString("")
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
|
|
|
|
Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
|
2021-07-15 21:19:48 +02:00
|
|
|
Service.DefaultUserIsRestricted = sec.Key("DEFAULT_USER_IS_RESTRICTED").MustBool(false)
|
2023-06-12 13:57:01 +02:00
|
|
|
Service.AllowDotsInUsernames = sec.Key("ALLOW_DOTS_IN_USERNAMES").MustBool(true)
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.EnableTimetracking = sec.Key("ENABLE_TIMETRACKING").MustBool(true)
|
|
|
|
if Service.EnableTimetracking {
|
|
|
|
Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
|
|
|
|
}
|
|
|
|
Service.DefaultEnableDependencies = sec.Key("DEFAULT_ENABLE_DEPENDENCIES").MustBool(true)
|
Allow cross-repository dependencies on issues (#7901)
* in progress changes for #7405, added ability to add cross-repo dependencies
* removed unused repolink var
* fixed query that was breaking ci tests; fixed check in issue dependency add so that the id of the issue and dependency is checked rather than the indexes
* reverted removal of string in local files becasue these are done via crowdin, not updated manually
* removed 'Select("issue.*")' from getBlockedByDependencies and getBlockingDependencies based on comments in PR review
* changed getBlockedByDependencies and getBlockingDependencies to use a more xorm-like query, also updated the sidebar as a result
* simplified the getBlockingDependencies and getBlockedByDependencies methods; changed the sidebar to show the dependencies in a different format where you can see the name of the repository
* made some changes to the issue view in the dependencies (issue name on top, repo full name on separate line). Change view of issue in the dependency search results (also showing the full repo name on separate line)
* replace call to FindUserAccessibleRepoIDs with SearchRepositoryByName. The former was hardcoded to use isPrivate = false on the repo search, but this code needed it to be true. The SearchRepositoryByName method is used more in the code including on the user's dashboard
* some more tweaks to the layout of the issues when showing dependencies and in the search box when you add new dependencies
* added Name to the RepositoryMeta struct
* updated swagger doc
* fixed total count for link header on SearchIssues
* fixed indentation
* fixed aligment of remove icon on dependencies in issue sidebar
* removed unnecessary nil check (unnecessary because issue.loadRepo is called prior to this block)
* reverting .css change, somehow missed or forgot that less is used
* updated less file and generated css; updated sidebar template with styles to line up delete and issue index
* added ordering to the blocked by/depends on queries
* fixed sorting in issue dependency search and the depends on/blocks views to show issues from the current repo first, then by created date descending; added a "all cross repository dependencies" setting to allow this feature to be turned off, if turned off, the issue dependency search will work the way it did before (restricted to the current repository)
* re-applied my swagger changes after merge
* fixed split string condition in issue search
* changed ALLOW_CROSS_REPOSITORY_DEPENDENCIES description to sound more global than just the issue dependency search; returning 400 in the cross repo issue search api method if not enabled; fixed bug where the issue count did not respect the state parameter
* when adding a dependency to an issue, added a check to make sure the issue and dependency are in the same repo if cross repo dependencies is not enabled
* updated sortIssuesSession call in PullRequests, another commit moved this method from pull.go to pull_list.go so I had to re-apply my change here
* fixed incorrect setting of user id parameter in search repos call
2019-10-31 06:06:10 +01:00
|
|
|
Service.AllowCrossRepositoryDependencies = sec.Key("ALLOW_CROSS_REPOSITORY_DEPENDENCIES").MustBool(true)
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
|
2019-12-14 05:14:43 +01:00
|
|
|
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply." + Domain)
|
[GITEA] Add OpenStreetMap URL to Location field in profile
Not too important, but I think that it'd be a pretty neat touch.
(cherry picked from commit 64de4e02f9ed776bc751354d39fc652ea5c2ef19)
Add placeholder text
(cherry picked from commit 1396e2716b57c8cc3f635837696b6c65edda3ea2)
Add test for OSM feature (doesn't work yet)
(cherry picked from commit 2c94e6d56f6444946bcdff3f24776e4532903b8c)
Lint tests (sorry, I'm a bit tired)
(cherry picked from commit 5731fbb4a4f800e1f38eba34a9db98913287928e)
It finally works, will add more tests later.
(cherry picked from commit 4437292622e689ae7afbada9bcc84186560c1cf9)
Improve testing
(cherry picked from commit 56a028ec96e232cfec32956f7c9908f6a059513d)
Introduce new button for OpenStreetMap URL
(cherry picked from commit 852317b46734ca5c929b4b12fb067c14e51d0f1b)
16, "gt-mr-2" in *all* icons
(cherry picked from commit c2c60a01eb0be9062000bc5b8cf7a4fdb534a2f0)
Wait, I forgot about *that* icon
(cherry picked from commit 9930f9b8f2b06d9593b256e4afee0109970a15f8)
Alright, we just made all the icons in that submenu a bit bolder and more consistent.
(cherry picked from commit d5c0009ad01fbf0486620b7c00351a6d1d01b6aa)
Remove | Safe attribute, it does exactly the opposite of what I intended it to.
(cherry picked from commit 1254f2aa9df3ba046d3067ffa49978cf053cdf39)
Make OSM button configurable
(cherry picked from commit ba3d76f5ba1621356390412a3767fc2daa6bfae7)
Fix tests (tested)
(cherry picked from commit 22983c65f8b143d26600d02b2615d4b36b02000f)
Add more tests
(cherry picked from commit 4bbcbd37e138c68d3b9329cb2dbcfd8aad430c79)
Add tooltip
(cherry picked from commit b906008ff1792f6e6e3acaa6e7c71be30c009dd2)
Revert "16, "gt-mr-2" in *all* icons"
This reverts commit c2c60a01eb0be9062000bc5b8cf7a4fdb534a2f0.
(cherry picked from commit 02bb52617dbf93d96bb69183ea8879e7e2e28d50)
Revert "Wait, I forgot about *that* icon"
This reverts commit 9930f9b8f2b06d9593b256e4afee0109970a15f8.
(cherry picked from commit a36d6575090124cac2b46b288cbb6f5c1df482ea)
Revert "Alright, we just made all the icons in that submenu a bit bolder and more consistent."
This reverts commit d5c0009ad01fbf0486620b7c00351a6d1d01b6aa.
(cherry picked from commit 27d8d1c5fc6418cb55430fc3f093a2e02ffaeb93)
2023-07-19 21:29:19 +02:00
|
|
|
Service.EnableOSMButton = sec.Key("ENABLE_OSM_BUTTON").MustBool(true)
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
|
|
|
|
Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true)
|
2019-11-10 10:22:19 +01:00
|
|
|
Service.AutoWatchOnChanges = sec.Key("AUTO_WATCH_ON_CHANGES").MustBool(false)
|
2021-06-26 21:53:14 +02:00
|
|
|
Service.DefaultUserVisibility = sec.Key("DEFAULT_USER_VISIBILITY").In("public", structs.ExtractKeysFromMapString(structs.VisibilityModes))
|
|
|
|
Service.DefaultUserVisibilityMode = structs.VisibilityModes[Service.DefaultUserVisibility]
|
2021-06-27 20:47:35 +02:00
|
|
|
Service.AllowedUserVisibilityModes = sec.Key("ALLOWED_USER_VISIBILITY_MODES").Strings(",")
|
|
|
|
if len(Service.AllowedUserVisibilityModes) != 0 {
|
|
|
|
Service.AllowedUserVisibilityModesSlice = []bool{false, false, false}
|
|
|
|
for _, sMode := range Service.AllowedUserVisibilityModes {
|
|
|
|
Service.AllowedUserVisibilityModesSlice[structs.VisibilityModes[sMode]] = true
|
|
|
|
}
|
|
|
|
}
|
2019-02-18 17:00:27 +01:00
|
|
|
Service.DefaultOrgVisibility = sec.Key("DEFAULT_ORG_VISIBILITY").In("public", structs.ExtractKeysFromMapString(structs.VisibilityModes))
|
|
|
|
Service.DefaultOrgVisibilityMode = structs.VisibilityModes[Service.DefaultOrgVisibility]
|
2019-08-24 14:28:59 +02:00
|
|
|
Service.DefaultOrgMemberVisible = sec.Key("DEFAULT_ORG_MEMBER_VISIBLE").MustBool()
|
2021-01-22 03:56:19 +01:00
|
|
|
Service.UserDeleteWithCommentsMaxTime = sec.Key("USER_DELETE_WITH_COMMENTS_MAX_TIME").MustDuration(0)
|
2021-06-26 00:38:27 +02:00
|
|
|
sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https")
|
|
|
|
Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",")
|
|
|
|
schemes := make([]string, len(Service.ValidSiteURLSchemes))
|
|
|
|
for _, scheme := range Service.ValidSiteURLSchemes {
|
|
|
|
scheme = strings.ToLower(strings.TrimSpace(scheme))
|
|
|
|
if scheme != "" {
|
|
|
|
schemes = append(schemes, scheme)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Service.ValidSiteURLSchemes = schemes
|
2019-02-10 02:37:37 +01:00
|
|
|
|
2023-02-19 17:12:01 +01:00
|
|
|
mustMapSetting(rootCfg, "service.explore", &Service.Explore)
|
|
|
|
|
|
|
|
loadOpenIDSetting(rootCfg)
|
|
|
|
}
|
2021-03-11 14:40:54 +01:00
|
|
|
|
2023-02-19 17:12:01 +01:00
|
|
|
func loadOpenIDSetting(rootCfg ConfigProvider) {
|
|
|
|
sec := rootCfg.Section("openid")
|
2019-02-10 02:37:37 +01:00
|
|
|
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
|
|
|
|
Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)
|
|
|
|
pats := sec.Key("WHITELISTED_URIS").Strings(" ")
|
|
|
|
if len(pats) != 0 {
|
|
|
|
Service.OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
|
|
|
|
for i, p := range pats {
|
|
|
|
Service.OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
|
|
|
|
if len(pats) != 0 {
|
|
|
|
Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
|
|
|
|
for i, p := range pats {
|
|
|
|
Service.OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|