forked from NYANDEV/forgejo
30d27261d3
(cherry picked from commit b1a792b63547df1471a125c2384a9623ffae409e) (cherry picked from commit ba71acccdb8eb4d1c87b50708fe3b03a3324dd9c) (cherry picked from commit ef58efb8e0c48a782e01aac8d754e70b7611a2c8) (cherry picked from commit 6a1b08241ebb862bdd39c708852e3e23c4d96c9d) (cherry picked from commit 132c7a3a07d5a11b9b165295ef12111ce74aea70) (cherry picked from commit a1f07975d67ceccedc808ddaf657f8e7e0da74b1) (cherry picked from commit f3793598b24d00ca3ae80dbde4ef9909b298ca03) (cherry picked from commit 60f38116afc60b055c6b40be8a1e94f646252bf6) (cherry picked from commit 88884cf2833429749b9a6ec6110b4c4727304903) (cherry picked from commit 520de41aefa6c1f5c939b2345878697094962812) (cherry picked from commit cfd5e5b95ab081d10d4f5d6022d09db4877f51fc) (cherry picked from commit 5cf1738f0a08d99aba2016100f3f0083b51efcf4) (cherry picked from commit b95f9b3142089d90df93708638b2ae6c857dbc87) (cherry picked from commit 0118fba9703a1e3f9da6c7b5c479b8b919a5f5e2) (cherry picked from commit ef213ec79d8d0ae006bfda0b9e49d2da2be47ca3) (cherry picked from commit f6794f694b9fb262c66f8d3958dd5145c7ef0dbb) (cherry picked from commit 639110c03bc2d2f91fb6a5c619f1138a0522f836) (cherry picked from commit 16ed04f9f45dfed0d3583a4f1aa1cbc5c1d97a24) (cherry picked from commit b6f50bf932c89182d9908d2d33bbf2ead69c0c41) (cherry picked from commit bcf255844d6871b7b707338d8babd99df3cb465e) (cherry picked from commit 9eb9f86542a62d5ae28ace41ef53403d97b3b3ad) (cherry picked from commit 9f98d6757b68f4875a9d977b8049261f9cc4f0f4)
151 lines
4.2 KiB
Go
151 lines
4.2 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
package setting
|
||
|
||
import (
|
||
"time"
|
||
|
||
"code.gitea.io/gitea/modules/container"
|
||
)
|
||
|
||
// UI settings
|
||
var UI = struct {
|
||
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
|
||
|
||
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
|
||
} `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"`
|
||
}{
|
||
ExplorePagingNum: 20,
|
||
SitemapPagingNum: 20,
|
||
IssuePagingNum: 20,
|
||
RepoSearchPagingNum: 20,
|
||
MembersPagingNum: 20,
|
||
FeedMaxCommitNum: 5,
|
||
FeedPagingNum: 20,
|
||
PackagesPagingNum: 20,
|
||
GraphMaxCommitNum: 100,
|
||
CodeCommentLines: 4,
|
||
ReactionMaxUserNum: 10,
|
||
MaxDisplayFileSize: 8388608,
|
||
DefaultTheme: `forgejo-auto`,
|
||
Themes: []string{`forgejo-auto`, `forgejo-light`, `forgejo-dark`, `auto`, `gitea`, `arc-green`},
|
||
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
|
||
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:"},
|
||
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
|
||
}{
|
||
MaxFileSize: 524288,
|
||
},
|
||
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
|
||
}{
|
||
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",
|
||
},
|
||
}
|
||
|
||
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)
|
||
|
||
// 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.
|
||
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 + ":"
|
||
}
|
||
}
|