a46b5bbf38
(cherry picked from commitade55ad308
) (cherry picked from commit107f726618
) (cherry picked from commitf29cf9cfc1
) (cherry picked from commit0761a41eee
) (cherry picked from commit2b1fd9565f
) (cherry picked from commit6a7c82f13b
) (cherry picked from commit4a56d40494
) (cherry picked from commitb48e3e896d
) (cherry picked from commitbde83340cb
) (cherry picked from commit74e0603d6b
) (cherry picked from commit84bd1ddc08
) (cherry picked from commit62d9acde2a
) (cherry picked from commit5b84a90913
) (cherry picked from commit5362f7d053
) (cherry picked from commit65ad7d1bd9
) (cherry picked from commit6e42d545a9
) (cherry picked from commit24d3bb33e2
) (cherry picked from commit704935cadd
) (cherry picked from commit5d9fc59e17
) (cherry picked from commit4c95df3f86
) (cherry picked from commit1ac704762a
) (cherry picked from commit0da9fb1318
) (cherry picked from commitbc2de51eef
) (cherry picked from commitea897a20b9
) (cherry picked from commit66f3f9c6ef
) (cherry picked from commitedc5c3c304
) (cherry picked from commit11dd4f31a4
) (cherry picked from commitbf0fb77afb
) (cherry picked from commit3a823b1001
) (cherry picked from commite1f6cb4ed6
) (cherry picked from commit0b3f45972f
) (cherry picked from commita9579c9679
) (cherry picked from commit0dea1aadf2
) (cherry picked from commitaeed23b96e
) (cherry picked from commit72712f467d
) (cherry picked from commitb49b832899
) (cherry picked from commita985bb8b90
) (cherry picked from commitdac4d69218
) (cherry picked from commit4962eb361d
) (cherry picked from commit61835639c8
) (cherry picked from commitf4e44e3b60
) (cherry picked from commit65c5f553c1
) Conflicts: modules/setting/ui.go https://codeberg.org/forgejo/forgejo/pulls/1976 (cherry picked from commitef2f0c1c4a
) (cherry picked from commit4c208ef65e
) (cherry picked from commit3386a9d6ee
) Conflicts: modules/setting/ui.go https://codeberg.org/forgejo/forgejo/pulls/2116 (cherry picked from commit8f93b38c66
) (cherry picked from commitaf49467e83
) (cherry picked from commitedef259a38
)
164 lines
4.6 KiB
Go
164 lines
4.6 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/modules/container"
|
|
"code.gitea.io/gitea/modules/log"
|
|
)
|
|
|
|
// 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
|
|
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
|
|
PreferredTimestampTense string
|
|
|
|
AmbiguousUnicodeDetection 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: `gitea-auto`,
|
|
Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`},
|
|
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:"},
|
|
PreferredTimestampTense: "mixed",
|
|
|
|
AmbiguousUnicodeDetection: true,
|
|
|
|
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)
|
|
|
|
if UI.PreferredTimestampTense != "mixed" && UI.PreferredTimestampTense != "absolute" {
|
|
log.Fatal("ui.PREFERRED_TIMESTAMP_TENSE must be either 'mixed' or 'absolute'")
|
|
}
|
|
|
|
// 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 + ":"
|
|
}
|
|
}
|