From 02fb64d6892f89d0497e397266b574e2ab772f3b Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Sat, 30 May 2026 10:50:41 +0000 Subject: [PATCH] appview/timeline: add recently visited pages to timeline Signed-off-by: oppiliappan --- appview/pages/pages.go | 8 ++++++++ appview/pages/templates/notifications/fragments/item.html | 3 +-- appview/pages/templates/timeline/fragments/recents.html | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ appview/pages/templates/timeline/fragments/vouchSuggestions.html | 4 ++-- appview/pages/templates/timeline/timeline.html | 3 ++- appview/state/timeline.go | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 6 file(s) changed, 192 insertion(s)(+), 6 deletion(s)(-) diff --git a/appview/pages/pages.go b/appview/pages/pages.go --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -400,6 +400,13 @@ func (p *Pages) Brand(w io.Writer, params BrandParams) error { return p.execute("brand/brand", w, params) } +type RecentItem struct { + Link *models.RecentLink + Repo *models.Repo + Issue *models.Issue + Pull *models.Pull +} + type TimelineParams struct { LoggedInUser *oauth.MultiAccountUser Timeline []models.TimelineGroup @@ -408,6 +415,7 @@ GfiLabel *models.LabelDefinition BlueskyPosts []models.BskyPost VouchSuggestions []models.VouchSuggestion Notifications []*models.NotificationWithEntity + Recents []RecentItem // ShowNewsletter controls whether the newsletter widget/CTA is rendered. // For logged-in users it reflects their newsletter_preferences row; for // anonymous visitors it is always true (dismissal falls back to diff --git a/appview/pages/templates/notifications/fragments/item.html b/appview/pages/templates/notifications/fragments/item.html --- a/appview/pages/templates/notifications/fragments/item.html +++ b/appview/pages/templates/notifications/fragments/item.html @@ -5,8 +5,7 @@ class="block no-underline hover:no-underline group">
{{/* row 1, col 1: icon */}} diff --git a/appview/pages/templates/timeline/fragments/recents.html b/appview/pages/templates/timeline/fragments/recents.html new file mode 100644 --- /dev/null +++ b/appview/pages/templates/timeline/fragments/recents.html @@ -0,0 +1,84 @@ +{{ define "timeline/fragments/recents" }} + {{ if .LoggedInUser }} +
+

+ {{ i "history" "size-4 flex-shrink-0" }} + Recents +

+ + {{ if not .Recents }} +
+
+ {{ i "route" "size-10" }} +
+

No recent pages yet.

+
+ {{ else }} +
+
+ {{ range .Recents }} + {{ if .Repo }} + {{ template "timeline/fragments/recentRepo" . }} + {{ else if .Issue }} + {{ template "timeline/fragments/recentIssue" . }} + {{ else if .Pull }} + {{ template "timeline/fragments/recentPull" . }} + {{ end }} + {{ end }} +
+ {{ end }} +
+ {{ end }} +{{ end }} + +{{ define "recentRowClass" }} + relative grid grid-cols-[1.75rem_1fr_auto] grid-rows-2 gap-x-3 pl-4 pr-4 py-3 text-sm no-underline hover:no-underline hover:bg-gray-100/50 dark:hover:bg-gray-700/50 overflow-hidden +{{ end }} + +{{/* call with dict "color" "text-*" "icon" "icon-name" */}} +{{ define "recentIconCircle" }} + + {{ i .icon "w-3.5 h-3.5" }} + +{{ end }} + +{{ define "timeline/fragments/recentRepo" }} + {{ $repoOwner := resolve .Repo.Did }} + + + {{ template "user/fragments/pic" (list .Repo.Did "size-7") }} + + {{ $repoOwner }}/{{ .Repo.Name }} + {{ template "repo/fragments/shortTime" .Link.Visited }} + +{{ end }} + +{{ define "timeline/fragments/recentIssue" }} + {{ $repoOwner := resolve .Issue.Repo.Did }} + + {{ if .Issue.Open }} + {{ template "recentIconCircle" (dict "color" "text-green-600 dark:text-green-500" "icon" "circle-dot") }} + {{ else }} + {{ template "recentIconCircle" (dict "color" "text-gray-500 dark:text-gray-400" "icon" "ban") }} + {{ end }} + {{ .Issue.Title }} + {{ $repoOwner }}/{{ .Issue.Repo.Name }} + {{ template "repo/fragments/shortTime" .Link.Visited }} + +{{ end }} + +{{ define "timeline/fragments/recentPull" }} + {{ $repoOwner := resolve .Pull.Repo.Did }} + + {{ if .Pull.State.IsOpen }} + {{ template "recentIconCircle" (dict "color" "text-green-600 dark:text-green-500" "icon" "git-pull-request") }} + {{ else if .Pull.State.IsMerged }} + {{ template "recentIconCircle" (dict "color" "text-purple-600 dark:text-purple-500" "icon" "git-merge") }} + {{ else }} + {{ template "recentIconCircle" (dict "color" "text-gray-600 dark:text-gray-300" "icon" "git-pull-request-closed") }} + {{ end }} + {{ .Pull.Title }} + {{ $repoOwner }}/{{ .Pull.Repo.Name }} + {{ template "repo/fragments/shortTime" .Link.Visited }} + +{{ end }} diff --git a/appview/pages/templates/timeline/fragments/vouchSuggestions.html b/appview/pages/templates/timeline/fragments/vouchSuggestions.html --- a/appview/pages/templates/timeline/fragments/vouchSuggestions.html +++ b/appview/pages/templates/timeline/fragments/vouchSuggestions.html @@ -8,8 +8,8 @@ Suggested View all {{ i "arrow-right" "size-3.5" }} - -
+ +
{{ range .VouchSuggestions }}
diff --git a/appview/pages/templates/timeline/timeline.html b/appview/pages/templates/timeline/timeline.html --- a/appview/pages/templates/timeline/timeline.html +++ b/appview/pages/templates/timeline/timeline.html @@ -16,8 +16,9 @@ {{ define "content" }}
-