From 62d59cb88eb736154b4c50cc091fb6ee7bbf76e4 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Mon, 08 Jun 2026 10:59:24 +0000 Subject: [PATCH] appview/timeline: process recent blog posts and show on timeline Signed-off-by: oppiliappan --- appview/pages/pages.go | 8 ++++++++ appview/timeline/router.go | 13 ++++++++----- appview/pages/templates/timeline/timeline.html | 8 +++++--- appview/pages/templates/timeline/fragments/announcements.html | 69 ++++++++++++++++++++++++++++++++++++++++++--------------------------- appview/pages/templates/timeline/fragments/timeline.html | 19 +++++++++++++++++++ 5 file(s) changed, 82 insertion(s)(+), 35 deletion(s)(-) diff --git a/appview/pages/pages.go b/appview/pages/pages.go --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -407,6 +407,13 @@ Pull *models.Pull } +type BlogPost struct { + Slug string + Title string + Subtitle string + Date time.Time +} + type TimelineParams struct { LoggedInUser *oauth.MultiAccountUser Timeline []models.TimelineGroup @@ -417,6 +424,7 @@ Notifications []*models.NotificationWithEntity Recents []RecentItem FollowingOnly bool + RecentBlogPosts []BlogPost // 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/timeline/router.go b/appview/timeline/router.go --- a/appview/timeline/router.go +++ b/appview/timeline/router.go @@ -7,6 +7,7 @@ "net/http" "os" "strings" + "time" "github.com/adrg/frontmatter" "github.com/go-chi/chi/v5" @@ -17,10 +18,11 @@ ) type postMeta struct { - Slug string `yaml:"slug"` - Title string `yaml:"title"` - Date string `yaml:"date"` - Draft bool `yaml:"draft"` + Slug string `yaml:"slug"` + Title string `yaml:"title"` + Subtitle string `yaml:"subtitle"` + Date string `yaml:"date"` + Draft bool `yaml:"draft"` } type Timeline struct { @@ -99,7 +101,8 @@ result := make([]pages.BlogPost, len(posts)) for i, p := range posts { - result[i] = pages.BlogPost{Slug: p.Slug, Title: p.Title, Date: p.Date} + t, _ := time.Parse("2006-01-02", p.Date) + result[i] = pages.BlogPost{Slug: p.Slug, Title: p.Title, Subtitle: p.Subtitle, Date: t} } return result } 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 @@ -32,15 +32,17 @@ {{ end }} - {{ template "timeline/fragments/announcements" . }} + {{ template "timeline/fragments/trending" . }} + + {{ if and .LoggedInUser .VouchSuggestions }} {{ end }} - - {{ template "timeline/fragments/trending" . }} diff --git a/appview/pages/templates/timeline/fragments/announcements.html b/appview/pages/templates/timeline/fragments/announcements.html --- a/appview/pages/templates/timeline/fragments/announcements.html +++ b/appview/pages/templates/timeline/fragments/announcements.html @@ -4,37 +4,52 @@ {{ i "megaphone" "size-4 flex-shrink-0" }} Announcements -
+
{{ template "vouchAnnouncement" . }} + {{ if .RecentBlogPosts }} + {{ template "recentBlogPosts" . }} + {{ end }}
{{ end }} -{{ define "vouchAnnouncement" }} -
-
-
-

Build a web of trust

-

- Vouch for trustworthy users that make open-source a better place. Visit a user's - profile to vouch for them. -

- -
- - Read more - - {{ if and .LoggedInUser .VouchSuggestions }} - - View suggestions {{ i "arrow-right" "size-3.5" }} - - {{ end }} -
- -
- -
- {{ i "shield-plus" "size-48" }} -
+{{ define "recentBlogPosts" }} + +{{ end }} + +{{ define "vouchAnnouncement" }} +
+
+
+

Build a web of trust

+

+ Vouch for trustworthy users that make open-source a better place. Visit a user's + profile to vouch for them. +

+ +
+ + Read more + + {{ if and .LoggedInUser .VouchSuggestions }} + + View suggestions {{ i "arrow-right" "size-3.5" }} + + {{ end }} +
+ +
+ +
+ {{ i "shield-plus" "size-48" }} +
+
{{ end }} diff --git a/appview/pages/templates/timeline/fragments/timeline.html b/appview/pages/templates/timeline/fragments/timeline.html --- a/appview/pages/templates/timeline/fragments/timeline.html +++ b/appview/pages/templates/timeline/fragments/timeline.html @@ -35,6 +35,7 @@ {{ end }}
+ {{ if .Timeline }}
{{ range $i, $g := .Timeline }}
@@ -54,6 +55,24 @@
{{ end }}
+ {{ else }} +
+
+ {{ if .FollowingOnly }} + {{ i "user-round-x" "size-10" }} + {{ else }} + {{ i "radio" "size-10" }} + {{ end }} +
+

+ {{ if .FollowingOnly }} + Follow some users to see their activity here. + {{ else }} + Nothing here yet. + {{ end }} +

+
+ {{ end }} {{ end }} -- tangled.sh