Skip to content

Commit 0504a8c

Browse files
committed
Switch to PreferredTimestampTense
Signed-off-by: Yarden Shoham <[email protected]>
1 parent bbe69c3 commit 0504a8c

File tree

5 files changed

+53
-46
lines changed

5 files changed

+53
-46
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,9 @@ LEVEL = Info
12451245
;; Default is "recentupdate", but you also have "alphabetically", "reverselastlogin", "newest", "oldest".
12461246
;EXPLORE_PAGING_DEFAULT_SORT = recentupdate
12471247
;;
1248-
;; Whether all timestamps should be rendered as absolute time (i.e. 1970-01-01, 11:59). Setting this to false means some timestamps would render as relative (i.e. 2 days ago).
1249-
;PREFER_ABSOLUTE_TIMESTAMPS = false
1248+
;; The tense all timestamps should be rendered as. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) or `mixed`
1249+
;; which means some timestamps would render as relative (i.e. 2 days ago).
1250+
;PREFERRED_TIMESTAMP_TENSE = mixed
12501251

12511252
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12521253
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
231231
- `ONLY_SHOW_RELEVANT_REPOS`: **false**: Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
232232
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
233233
- `EXPLORE_PAGING_DEFAULT_SORT`: **recentupdate**: Change the sort type of the explore pages. Valid values are "recentupdate", "alphabetically", "reverselastlogin", "newest" and "oldest"
234-
- `PREFER_ABSOLUTE_TIMESTAMPS`: **false**: Whether all timestamps should be rendered as absolute time (i.e. 1970-01-01, 11:59). Setting this to false means some timestamps would render as relative (i.e. 2 days ago).
234+
- `PREFERRED_TIMESTAMP_TENSE`: **mixed**: The tense all timestamps should be rendered as. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) or `mixed` which means some timestamps would render as relative (i.e. 2 days ago).
235235

236236
### UI - Admin (`ui.admin`)
237237

modules/setting/ui.go

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,35 @@ import (
77
"time"
88

99
"code.gitea.io/gitea/modules/container"
10+
"code.gitea.io/gitea/modules/log"
1011
)
1112

1213
// UI settings
1314
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-
MaxDisplayFileSize int64
26-
ShowUserEmail bool
27-
DefaultShowFullName bool
28-
DefaultTheme string
29-
Themes []string
30-
Reactions []string
31-
ReactionsLookup container.Set[string] `ini:"-"`
32-
CustomEmojis []string
33-
CustomEmojisMap map[string]string `ini:"-"`
34-
SearchRepoDescription bool
35-
OnlyShowRelevantRepos bool
36-
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
37-
PreferAbsoluteTimestamps bool
15+
ExplorePagingNum int
16+
SitemapPagingNum int
17+
IssuePagingNum int
18+
RepoSearchPagingNum int
19+
MembersPagingNum int
20+
FeedMaxCommitNum int
21+
FeedPagingNum int
22+
PackagesPagingNum int
23+
GraphMaxCommitNum int
24+
CodeCommentLines int
25+
ReactionMaxUserNum int
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+
OnlyShowRelevantRepos bool
37+
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
38+
PreferredTimestampTense string
3839

3940
AmbiguousUnicodeDetection bool
4041

@@ -68,23 +69,24 @@ var UI = struct {
6869
Keywords string
6970
} `ini:"ui.meta"`
7071
}{
71-
ExplorePagingNum: 20,
72-
SitemapPagingNum: 20,
73-
IssuePagingNum: 20,
74-
RepoSearchPagingNum: 20,
75-
MembersPagingNum: 20,
76-
FeedMaxCommitNum: 5,
77-
FeedPagingNum: 20,
78-
PackagesPagingNum: 20,
79-
GraphMaxCommitNum: 100,
80-
CodeCommentLines: 4,
81-
ReactionMaxUserNum: 10,
82-
MaxDisplayFileSize: 8388608,
83-
DefaultTheme: `gitea-auto`,
84-
Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`},
85-
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
86-
CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`},
87-
CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"},
72+
ExplorePagingNum: 20,
73+
SitemapPagingNum: 20,
74+
IssuePagingNum: 20,
75+
RepoSearchPagingNum: 20,
76+
MembersPagingNum: 20,
77+
FeedMaxCommitNum: 5,
78+
FeedPagingNum: 20,
79+
PackagesPagingNum: 20,
80+
GraphMaxCommitNum: 100,
81+
CodeCommentLines: 4,
82+
ReactionMaxUserNum: 10,
83+
MaxDisplayFileSize: 8388608,
84+
DefaultTheme: `gitea-auto`,
85+
Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`},
86+
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
87+
CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`},
88+
CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"},
89+
PreferredTimestampTense: "mixed",
8890

8991
AmbiguousUnicodeDetection: true,
9092

@@ -143,6 +145,10 @@ func loadUIFrom(rootCfg ConfigProvider) {
143145
UI.DefaultShowFullName = sec.Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
144146
UI.SearchRepoDescription = sec.Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
145147

148+
if UI.PreferredTimestampTense != "mixed" && UI.PreferredTimestampTense != "absolute" {
149+
log.Fatal("ui.PREFERRED_TIMESTAMP_TENSE must be either 'mixed' or 'absolute'")
150+
}
151+
146152
// OnlyShowRelevantRepos=false is important for many private/enterprise instances,
147153
// because many private repositories do not have "description/topic", users just want to search by their names.
148154
UI.OnlyShowRelevantRepos = sec.Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false)

modules/timeutil/since.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func timeSinceUnix(then, now time.Time, lang translation.Locale) template.HTML {
133133

134134
// TimeSince renders relative time HTML given a time.Time
135135
func TimeSince(then time.Time, lang translation.Locale) template.HTML {
136-
if setting.UI.PreferAbsoluteTimestamps {
136+
if setting.UI.PreferredTimestampTense == "absolute" {
137137
return DateTime("full", then, `class="time-since"`)
138138
}
139139
return timeSinceUnix(then, time.Now(), lang)

web_src/js/components/DiffCommitSelector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export default {
247247
<div class="gt-ellipsis text light-2">
248248
{{ commit.committer_or_author_name }}
249249
<span class="text right">
250-
<!-- TODO: make this respect the PreferAbsoluteTimestamps setting -->
250+
<!-- TODO: make this respect the PreferredTimestampTense setting -->
251251
<relative-time class="time-since" prefix="" :datetime="commit.time" data-tooltip-content data-tooltip-interactive="true">{{ commit.time }}</relative-time>
252252
</span>
253253
</div>

0 commit comments

Comments
 (0)