forgejo/modules/setting/ui.go

152 lines
4.1 KiB
Go
Raw Normal View History

// 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: `auto`,
Themes: []string{`auto`, `gitea`, `arc-green`},
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
[BRANDING] Add `forgejo` emoji (cherry picked from commit ade55ad308ea0ac6bb36903e3a69b02d18228adb) (cherry picked from commit 107f7266183584b51299351961b73ab2b185f24b) (cherry picked from commit f29cf9cfc107692cd79a4ba4062a66f90813bc4e) (cherry picked from commit 0761a41eee30a32c822834ca2b989ad6343ed1e0) (cherry picked from commit 2b1fd9565f615dde8bdd07d86ff3a5ca3815af67) (cherry picked from commit 6a7c82f13b17df1fa647130d086fbcdbeb086571) (cherry picked from commit 4a56d404942562e3f5a45abd45518bc8679109b6) (cherry picked from commit b48e3e896d0d3942362b5a1c18f847ffd64609cb) (cherry picked from commit bde83340cbcce8370d524da9c909731c78544c49) (cherry picked from commit 74e0603d6be22d8d74d38f9c99c8bcf26dd83482) (cherry picked from commit 84bd1ddc082aa55a7d7c03eeac55478f0e15e019) (cherry picked from commit 62d9acde2a0692f46257dc3db329e0196b74837a) (cherry picked from commit 5b84a909135a4d71c778a2d0719a20ff01abef64) (cherry picked from commit 5362f7d053f4e8bd6a91d93ddbcb6d291a250efe) (cherry picked from commit 65ad7d1bd9875b6dd00f3ef31bc1d5ef2b9e84f5) (cherry picked from commit 6e42d545a97ef7d470b57f6ae43ae15fa1581a37) (cherry picked from commit 24d3bb33e2031a44c535602a7a083194acacbff1) (cherry picked from commit 704935cadd997dcc1dea5e51a089ed25ec1ccab1) (cherry picked from commit 5d9fc59e17c9be563432376c3b7d1851300ccdac) (cherry picked from commit 4c95df3f86f9e778a9d1267cdca22c4ce15ffb94) (cherry picked from commit 1ac704762ac78ba2a86a787f02de45779d765673) (cherry picked from commit 0da9fb13189b0bff21a734c0f635ec196731a91f) (cherry picked from commit bc2de51eeffea7fb4c5b53e7a72cab315af8215a) (cherry picked from commit ea897a20b91e89be48570ca923dcbea1b4baf81e) (cherry picked from commit 66f3f9c6effd19ca6762437e7756bd3ac564a6f3) (cherry picked from commit edc5c3c3043867ea01b93f50ca83014592ef89b6) (cherry picked from commit 11dd4f31a49b5448d4207c928df6be647adf5ce0) (cherry picked from commit bf0fb77afb91dfff7ba81a59bbf5506a6b0a6462)
2022-12-19 11:05:51 +01:00
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: "Gitea - Git with a cup of tea",
Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
Keywords: "go,git,self-hosted,gitea",
},
}
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 + ":"
}
}