diff --git a/appview/pages/pages.go b/appview/pages/pages.go index c2a8c559..5f81540e 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -407,6 +407,13 @@ type RecentItem struct { 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 @@ type TimelineParams struct { 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/pages/templates/timeline/fragments/announcements.html b/appview/pages/templates/timeline/fragments/announcements.html index f281fb9c..23d6cf87 100644 --- 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. -

+{{ define "recentBlogPosts" }} + +{{ end }} -
- - Read more - - {{ if and .LoggedInUser .VouchSuggestions }} - - View suggestions {{ i "arrow-right" "size-3.5" }} - - {{ 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" }} -
+ +
+ {{ i "shield-plus" "size-48" }} +
+
{{ end }} diff --git a/appview/pages/templates/timeline/fragments/timeline.html b/appview/pages/templates/timeline/fragments/timeline.html index 64fb55d9..08ef62a1 100644 --- 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 }} diff --git a/appview/pages/templates/timeline/timeline.html b/appview/pages/templates/timeline/timeline.html index 46ac0d61..478dbddd 100644 --- 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/timeline/router.go b/appview/timeline/router.go index 765fa1e2..86757d75 100644 --- a/appview/timeline/router.go +++ b/appview/timeline/router.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "strings" + "time" "github.com/adrg/frontmatter" "github.com/go-chi/chi/v5" @@ -17,10 +18,11 @@ import ( ) 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 @@ func loadRecentPosts(postsDir string, logger *slog.Logger) []pages.BlogPost { 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 }