From c49a5e0bb37c255f79b0739eb0fa83a85428cf8b Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Thu, 4 Jul 2024 17:26:36 -0500 Subject: [PATCH] Add banner and maybe other things, I do not remember --- src/templates/mapping.go | 12 ++++++ src/templates/src/include/header-2024.html | 26 +++++++++++++ src/templates/src/layouts/base-2024.html | 2 +- src/templates/types.go | 11 ++++++ src/utils/utils.go | 8 ++++ src/website/base_data.go | 19 ++++++++++ src/website/jam.go | 43 +++++++++------------- src/website/landing.go | 13 ++++--- 8 files changed, 102 insertions(+), 32 deletions(-) diff --git a/src/templates/mapping.go b/src/templates/mapping.go index 7dc9c7f3..69140b16 100644 --- a/src/templates/mapping.go +++ b/src/templates/mapping.go @@ -12,6 +12,7 @@ import ( "git.handmade.network/hmn/hmn/src/hmnurl" "git.handmade.network/hmn/hmn/src/links" "git.handmade.network/hmn/hmn/src/models" + "git.handmade.network/hmn/hmn/src/utils" ) func PostToTemplate(p *models.Post, author *models.User) Post { @@ -494,6 +495,17 @@ func CalendarEventToTemplate(ev *calendar.CalendarEvent) CalendarEvent { } } +func JamToBannerEvent(jam hmndata.Jam) BannerEvent { + return BannerEvent{ + Slug: jam.Slug, + DaysUntilStart: utils.DaysUntil(jam.StartTime), + DaysUntilEnd: utils.DaysUntil(jam.EndTime), + StartTimeUnix: jam.StartTime.Unix(), + EndTimeUnix: jam.EndTime.Unix(), + Url: hmnurl.BuildJamIndexAny(jam.UrlSlug), + } +} + func maybeString(s *string) string { if s == nil { return "" diff --git a/src/templates/src/include/header-2024.html b/src/templates/src/include/header-2024.html index a92ab908..d94fb2cc 100644 --- a/src/templates/src/include/header-2024.html +++ b/src/templates/src/include/header-2024.html @@ -56,6 +56,32 @@ {{ end }} +{{ if and .Header.BannerEvent (not .Header.SuppressBanners) }} + {{ with .Header.BannerEvent }} + {{ if eq .Slug "VJ2024" }} + + Visibility Jam. + July 19-21, 2024. + {{ if gt .DaysUntilEnd 0 }} + {{ if eq .DaysUntilStart 0 }} + Happening now. + {{ else if eq .DaysUntilStart 1 }} + Starting tomorrow. + {{ else }} + In {{ .DaysUntilStart }} days. + {{ end }} + {{ else }} + See the results. + {{ end }} + + {{ end }} + {{ end }} +{{ end }} +