2023-02-19 21:42:01 +05:30
|
|
|
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
package setting
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/container"
|
2024-01-02 06:55:30 +05:30
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
2023-02-19 21:42:01 +05:30
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// UI settings
|
|
|
|
|
var UI = struct {
|
2024-01-02 06:55:30 +05:30
|
|
|
|
ExplorePagingNum int
|
|
|
|
|
SitemapPagingNum int
|
|
|
|
|
IssuePagingNum int
|
|
|
|
|
RepoSearchPagingNum int
|
|
|
|
|
MembersPagingNum int
|
|
|
|
|
FeedMaxCommitNum int
|
|
|
|
|
FeedPagingNum int
|
|
|
|
|
PackagesPagingNum int
|
|
|
|
|
GraphMaxCommitNum int
|
|
|
|
|
CodeCommentLines int
|
|
|
|
|
ReactionMaxUserNum int
|
|
|
|
|
MaxDisplayFileSize int64
|
|
|
|
|
ShowUserEmail bool
|
|
|
|
|
DefaultShowFullName bool
|
|
|
|
|
DefaultTheme string
|
|
|
|
|
Themes []string
|
|
|
|
|
Reactions []string
|
|
|
|
|
ReactionsLookup container.Set[string] `ini:"-"`
|
|
|
|
|
CustomEmojis []string
|
|
|
|
|
CustomEmojisMap map[string]string `ini:"-"`
|
|
|
|
|
SearchRepoDescription bool
|
|
|
|
|
OnlyShowRelevantRepos bool
|
|
|
|
|
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
|
|
|
|
|
PreferredTimestampTense string
|
2023-02-19 21:42:01 +05:30
|
|
|
|
|
2023-12-17 20:08:54 +05:30
|
|
|
|
AmbiguousUnicodeDetection bool
|
2024-02-22 02:48:44 +05:30
|
|
|
|
SkipEscapeContexts []string
|
2023-12-17 20:08:54 +05:30
|
|
|
|
|
2023-02-19 21:42:01 +05:30
|
|
|
|
Notification struct {
|
|
|
|
|
MinTimeout time.Duration
|
|
|
|
|
TimeoutStep time.Duration
|
|
|
|
|
MaxTimeout time.Duration
|
|
|
|
|
EventSourceUpdateTime time.Duration
|
|
|
|
|
} `ini:"ui.notification"`
|
|
|
|
|
|
|
|
|
|
SVG struct {
|
|
|
|
|
Enabled bool `ini:"ENABLE_RENDER"`
|
|
|
|
|
} `ini:"ui.svg"`
|
|
|
|
|
|
|
|
|
|
CSV struct {
|
|
|
|
|
MaxFileSize int64
|
2024-06-06 13:36:59 +05:30
|
|
|
|
MaxRows int
|
2023-02-19 21:42:01 +05:30
|
|
|
|
} `ini:"ui.csv"`
|
|
|
|
|
|
|
|
|
|
Admin struct {
|
|
|
|
|
UserPagingNum int
|
|
|
|
|
RepoPagingNum int
|
|
|
|
|
NoticePagingNum int
|
|
|
|
|
OrgPagingNum int
|
|
|
|
|
} `ini:"ui.admin"`
|
|
|
|
|
User struct {
|
|
|
|
|
RepoPagingNum int
|
|
|
|
|
} `ini:"ui.user"`
|
|
|
|
|
Meta struct {
|
|
|
|
|
Author string
|
|
|
|
|
Description string
|
|
|
|
|
Keywords string
|
|
|
|
|
} `ini:"ui.meta"`
|
|
|
|
|
}{
|
2024-01-02 06:55:30 +05:30
|
|
|
|
ExplorePagingNum: 20,
|
|
|
|
|
SitemapPagingNum: 20,
|
|
|
|
|
IssuePagingNum: 20,
|
|
|
|
|
RepoSearchPagingNum: 20,
|
|
|
|
|
MembersPagingNum: 20,
|
|
|
|
|
FeedMaxCommitNum: 5,
|
|
|
|
|
FeedPagingNum: 20,
|
|
|
|
|
PackagesPagingNum: 20,
|
|
|
|
|
GraphMaxCommitNum: 100,
|
|
|
|
|
CodeCommentLines: 4,
|
|
|
|
|
ReactionMaxUserNum: 10,
|
|
|
|
|
MaxDisplayFileSize: 8388608,
|
2022-12-25 17:14:04 +05:30
|
|
|
|
DefaultTheme: `forgejo-auto`,
|
2023-11-08 07:23:37 +05:30
|
|
|
|
Themes: []string{`forgejo-auto`, `forgejo-light`, `forgejo-dark`, `gitea-auto`, `gitea-light`, `gitea-dark`, `forgejo-auto-deuteranopia-protanopia`, `forgejo-light-deuteranopia-protanopia`, `forgejo-dark-deuteranopia-protanopia`, `forgejo-auto-tritanopia`, `forgejo-light-tritanopia`, `forgejo-dark-tritanopia`},
|
2024-01-02 06:55:30 +05:30
|
|
|
|
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
|
2022-12-19 15:35:51 +05:30
|
|
|
|
CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`, `forgejo`},
|
|
|
|
|
CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:", "forgejo": ":forgejo:"},
|
2024-01-02 06:55:30 +05:30
|
|
|
|
PreferredTimestampTense: "mixed",
|
2023-12-17 20:08:54 +05:30
|
|
|
|
|
|
|
|
|
AmbiguousUnicodeDetection: true,
|
2024-02-22 02:48:44 +05:30
|
|
|
|
SkipEscapeContexts: []string{},
|
2023-12-17 20:08:54 +05:30
|
|
|
|
|
2023-02-19 21:42:01 +05:30
|
|
|
|
Notification: struct {
|
|
|
|
|
MinTimeout time.Duration
|
|
|
|
|
TimeoutStep time.Duration
|
|
|
|
|
MaxTimeout time.Duration
|
|
|
|
|
EventSourceUpdateTime time.Duration
|
|
|
|
|
}{
|
|
|
|
|
MinTimeout: 10 * time.Second,
|
|
|
|
|
TimeoutStep: 10 * time.Second,
|
|
|
|
|
MaxTimeout: 60 * time.Second,
|
|
|
|
|
EventSourceUpdateTime: 10 * time.Second,
|
|
|
|
|
},
|
|
|
|
|
SVG: struct {
|
|
|
|
|
Enabled bool `ini:"ENABLE_RENDER"`
|
|
|
|
|
}{
|
|
|
|
|
Enabled: true,
|
|
|
|
|
},
|
|
|
|
|
CSV: struct {
|
|
|
|
|
MaxFileSize int64
|
2024-06-06 13:36:59 +05:30
|
|
|
|
MaxRows int
|
2023-02-19 21:42:01 +05:30
|
|
|
|
}{
|
|
|
|
|
MaxFileSize: 524288,
|
2024-06-06 13:36:59 +05:30
|
|
|
|
MaxRows: 2500,
|
2023-02-19 21:42:01 +05:30
|
|
|
|
},
|
|
|
|
|
Admin: struct {
|
|
|
|
|
UserPagingNum int
|
|
|
|
|
RepoPagingNum int
|
|
|
|
|
NoticePagingNum int
|
|
|
|
|
OrgPagingNum int
|
|
|
|
|
}{
|
|
|
|
|
UserPagingNum: 50,
|
|
|
|
|
RepoPagingNum: 50,
|
|
|
|
|
NoticePagingNum: 25,
|
|
|
|
|
OrgPagingNum: 50,
|
|
|
|
|
},
|
|
|
|
|
User: struct {
|
|
|
|
|
RepoPagingNum int
|
|
|
|
|
}{
|
|
|
|
|
RepoPagingNum: 15,
|
|
|
|
|
},
|
|
|
|
|
Meta: struct {
|
|
|
|
|
Author string
|
|
|
|
|
Description string
|
|
|
|
|
Keywords string
|
|
|
|
|
}{
|
2022-12-28 15:58:39 +05:30
|
|
|
|
Author: "Forgejo – Beyond coding. We forge.",
|
|
|
|
|
Description: "Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job.",
|
|
|
|
|
Keywords: "git,forge,forgejo",
|
2023-02-19 21:42:01 +05:30
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func loadUIFrom(rootCfg ConfigProvider) {
|
|
|
|
|
mustMapSetting(rootCfg, "ui", &UI)
|
|
|
|
|
sec := rootCfg.Section("ui")
|
|
|
|
|
UI.ShowUserEmail = sec.Key("SHOW_USER_EMAIL").MustBool(true)
|
|
|
|
|
UI.DefaultShowFullName = sec.Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
|
|
|
|
|
UI.SearchRepoDescription = sec.Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
|
2023-03-29 19:11:45 +05:30
|
|
|
|
|
2024-01-02 06:55:30 +05:30
|
|
|
|
if UI.PreferredTimestampTense != "mixed" && UI.PreferredTimestampTense != "absolute" {
|
|
|
|
|
log.Fatal("ui.PREFERRED_TIMESTAMP_TENSE must be either 'mixed' or 'absolute'")
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 19:11:45 +05:30
|
|
|
|
// OnlyShowRelevantRepos=false is important for many private/enterprise instances,
|
|
|
|
|
// because many private repositories do not have "description/topic", users just want to search by their names.
|
2023-02-19 21:42:01 +05:30
|
|
|
|
UI.OnlyShowRelevantRepos = sec.Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false)
|
|
|
|
|
|
|
|
|
|
UI.ReactionsLookup = make(container.Set[string])
|
|
|
|
|
for _, reaction := range UI.Reactions {
|
|
|
|
|
UI.ReactionsLookup.Add(reaction)
|
|
|
|
|
}
|
|
|
|
|
UI.CustomEmojisMap = make(map[string]string)
|
|
|
|
|
for _, emoji := range UI.CustomEmojis {
|
|
|
|
|
UI.CustomEmojisMap[emoji] = ":" + emoji + ":"
|
|
|
|
|
}
|
|
|
|
|
}
|