diff --git a/models/user/setting_keys.go b/models/user/setting_keys.go index 10255735b3177..653e8789a6762 100644 --- a/models/user/setting_keys.go +++ b/models/user/setting_keys.go @@ -12,4 +12,8 @@ const ( UserActivityPubPrivPem = "activitypub.priv_pem" // UserActivityPubPubPem is user's public key UserActivityPubPubPem = "activitypub.pub_pem" + // SettingsPreferAbsoluteTimestamps is the setting key for absolute timestamps + SettingsPreferAbsoluteTimestamps = "timestamps.prefer_absolute" + // SettingsPreferAbsoluteTimestampsDefault is the default setting value for absolute timestamps + SettingsPreferAbsoluteTimestampsDefault = "false" ) diff --git a/modules/timeutil/datetime.go b/modules/timeutil/datetime.go index 80b96fa656be3..29078365c5391 100644 --- a/modules/timeutil/datetime.go +++ b/modules/timeutil/datetime.go @@ -7,11 +7,12 @@ import ( "fmt" "html" "html/template" + "strings" "time" ) // DateTime renders an absolute time HTML element by datetime. -func DateTime(format string, datetime any) template.HTML { +func DateTime(format string, datetime any, attrs ...string) template.HTML { if p, ok := datetime.(*time.Time); ok { datetime = *p } @@ -48,13 +49,15 @@ func DateTime(format string, datetime any) template.HTML { panic(fmt.Sprintf("Unsupported time type %T", datetime)) } + extraAttrs := strings.Join(attrs, " ") + switch format { case "short": - return template.HTML(fmt.Sprintf(`%s`, datetimeEscaped, textEscaped)) + return template.HTML(fmt.Sprintf(`%s`, extraAttrs, datetimeEscaped, textEscaped)) case "long": - return template.HTML(fmt.Sprintf(`%s`, datetimeEscaped, textEscaped)) + return template.HTML(fmt.Sprintf(`%s`, extraAttrs, datetimeEscaped, textEscaped)) case "full": - return template.HTML(fmt.Sprintf(`%s`, datetimeEscaped, textEscaped)) + return template.HTML(fmt.Sprintf(`%s`, extraAttrs, datetimeEscaped, textEscaped)) } panic(fmt.Sprintf("Unsupported format %s", format)) } diff --git a/modules/timeutil/since.go b/modules/timeutil/since.go index 04fcff54a3384..ed63ebfee2ee1 100644 --- a/modules/timeutil/since.go +++ b/modules/timeutil/since.go @@ -4,14 +4,31 @@ package timeutil import ( + "context" "fmt" "html/template" + "strconv" "strings" "time" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/translation" ) +type PreferenceHelper struct { + GetSetting func(ctx context.Context, key string, def ...string) (string, error) + SettingsPreferAbsoluteTimestamps string + SettingsPreferAbsoluteTimestampsDefault string +} + +var preferenceHelper PreferenceHelper + +func Init(ph *PreferenceHelper) { + if ph != nil { + preferenceHelper = *ph + } +} + // Seconds-based time units const ( Minute = 60 @@ -131,11 +148,21 @@ func timeSinceUnix(then, now time.Time, lang translation.Locale) template.HTML { } // TimeSince renders relative time HTML given a time.Time -func TimeSince(then time.Time, lang translation.Locale) template.HTML { +func TimeSince(ctx context.Context, then time.Time, lang translation.Locale) template.HTML { + // if user prefers absolute timestamps, use the full time + val, err := preferenceHelper.GetSetting(ctx, preferenceHelper.SettingsPreferAbsoluteTimestamps, preferenceHelper.SettingsPreferAbsoluteTimestampsDefault) + if err != nil { + log.Error("GetSetting %w", err) + } + preferAbsoluteTimestamps, _ := strconv.ParseBool(val) // we can safely ignore the failed conversion here + if preferAbsoluteTimestamps { + return DateTime("full", then, `class="time-since"`) + } + return timeSinceUnix(then, time.Now(), lang) } // TimeSinceUnix renders relative time HTML given a TimeStamp -func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML { - return TimeSince(then.AsLocalTime(), lang) +func TimeSinceUnix(ctx context.Context, then TimeStamp, lang translation.Locale) template.HTML { + return TimeSince(ctx, then.AsLocalTime(), lang) } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0072ac6fc36fa..b7f66b5b2f133 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -641,6 +641,9 @@ saved_successfully = Your settings were saved successfully. privacy = Privacy keep_activity_private = Hide the activity from the profile page keep_activity_private_popup = Makes the activity visible only for you and the admins +timestamps = Timestamps +prefer_absolute_timestamps = Prefer absolute timestamps +prefer_absolute_timestamps_popup = Display timestamps as absolute dates instead of relative time lookup_avatar_by_mail = Look Up Avatar by Email Address federated_avatar_lookup = Federated Avatar Lookup diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index 0e232c194c2e1..0ee4516eb59a3 100644 --- a/routers/web/repo/blame.go +++ b/routers/web/repo/blame.go @@ -253,7 +253,7 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m commitCnt++ // User avatar image - commitSince := timeutil.TimeSinceUnix(timeutil.TimeStamp(commit.Author.When.Unix()), ctx.Locale) + commitSince := timeutil.TimeSinceUnix(ctx, timeutil.TimeStamp(commit.Author.When.Unix()), ctx.Locale) var avatar string if commit.User != nil { diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go index 7e5295e757b7c..35a7179b60a90 100644 --- a/routers/web/repo/issue_content_history.go +++ b/routers/web/repo/issue_content_history.go @@ -74,7 +74,7 @@ func GetContentHistoryList(ctx *context.Context) { class := avatars.DefaultAvatarClass + " gt-mr-3" name := html.EscapeString(username) avatarHTML := string(templates.AvatarHTML(src, 28, class, username)) - timeSinceText := string(timeutil.TimeSinceUnix(item.EditedUnix, ctx.Locale)) + timeSinceText := string(timeutil.TimeSinceUnix(ctx, item.EditedUnix, ctx.Locale)) results = append(results, map[string]interface{}{ "name": avatarHTML + "" + name + " " + actionText + " " + timeSinceText, diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 0a8a5e6280c46..0bd041f45fced 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -12,6 +12,7 @@ import ( "net/http" "os" "path/filepath" + "strconv" "strings" "code.gitea.io/gitea/models/db" @@ -350,6 +351,14 @@ func Appearance(ctx *context.Context) { return forms.IsUserHiddenCommentTypeGroupChecked(commentTypeGroup, hiddenCommentTypes) } + val, err = user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsPreferAbsoluteTimestamps, user_model.SettingsPreferAbsoluteTimestampsDefault) + if err != nil { + ctx.ServerError("GetUserSetting", err) + return + } + preferAbsoluteTimestamps, _ := strconv.ParseBool(val) // we can safely ignore the failed conversion here + ctx.Data["PreferAbsoluteTimestamps"] = preferAbsoluteTimestamps + ctx.HTML(http.StatusOK, tplSettingsAppearance) } @@ -421,3 +430,16 @@ func UpdateUserHiddenComments(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("settings.saved_successfully")) ctx.Redirect(setting.AppSubURL + "/user/settings/appearance") } + +// UpdateUserTimestamps update a user's timestamp preferences +func UpdateUserTimestamps(ctx *context.Context) { + err := user_model.SetUserSetting(ctx.Doer.ID, user_model.SettingsPreferAbsoluteTimestamps, strconv.FormatBool(forms.UserTimestampsFromRequest(ctx).PreferAbsoluteTimestamps)) + if err != nil { + ctx.ServerError("SetUserSetting", err) + return + } + + log.Trace("User settings updated: %s", ctx.Doer.Name) + ctx.Flash.Success(ctx.Tr("settings.saved_successfully")) + ctx.Redirect(setting.AppSubURL + "/user/settings/appearance") +} diff --git a/routers/web/web.go b/routers/web/web.go index bb2442fec40ec..eaba150deb6b5 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -41,6 +41,7 @@ import ( context_service "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/lfs" + user_service "code.gitea.io/gitea/services/user" _ "code.gitea.io/gitea/modules/session" // to registers all internal adapters @@ -397,6 +398,7 @@ func registerRoutes(m *web.Route) { m.Get("/login/oauth/keys", ignSignInAndCsrf, auth.OIDCKeys) m.Post("/login/oauth/introspect", CorsHandler(), web.Bind(forms.IntrospectTokenForm{}), ignSignInAndCsrf, auth.IntrospectOAuth) + user_service.Init() m.Group("/user/settings", func() { m.Get("", user_setting.Profile) m.Post("", web.Bind(forms.UpdateProfileForm{}), user_setting.ProfilePost) @@ -414,6 +416,7 @@ func registerRoutes(m *web.Route) { m.Get("", user_setting.Appearance) m.Post("/language", web.Bind(forms.UpdateLanguageForm{}), user_setting.UpdateUserLang) m.Post("/hidden_comments", user_setting.UpdateUserHiddenComments) + m.Post("/timestamps", user_setting.UpdateUserTimestamps) m.Post("/theme", web.Bind(forms.UpdateThemeForm{}), user_setting.UpdateUIThemePost) }) m.Group("/security", func() { diff --git a/services/forms/user_form.go b/services/forms/user_form.go index 285bc398b26c5..a23b0ca9dc624 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -261,6 +261,11 @@ type UpdateLanguageForm struct { Language string } +// UpdateTimestampsForm form for updating profile +type UpdateTimestampsForm struct { + PreferAbsoluteTimestamps bool +} + // Validate validates the fields func (f *UpdateLanguageForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { ctx := context.GetContext(req) diff --git a/services/forms/user_form_timestamps.go b/services/forms/user_form_timestamps.go new file mode 100644 index 0000000000000..41ea1bff8ad0c --- /dev/null +++ b/services/forms/user_form_timestamps.go @@ -0,0 +1,14 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package forms + +import ( + "code.gitea.io/gitea/modules/context" +) + +// UserTimestampsFromRequest parses the form for the absolute timestamps preference +func UserTimestampsFromRequest(ctx *context.Context) *UpdateTimestampsForm { + timestampsForm := &UpdateTimestampsForm{PreferAbsoluteTimestamps: ctx.FormBool("prefer_absolute_timestamps")} + return timestampsForm +} diff --git a/services/user/user.go b/services/user/user.go index d52a2f404bcf0..b6a1e3da21262 100644 --- a/services/user/user.go +++ b/services/user/user.go @@ -19,10 +19,12 @@ import ( system_model "code.gitea.io/gitea/models/system" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/avatar" + gitea_context "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/eventsource" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" + "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/packages" ) @@ -290,3 +292,19 @@ func DeleteAvatar(u *user_model.User) error { } return nil } + +func Init() { + timeutil.Init(&timeutil.PreferenceHelper{ + GetSetting: func(ctx context.Context, key string, def ...string) (string, error) { + giteaCtx, ok := ctx.(*gitea_context.Context) + + // this casting should always be ok but if it fails we have to provide a fallback + if !ok { + return "false", nil + } + return user_model.GetUserSetting(giteaCtx.Doer.ID, key, def...) + }, + SettingsPreferAbsoluteTimestamps: user_model.SettingsPreferAbsoluteTimestamps, + SettingsPreferAbsoluteTimestampsDefault: user_model.SettingsPreferAbsoluteTimestampsDefault, + }) +} diff --git a/templates/admin/process-row.tmpl b/templates/admin/process-row.tmpl index 8fd2d1af700dc..a7540879ce3f4 100644 --- a/templates/admin/process-row.tmpl +++ b/templates/admin/process-row.tmpl @@ -3,7 +3,7 @@
{{if eq .Process.Type "request"}}{{svg "octicon-globe" 16}}{{else if eq .Process.Type "system"}}{{svg "octicon-cpu" 16}}{{else}}{{svg "octicon-terminal" 16}}{{end}}
{{.Process.Description}}
-
{{TimeSince .Process.Start .root.locale}}
+
{{TimeSince $.Context .Process.Start .root.locale}}
{{if ne .Process.Type "system"}} diff --git a/templates/admin/stacktrace-row.tmpl b/templates/admin/stacktrace-row.tmpl index 15e51e4aca7ce..874e634686f56 100644 --- a/templates/admin/stacktrace-row.tmpl +++ b/templates/admin/stacktrace-row.tmpl @@ -13,7 +13,7 @@
{{.Process.Description}}
-
{{if ne .Process.Type "none"}}{{TimeSince .Process.Start .root.locale}}{{end}}
+
{{if ne .Process.Type "none"}}{{TimeSince .root.Context .Process.Start .root.locale}}{{end}}
{{if or (eq .Process.Type "request") (eq .Process.Type "normal")}} diff --git a/templates/devtest/gitea-ui.tmpl b/templates/devtest/gitea-ui.tmpl index 2fe478a07d8a0..d739b9b629021 100644 --- a/templates/devtest/gitea-ui.tmpl +++ b/templates/devtest/gitea-ui.tmpl @@ -26,13 +26,13 @@

TimeSince

-
Now: {{TimeSince .TimeNow $.locale}}
-
5s past: {{TimeSince .TimePast5s $.locale}}
-
5s future: {{TimeSince .TimeFuture5s $.locale}}
-
2m past: {{TimeSince .TimePast2m $.locale}}
-
2m future: {{TimeSince .TimeFuture2m $.locale}}
-
1y past: {{TimeSince .TimePast1y $.locale}}
-
1y future: {{TimeSince .TimeFuture1y $.locale}}
+
Now: {{TimeSince $.Context .TimeNow $.locale}}
+
5s past: {{TimeSince $.Context .TimePast5s $.locale}}
+
5s future: {{TimeSince $.Context .TimeFuture5s $.locale}}
+
2m past: {{TimeSince $.Context .TimePast2m $.locale}}
+
2m future: {{TimeSince $.Context .TimeFuture2m $.locale}}
+
1y past: {{TimeSince $.Context .TimePast1y $.locale}}
+
1y future: {{TimeSince $.Context .TimeFuture1y $.locale}}
diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index b311472b43ed2..47e95ee22a171 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -60,7 +60,7 @@ {{end}}
{{end}} -

{{$.locale.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix $.locale}}

+

{{$.locale.Tr "org.repo_updated"}} {{TimeSinceUnix $.Context .UpdatedUnix $.locale}}

{{else}} diff --git a/templates/package/shared/list.tmpl b/templates/package/shared/list.tmpl index 2b6398fcd6705..3c59b0401be66 100644 --- a/templates/package/shared/list.tmpl +++ b/templates/package/shared/list.tmpl @@ -22,7 +22,7 @@ {{svg .Package.Type.SVGName 16}} {{.Package.Type.Name}}
- {{$timeStr := TimeSinceUnix .Version.CreatedUnix $.locale}} + {{$timeStr := TimeSinceUnix $.Context .Version.CreatedUnix $.locale}} {{$hasRepositoryAccess := false}} {{if .Repository}} {{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}} diff --git a/templates/package/shared/versionlist.tmpl b/templates/package/shared/versionlist.tmpl index ba488586a82e6..157e0700aabd5 100644 --- a/templates/package/shared/versionlist.tmpl +++ b/templates/package/shared/versionlist.tmpl @@ -27,7 +27,7 @@ {{.Version.LowerVersion}}
- {{$.locale.Tr "packages.published_by" (TimeSinceUnix .Version.CreatedUnix $.locale) .Creator.HomeLink (.Creator.GetDisplayName | Escape) | Safe}} + {{$.locale.Tr "packages.published_by" (TimeSinceUnix $.Context .Version.CreatedUnix $.locale) .Creator.HomeLink (.Creator.GetDisplayName | Escape) | Safe}}
diff --git a/templates/package/view.tmpl b/templates/package/view.tmpl index 3cb130851fee1..86d74c05cb432 100644 --- a/templates/package/view.tmpl +++ b/templates/package/view.tmpl @@ -9,7 +9,7 @@

{{.PackageDescriptor.Package.Name}} ({{.PackageDescriptor.Version.Version}})

- {{$timeStr := TimeSinceUnix .PackageDescriptor.Version.CreatedUnix $.locale}} + {{$timeStr := TimeSinceUnix $.Context .PackageDescriptor.Version.CreatedUnix $.locale}} {{if .HasRepositoryAccess}} {{.locale.Tr "packages.published_by_in" $timeStr .PackageDescriptor.Creator.HomeLink (.PackageDescriptor.Creator.GetDisplayName | Escape) .PackageDescriptor.Repository.Link (.PackageDescriptor.Repository.FullName | Escape) | Safe}} {{else}} @@ -44,7 +44,7 @@ {{if .HasRepositoryAccess}}
{{svg "octicon-repo" 16 "gt-mr-3"}} {{.PackageDescriptor.Repository.FullName}}
{{end}} -
{{svg "octicon-calendar" 16 "gt-mr-3"}} {{TimeSinceUnix .PackageDescriptor.Version.CreatedUnix $.locale}}
+
{{svg "octicon-calendar" 16 "gt-mr-3"}} {{TimeSinceUnix $.Context .PackageDescriptor.Version.CreatedUnix $.locale}}
{{svg "octicon-download" 16 "gt-mr-3"}} {{.PackageDescriptor.Version.DownloadCount}}
{{template "package/metadata/cargo" .}} {{template "package/metadata/chef" .}} diff --git a/templates/projects/list.tmpl b/templates/projects/list.tmpl index ac4b34a960f25..3c4c9cee8497a 100644 --- a/templates/projects/list.tmpl +++ b/templates/projects/list.tmpl @@ -40,7 +40,7 @@
  • {{svg .IconName}} {{.Title}}
    - {{$closedDate:= TimeSinceUnix .ClosedDateUnix $.locale}} + {{$closedDate:= TimeSinceUnix $.Context .ClosedDateUnix $.locale}} {{if .IsClosed}} {{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.closed" $closedDate | Safe}} {{end}} diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index c108d0b370dbe..e366fcd881589 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -218,7 +218,7 @@
    {{.Repo.FullName}}#{{.Index}} - {{$timeStr := TimeSinceUnix .GetLastEventTimestamp $.locale}} + {{$timeStr := TimeSinceUnix $.Context .GetLastEventTimestamp $.locale}} {{if .OriginalAuthor}} {{$.locale.Tr .GetLastEventLabelFake $timeStr (.OriginalAuthor|Escape) | Safe}} {{else if gt .Poster.ID 0}} diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index 709bfaaced2c4..a04cf5b1b8ea0 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -23,7 +23,7 @@
    -
    {{TimeSinceUnix .Updated $.locale}}
    +
    {{TimeSinceUnix $.Context .Updated $.locale}}
    {{.Duration}}
  • diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index 9d15cec051bfe..32771fd977c31 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -131,7 +131,7 @@ {{if not .IsTag}} {{.Title | RenderEmoji $.Context}} {{end}} - {{TimeSinceUnix .CreatedUnix $.locale}} + {{TimeSinceUnix $.Context .CreatedUnix $.locale}}

    {{end}}
    @@ -150,7 +150,7 @@

    {{$.locale.Tr "repo.activity.merged_prs_label"}} #{{.Index}} {{.Issue.Title | RenderEmoji $.Context}} - {{TimeSinceUnix .MergedUnix $.locale}} + {{TimeSinceUnix $.Context .MergedUnix $.locale}}

    {{end}} @@ -169,7 +169,7 @@

    {{$.locale.Tr "repo.activity.opened_prs_label"}} #{{.Index}} {{.Issue.Title | RenderEmoji $.Context}} - {{TimeSinceUnix .Issue.CreatedUnix $.locale}} + {{TimeSinceUnix $.Context .Issue.CreatedUnix $.locale}}

    {{end}} @@ -188,7 +188,7 @@

    {{$.locale.Tr "repo.activity.closed_issue_label"}} #{{.Index}} {{.Title | RenderEmoji $.Context}} - {{TimeSinceUnix .ClosedUnix $.locale}} + {{TimeSinceUnix $.Context .ClosedUnix $.locale}}

    {{end}} @@ -207,7 +207,7 @@

    {{$.locale.Tr "repo.activity.new_issue_label"}} #{{.Index}} {{.Title | RenderEmoji $.Context}} - {{TimeSinceUnix .CreatedUnix $.locale}} + {{TimeSinceUnix $.Context .CreatedUnix $.locale}}

    {{end}} @@ -231,7 +231,7 @@ {{else}} {{.Title | RenderEmoji $.Context}} {{end}} - {{TimeSinceUnix .UpdatedUnix $.locale}} + {{TimeSinceUnix $.Context .UpdatedUnix $.locale}}

    {{end}} diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index 596d9ae78bd67..0dd5c565cd2ba 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -18,7 +18,7 @@ {{svg "octicon-shield-lock"}} {{end}} {{.DefaultBranch}} -

    {{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .DefaultBranchBranch.Commit.ID.String}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.Commit.CommitMessage .RepoLink .Repository.ComposeMetas}} · {{.locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.Commit.Committer.When .locale}}

    +

    {{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .DefaultBranchBranch.Commit.ID.String}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.Commit.CommitMessage .RepoLink .Repository.ComposeMetas}} · {{.locale.Tr "org.repo_updated"}} {{TimeSince .Context .DefaultBranchBranch.Commit.Committer.When .locale}}

    {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} @@ -60,13 +60,13 @@ {{if .IsDeleted}} {{.Name}} -

    {{$.locale.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSinceUnix .DeletedBranch.DeletedUnix $.locale}}

    +

    {{$.locale.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSinceUnix $.Context .DeletedBranch.DeletedUnix $.locale}}

    {{else}} {{if .IsProtected}} {{svg "octicon-shield-lock"}} {{end}} {{.Name}} -

    {{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage $.Context .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.locale.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.locale}}

    +

    {{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage $.Context .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.locale.Tr "org.repo_updated"}} {{TimeSince $.Context .Commit.Committer.When $.locale}}

    {{end}} diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 5e26c04fd879c..00f192245f2ea 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -156,7 +156,7 @@ {{avatarByEmail $.Context .Commit.Author.Email .Commit.Author.Email 28 "gt-mr-3"}} {{.Commit.Author.Name}} {{end}} - {{TimeSince .Commit.Author.When $.locale}} + {{TimeSince $.Context .Commit.Author.When $.locale}} {{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}} {{.locale.Tr "repo.diff.committed_by"}} {{if ne .Verification.CommittingUser.ID 0}} @@ -277,7 +277,7 @@ {{else}} {{.NoteCommit.Author.Name}} {{end}} - {{TimeSince .NoteCommit.Author.When $.locale}} + {{TimeSince $.Context .NoteCommit.Author.When $.locale}}
    {{RenderNote $.Context .Note $.RepoLink $.Repository.ComposeMetas}}
    diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 36333c554079c..ae15fa5844495 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -76,9 +76,9 @@ {{end}} {{if .Committer}} - {{TimeSince .Committer.When $.locale}} + {{TimeSince $.Context .Committer.When $.locale}} {{else}} - {{TimeSince .Author.When $.locale}} + {{TimeSince $.Context .Author.When $.locale}} {{end}} {{end}} diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index f30126153307a..7c4067b9db9b7 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -1,6 +1,6 @@ {{range .comments}} -{{$createdStr:= TimeSinceUnix .CreatedUnix $.root.locale}} +{{$createdStr:= TimeSinceUnix $.root.Context .CreatedUnix $.root.locale}}
    {{if .OriginalAuthor}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 472bebb33face..ccd7be3fac32d 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -29,7 +29,7 @@
    - {{$closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix $.locale}} + {{$closedDate:= TimeSinceUnix $.Context .Milestone.ClosedDateUnix $.locale}} {{if .IsClosed}} {{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.closed" $closedDate | Safe}} {{else}} diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl index 3a23d225c4306..5487ff0b53eb6 100644 --- a/templates/repo/issue/milestones.tmpl +++ b/templates/repo/issue/milestones.tmpl @@ -71,7 +71,7 @@
    - {{$closedDate:= TimeSinceUnix .ClosedDateUnix $.locale}} + {{$closedDate:= TimeSinceUnix $.Context .ClosedDateUnix $.locale}} {{if .IsClosed}} {{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.closed" $closedDate | Safe}} {{else}} @@ -88,7 +88,7 @@ {{svg "octicon-check" 16 "gt-mr-3"}} {{$.locale.PrettyNumber .NumClosedIssues}} {{$.locale.Tr "repo.issues.closed_title"}} {{if .TotalTrackedTime}}{{svg "octicon-clock"}} {{.TotalTrackedTime|Sec2Time}}{{end}} - {{if .UpdatedUnix}}{{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.update_ago" (TimeSinceUnix .UpdatedUnix $.locale) | Safe}}{{end}} + {{if .UpdatedUnix}}{{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.update_ago" (TimeSinceUnix $.Context .UpdatedUnix $.locale) | Safe}}{{end}}
    {{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 7d3bce2b6a872..712c121500bd3 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -15,7 +15,7 @@ - {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix $.locale}} + {{$createdStr:= TimeSinceUnix $.Context .Issue.CreatedUnix $.locale}}
    diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index b99e49a586342..f49f4aac604b8 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -1,7 +1,7 @@ {{template "base/alert"}} {{range .Issue.Comments}} {{if call $.ShouldShowCommentType .Type}} - {{$createdStr:= TimeSinceUnix .CreatedUnix $.locale}} + {{$createdStr:= TimeSinceUnix $.Context .CreatedUnix $.locale}} +

    + {{.locale.Tr "settings.timestamps"}} +

    +
    +
    + {{.CsrfTokenHtml}} +
    +
    + + +
    +
    +
    + +
    +
    +
    +

    {{.locale.Tr "settings.hidden_comment_types"}} diff --git a/templates/user/settings/security/webauthn.tmpl b/templates/user/settings/security/webauthn.tmpl index 59022eb1c976d..ada7ac78183c8 100644 --- a/templates/user/settings/security/webauthn.tmpl +++ b/templates/user/settings/security/webauthn.tmpl @@ -14,7 +14,7 @@
    {{.Name}}
    - {{TimeSinceUnix .CreatedUnix $.locale}} + {{TimeSinceUnix $.Context .CreatedUnix $.locale}}

    {{end}}