code.gitea.io/gitea@v1.19.3/modules/setting/ui.go (about) 1 // Copyright 2023 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package setting 5 6 import ( 7 "time" 8 9 "code.gitea.io/gitea/modules/container" 10 ) 11 12 // UI settings 13 var UI = struct { 14 ExplorePagingNum int 15 SitemapPagingNum int 16 IssuePagingNum int 17 RepoSearchPagingNum int 18 MembersPagingNum int 19 FeedMaxCommitNum int 20 FeedPagingNum int 21 PackagesPagingNum int 22 GraphMaxCommitNum int 23 CodeCommentLines int 24 ReactionMaxUserNum int 25 ThemeColorMetaTag string 26 MaxDisplayFileSize int64 27 ShowUserEmail bool 28 DefaultShowFullName bool 29 DefaultTheme string 30 Themes []string 31 Reactions []string 32 ReactionsLookup container.Set[string] `ini:"-"` 33 CustomEmojis []string 34 CustomEmojisMap map[string]string `ini:"-"` 35 SearchRepoDescription bool 36 UseServiceWorker bool 37 OnlyShowRelevantRepos bool 38 39 Notification struct { 40 MinTimeout time.Duration 41 TimeoutStep time.Duration 42 MaxTimeout time.Duration 43 EventSourceUpdateTime time.Duration 44 } `ini:"ui.notification"` 45 46 SVG struct { 47 Enabled bool `ini:"ENABLE_RENDER"` 48 } `ini:"ui.svg"` 49 50 CSV struct { 51 MaxFileSize int64 52 } `ini:"ui.csv"` 53 54 Admin struct { 55 UserPagingNum int 56 RepoPagingNum int 57 NoticePagingNum int 58 OrgPagingNum int 59 } `ini:"ui.admin"` 60 User struct { 61 RepoPagingNum int 62 } `ini:"ui.user"` 63 Meta struct { 64 Author string 65 Description string 66 Keywords string 67 } `ini:"ui.meta"` 68 }{ 69 ExplorePagingNum: 20, 70 SitemapPagingNum: 20, 71 IssuePagingNum: 20, 72 RepoSearchPagingNum: 20, 73 MembersPagingNum: 20, 74 FeedMaxCommitNum: 5, 75 FeedPagingNum: 20, 76 PackagesPagingNum: 20, 77 GraphMaxCommitNum: 100, 78 CodeCommentLines: 4, 79 ReactionMaxUserNum: 10, 80 ThemeColorMetaTag: ``, 81 MaxDisplayFileSize: 8388608, 82 DefaultTheme: `auto`, 83 Themes: []string{`auto`, `gitea`, `arc-green`}, 84 Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`}, 85 CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`}, 86 CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"}, 87 Notification: struct { 88 MinTimeout time.Duration 89 TimeoutStep time.Duration 90 MaxTimeout time.Duration 91 EventSourceUpdateTime time.Duration 92 }{ 93 MinTimeout: 10 * time.Second, 94 TimeoutStep: 10 * time.Second, 95 MaxTimeout: 60 * time.Second, 96 EventSourceUpdateTime: 10 * time.Second, 97 }, 98 SVG: struct { 99 Enabled bool `ini:"ENABLE_RENDER"` 100 }{ 101 Enabled: true, 102 }, 103 CSV: struct { 104 MaxFileSize int64 105 }{ 106 MaxFileSize: 524288, 107 }, 108 Admin: struct { 109 UserPagingNum int 110 RepoPagingNum int 111 NoticePagingNum int 112 OrgPagingNum int 113 }{ 114 UserPagingNum: 50, 115 RepoPagingNum: 50, 116 NoticePagingNum: 25, 117 OrgPagingNum: 50, 118 }, 119 User: struct { 120 RepoPagingNum int 121 }{ 122 RepoPagingNum: 15, 123 }, 124 Meta: struct { 125 Author string 126 Description string 127 Keywords string 128 }{ 129 Author: "Gitea - Git with a cup of tea", 130 Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go", 131 Keywords: "go,git,self-hosted,gitea", 132 }, 133 } 134 135 func loadUIFrom(rootCfg ConfigProvider) { 136 mustMapSetting(rootCfg, "ui", &UI) 137 sec := rootCfg.Section("ui") 138 UI.ShowUserEmail = sec.Key("SHOW_USER_EMAIL").MustBool(true) 139 UI.DefaultShowFullName = sec.Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) 140 UI.SearchRepoDescription = sec.Key("SEARCH_REPO_DESCRIPTION").MustBool(true) 141 UI.UseServiceWorker = sec.Key("USE_SERVICE_WORKER").MustBool(false) 142 143 // OnlyShowRelevantRepos=false is important for many private/enterprise instances, 144 // because many private repositories do not have "description/topic", users just want to search by their names. 145 UI.OnlyShowRelevantRepos = sec.Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false) 146 147 UI.ReactionsLookup = make(container.Set[string]) 148 for _, reaction := range UI.Reactions { 149 UI.ReactionsLookup.Add(reaction) 150 } 151 UI.CustomEmojisMap = make(map[string]string) 152 for _, emoji := range UI.CustomEmojis { 153 UI.CustomEmojisMap[emoji] = ":" + emoji + ":" 154 } 155 }