@@ -5,7 +5,6 @@ package setting
55
66import (
77 "context"
8- "strings"
98 "sync"
109
1110 "code.gitea.io/gitea/modules/log"
@@ -54,86 +53,64 @@ type RepositoryStruct struct {
5453}
5554
5655type UIStruct struct {
57- ExplorePagingNum * config.Value [int ]
58- SitemapPagingNum * config.Value [int ]
59- IssuePagingNum * config.Value [int ]
60- RepoSearchPagingNum * config.Value [int ]
61- MembersPagingNum * config.Value [int ]
62- FeedMaxCommitNum * config.Value [int ]
63- FeedPagingNum * config.Value [int ]
64- PackagesPagingNum * config.Value [int ]
65- GraphMaxCommitNum * config.Value [int ]
66- CodeCommentLines * config.Value [int ]
67- ReactionMaxUserNum * config.Value [int ]
68- MaxDisplayFileSize * config.Value [int64 ]
69- ShowUserEmail * config.Value [bool ]
70- DefaultShowFullName * config.Value [bool ]
71- DefaultTheme * config.Value [string ]
72- Themes * config.Value [[]string ]
73- SearchRepoDescription * config.Value [bool ]
74- OnlyShowRelevantRepos * config.Value [bool ]
75- ExploreDefaultSort * config.Value [string ]
76- PreferredTimestampTense * config.Value [string ]
77- AmbiguousUnicodeDetection * config.Value [bool ]
56+ ExplorePagingNum * config.Value [int ]
57+ SitemapPagingNum * config.Value [int ]
58+ IssuePagingNum * config.Value [int ]
59+ RepoSearchPagingNum * config.Value [int ]
60+ MembersPagingNum * config.Value [int ]
61+ FeedMaxCommitNum * config.Value [int ]
62+ FeedPagingNum * config.Value [int ]
63+ PackagesPagingNum * config.Value [int ]
64+ GraphMaxCommitNum * config.Value [int ]
65+ CodeCommentLines * config.Value [int ]
66+ ReactionMaxUserNum * config.Value [int ]
67+ ShowUserEmail * config.Value [bool ]
68+ DefaultShowFullName * config.Value [bool ]
69+ SearchRepoDescription * config.Value [bool ]
70+ OnlyShowRelevantRepos * config.Value [bool ]
71+ ExploreDefaultSort * config.Value [string ]
7872}
7973
8074func (u * UIStruct ) ToStruct (ctx context.Context ) UIForm {
81- var themes string
82- for _ , v := range u .Themes .Value (ctx ) {
83- themes += v + ","
84- }
85- themes = strings .TrimSuffix (themes , "," )
8675 return UIForm {
87- ExplorePagingNum : u .ExplorePagingNum .Value (ctx ),
88- SitemapPagingNum : u .SitemapPagingNum .Value (ctx ),
89- IssuePagingNum : u .IssuePagingNum .Value (ctx ),
90- RepoSearchPagingNum : u .RepoSearchPagingNum .Value (ctx ),
91- MembersPagingNum : u .MembersPagingNum .Value (ctx ),
92- FeedMaxCommitNum : u .FeedMaxCommitNum .Value (ctx ),
93- FeedPagingNum : u .FeedPagingNum .Value (ctx ),
94- PackagesPagingNum : u .PackagesPagingNum .Value (ctx ),
95- GraphMaxCommitNum : u .GraphMaxCommitNum .Value (ctx ),
96- CodeCommentLines : u .CodeCommentLines .Value (ctx ),
97- ReactionMaxUserNum : u .ReactionMaxUserNum .Value (ctx ),
98- MaxDisplayFileSize : u .MaxDisplayFileSize .Value (ctx ),
99- ShowUserEmail : u .ShowUserEmail .Value (ctx ),
100- DefaultShowFullName : u .DefaultShowFullName .Value (ctx ),
101- DefaultTheme : u .DefaultTheme .Value (ctx ),
102- Themes : themes ,
103- SearchRepoDescription : u .SearchRepoDescription .Value (ctx ),
104- OnlyShowRelevantRepos : u .OnlyShowRelevantRepos .Value (ctx ),
105- ExplorePagingDefaultSort : u .ExploreDefaultSort .Value (ctx ),
106- ExplorePagingSortOption : []string {"recentupdate" , "alphabetically" , "reverselastlogin" , "newest" , "oldest" },
107- PreferredTimestampTense : u .PreferredTimestampTense .Value (ctx ),
108- PreferredTimestampTenseOption : []string {"mixed" , "absolute" },
109- AmbiguousUnicodeDetection : u .AmbiguousUnicodeDetection .Value (ctx ),
76+ ExplorePagingNum : u .ExplorePagingNum .Value (ctx ),
77+ SitemapPagingNum : u .SitemapPagingNum .Value (ctx ),
78+ IssuePagingNum : u .IssuePagingNum .Value (ctx ),
79+ RepoSearchPagingNum : u .RepoSearchPagingNum .Value (ctx ),
80+ MembersPagingNum : u .MembersPagingNum .Value (ctx ),
81+ FeedMaxCommitNum : u .FeedMaxCommitNum .Value (ctx ),
82+ FeedPagingNum : u .FeedPagingNum .Value (ctx ),
83+ PackagesPagingNum : u .PackagesPagingNum .Value (ctx ),
84+ GraphMaxCommitNum : u .GraphMaxCommitNum .Value (ctx ),
85+ CodeCommentLines : u .CodeCommentLines .Value (ctx ),
86+ ReactionMaxUserNum : u .ReactionMaxUserNum .Value (ctx ),
87+ ShowUserEmail : u .ShowUserEmail .Value (ctx ),
88+ DefaultShowFullName : u .DefaultShowFullName .Value (ctx ),
89+ SearchRepoDescription : u .SearchRepoDescription .Value (ctx ),
90+ OnlyShowRelevantRepos : u .OnlyShowRelevantRepos .Value (ctx ),
91+ ExplorePagingDefaultSort : u .ExploreDefaultSort .Value (ctx ),
92+ ExplorePagingSortOption : []string {"recentupdate" , "alphabetically" , "reverselastlogin" , "newest" , "oldest" },
11093 }
11194}
11295
11396type UIForm struct {
114- ExplorePagingNum int
115- SitemapPagingNum int
116- IssuePagingNum int
117- RepoSearchPagingNum int
118- MembersPagingNum int
119- FeedMaxCommitNum int
120- FeedPagingNum int
121- PackagesPagingNum int
122- GraphMaxCommitNum int
123- CodeCommentLines int
124- ReactionMaxUserNum int
125- MaxDisplayFileSize int64
126- ShowUserEmail bool
127- DefaultShowFullName bool
128- DefaultTheme string
129- Themes string
130- SearchRepoDescription bool
131- OnlyShowRelevantRepos bool
132- ExplorePagingDefaultSort string
133- ExplorePagingSortOption []string
134- PreferredTimestampTense string
135- PreferredTimestampTenseOption []string
136- AmbiguousUnicodeDetection bool
97+ ExplorePagingNum int
98+ SitemapPagingNum int
99+ IssuePagingNum int
100+ RepoSearchPagingNum int
101+ MembersPagingNum int
102+ FeedMaxCommitNum int
103+ FeedPagingNum int
104+ PackagesPagingNum int
105+ GraphMaxCommitNum int
106+ CodeCommentLines int
107+ ReactionMaxUserNum int
108+ ShowUserEmail bool
109+ DefaultShowFullName bool
110+ SearchRepoDescription bool
111+ OnlyShowRelevantRepos bool
112+ ExplorePagingDefaultSort string
113+ ExplorePagingSortOption []string
137114}
138115
139116type ConfigStruct struct {
@@ -158,27 +135,22 @@ func initDefaultConfig() {
158135 OpenWithEditorApps : config.ValueJSON [OpenWithEditorAppsType ]("repository.open-with.editor-apps" ),
159136 },
160137 UI : & UIStruct {
161- ExplorePagingNum : config.ValueJSON [int ]("ui.explore_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "EXPLORE_PAGING_NUM" }).WithDefault (20 ),
162- SitemapPagingNum : config.ValueJSON [int ]("ui.sitemap_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "SITEMAP_PAGING_NUM" }).WithDefault (20 ),
163- IssuePagingNum : config.ValueJSON [int ]("ui.issue_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "ISSUE_PAGING_NUM" }).WithDefault (20 ),
164- RepoSearchPagingNum : config.ValueJSON [int ]("ui.repo_search_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "REPO_SEARCH_PAGING_NUM" }).WithDefault (20 ),
165- MembersPagingNum : config.ValueJSON [int ]("ui.members_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "MEMBERS_PAGING_NUM" }).WithDefault (20 ),
166- FeedMaxCommitNum : config.ValueJSON [int ]("ui.feed_max_commit_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "FEED_MAX_COMMIT_NUM" }).WithDefault (20 ),
167- FeedPagingNum : config.ValueJSON [int ]("ui.feed_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "FEED_PAGE_NUM" }).WithDefault (20 ),
168- PackagesPagingNum : config.ValueJSON [int ]("ui.packages_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "PACKAGES_PAGING_NUM" }).WithDefault (20 ),
169- GraphMaxCommitNum : config.ValueJSON [int ]("ui.graph_max_commit_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "GRAPH_MAX_COMMIT_NUM" }).WithDefault (100 ),
170- CodeCommentLines : config.ValueJSON [int ]("ui.code_comment_lines" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "CODE_COMMENT_LINES" }).WithDefault (4 ),
171- ReactionMaxUserNum : config.ValueJSON [int ]("ui.reaction_max_user_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "REACTION_MAX_USER_NUM" }).WithDefault (10 ),
172- MaxDisplayFileSize : config.ValueJSON [int64 ]("ui.max_display_file_size" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "MAX_DISPLAY_FILE_SIZE" }).WithDefault (8 * 1024 * 1024 ),
173- ShowUserEmail : config.ValueJSON [bool ]("ui.show_user_email" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "SHOW_USER_EMAIL" }).WithDefault (true ),
174- DefaultShowFullName : config.ValueJSON [bool ]("ui.default_show_full_name" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "DEFAULT_SHOW_FULL_NAME" }).WithDefault (false ),
175- DefaultTheme : config.ValueJSON [string ]("ui.default_theme" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "DEFAULT_THEME" }).WithDefault ("gitea-auto" ),
176- Themes : config.ValueJSON [[]string ]("ui.themes" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "THEMES" }).WithDefault ([]string {"gitea-auto" , "gitea-dark" , "gitea-light" }),
177- SearchRepoDescription : config.ValueJSON [bool ]("ui.search_repo_description" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "SEARCH_REPO_DESCRIPTION" }).WithDefault (false ),
178- OnlyShowRelevantRepos : config.ValueJSON [bool ]("ui.only_show_relevant_repos" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "ONLY_SHOW_RELEVANT_REPOS" }).WithDefault (false ),
179- ExploreDefaultSort : config.ValueJSON [string ]("ui.explore_paging_default_sort" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "EXPLORE_PAGING_DEFAULT_SORT" }).WithDefault ("recentupdate" ),
180- PreferredTimestampTense : config.ValueJSON [string ]("ui.preferred_timestamp_tense" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "PREFERRED_TIMESTAMP_TENSE" }).WithDefault ("mixed" ),
181- AmbiguousUnicodeDetection : config.ValueJSON [bool ]("ui.ambiguous_unicode_detection" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "AMBIGUOUS_UNICODE" }).WithDefault (true ),
138+ ExplorePagingNum : config.ValueJSON [int ]("ui.explore_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "EXPLORE_PAGING_NUM" }).WithDefault (20 ),
139+ SitemapPagingNum : config.ValueJSON [int ]("ui.sitemap_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "SITEMAP_PAGING_NUM" }).WithDefault (20 ),
140+ IssuePagingNum : config.ValueJSON [int ]("ui.issue_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "ISSUE_PAGING_NUM" }).WithDefault (20 ),
141+ RepoSearchPagingNum : config.ValueJSON [int ]("ui.repo_search_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "REPO_SEARCH_PAGING_NUM" }).WithDefault (20 ),
142+ MembersPagingNum : config.ValueJSON [int ]("ui.members_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "MEMBERS_PAGING_NUM" }).WithDefault (20 ),
143+ FeedMaxCommitNum : config.ValueJSON [int ]("ui.feed_max_commit_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "FEED_MAX_COMMIT_NUM" }).WithDefault (20 ),
144+ FeedPagingNum : config.ValueJSON [int ]("ui.feed_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "FEED_PAGE_NUM" }).WithDefault (20 ),
145+ PackagesPagingNum : config.ValueJSON [int ]("ui.packages_paging_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "PACKAGES_PAGING_NUM" }).WithDefault (20 ),
146+ GraphMaxCommitNum : config.ValueJSON [int ]("ui.graph_max_commit_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "GRAPH_MAX_COMMIT_NUM" }).WithDefault (100 ),
147+ CodeCommentLines : config.ValueJSON [int ]("ui.code_comment_lines" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "CODE_COMMENT_LINES" }).WithDefault (4 ),
148+ ReactionMaxUserNum : config.ValueJSON [int ]("ui.reaction_max_user_num" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "REACTION_MAX_USER_NUM" }).WithDefault (10 ),
149+ ShowUserEmail : config.ValueJSON [bool ]("ui.show_user_email" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "SHOW_USER_EMAIL" }).WithDefault (true ),
150+ DefaultShowFullName : config.ValueJSON [bool ]("ui.default_show_full_name" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "DEFAULT_SHOW_FULL_NAME" }).WithDefault (false ),
151+ SearchRepoDescription : config.ValueJSON [bool ]("ui.search_repo_description" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "SEARCH_REPO_DESCRIPTION" }).WithDefault (false ),
152+ OnlyShowRelevantRepos : config.ValueJSON [bool ]("ui.only_show_relevant_repos" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "ONLY_SHOW_RELEVANT_REPOS" }).WithDefault (false ),
153+ ExploreDefaultSort : config.ValueJSON [string ]("ui.explore_paging_default_sort" ).WithFileConfig (config.CfgSecKey {Sec : "ui" , Key : "EXPLORE_PAGING_DEFAULT_SORT" }).WithDefault ("recentupdate" ),
182154 },
183155 }
184156}
0 commit comments