forgejo/modules/setting/ui.go
Caesar Schinas dca8fb6cf7
[BRANDING] Rebrand default meta tags
(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 2be6eca1e1c8488bdc9e6ce164dbd9f3d79771ce)
(cherry picked from commit eb929d0d566b3dff8454e62ff9f2384a896fb549)
(cherry picked from commit c49dd4ed7f771e8fa1573add6cbadc193a473ead)
(cherry picked from commit 8ea074c4ddaa737c4faa83c1b4746dbd7cb84440)
(cherry picked from commit 3145df43d60593700b60409a8d5ac12e4fbbc197)
(cherry picked from commit d0df3e306a4f0a4f773c7cbc1409922fe69973aa)
(cherry picked from commit 8f4850705eb4e016ebebc738f629bcc9ce87ca61)
(cherry picked from commit 5a24d4319cf7ac2e56b9e43e4181b066d76d6d8d)
(cherry picked from commit 756c04c6c46a55852089711f7859f533b85fd042)
(cherry picked from commit ea627e79e36d0bc7514b28e6b7d5847b5bdf5922)
(cherry picked from commit c52b141902ef0be06c100f4a1285f28419e6f497)
(cherry picked from commit 49ab0c55597dc12a50be39a2bd35cb870ba8e361)
(cherry picked from commit f14f26c940abd341ae6bd8e20e93bd736e907b52)
(cherry picked from commit 4caebbb6becb26732f4d72d3e73a71ea821edf8f)
(cherry picked from commit 7c3d0bca9e8868529e4496b6b17fbe1c0736c425)
(cherry picked from commit 171a207006f82d5dfed4abb9c957a837a8aa53ba)
(cherry picked from commit 2a4a7d05fbcc67f603f81c5a4adab016dccf7460)
(cherry picked from commit 94b1b902053922ec73213f9c20f1a37a292959b8)
(cherry picked from commit cd3565dbed2c86ef9c2d5e6b92931481b17e62c9)
(cherry picked from commit 5d02758b22717ec93b9bf36af6d09bc66925e6a8)
(cherry picked from commit 5901edd111)
(cherry picked from commit 8a3abe6daf)
(cherry picked from commit eaa1a3e6ca6a4c178944e6d25a0819478c60d96d)
(cherry picked from commit 7191d0abc48c464cafba209a1a5c3b762a4918d8)
(cherry picked from commit 579b985d791182c20754293151b8829d95837ae9)
(cherry picked from commit 16d7dbed870b69cf2e09c19fb16ad9cea0cce76a)
(cherry picked from commit c1fa9edc159596e470daf28571e356295695396d)
(cherry picked from commit cdcf37ff1b726b9f3e240935c19dc30160b47eba)
(cherry picked from commit b0c78efb8656006239c22f330a63341ac99eb783)
2024-01-15 16:11:11 +00:00

164 lines
4.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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: `forgejo-auto`,
Themes: []string{`forgejo-auto`, `forgejo-light`, `forgejo-dark`, `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: "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)
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 + ":"
}
}