diff --git a/src/templates/src/jam_2024_lj_feed.html b/src/templates/src/jam_2024_lj_feed.html index 314a3bd8..16fb04bc 100644 --- a/src/templates/src/jam_2024_lj_feed.html +++ b/src/templates/src/jam_2024_lj_feed.html @@ -1,32 +1,44 @@ {{ template "jam_2024_learning_base.html" . }} + {{ define "content-top" }} -
- -
The Learning Jam
-
-
-
Learn
-
March 15-17, 2024
-
-
-
Teach
-
March 22-24, 2024
+
+
+ +
+
Learning Jam
+
+
+
Learn
+
March 15-17, 2024
+
+
+
Share
+
March 22-24, 2024
+
-
- Join the Discord +
+ {{ if and (eq .DaysUntilStart 0) (gt .DaysUntilEnd 0) }} + {{ if .SubmittedProjectUrl }} + Share your progress + {{ else }} + Create your project + {{ end }} + {{ end }} + Join the Discord
+
{{ end }} {{ define "content" }} -
-
+
+

Recent activity

-
+
{{ if .TimelineItems }} {{ range .TimelineItems }} - {{ end }} diff --git a/src/templates/src/jam_2024_lj_index.html b/src/templates/src/jam_2024_lj_index.html index 8a322488..0cd05354 100644 --- a/src/templates/src/jam_2024_lj_index.html +++ b/src/templates/src/jam_2024_lj_index.html @@ -1,35 +1,5 @@ {{ template "jam_2024_learning_base.html" . }} -{{ define "extrahead" }} - -{{ end }} - {{ define "content-top" }}
@@ -47,17 +17,19 @@
- {{ if lt .DaysUntilStart 0 }} -
- {{ if .SubmittedProjectUrl }} - Share your progress - {{ else }} - Create your project - {{ end }} - Recent activity -
- {{ end }}
+ {{ if eq .DaysUntilStart 0 }} + {{ if gt .DaysUntilEnd 0 }} + {{ if .SubmittedProjectUrl }} + Share your progress + {{ else }} + Create your project + {{ end }} + Recent activity + {{ else }} + See the results + {{ end }} + {{ end }} Join the Discord
diff --git a/src/templates/src/layouts/jam_2024_learning_base.html b/src/templates/src/layouts/jam_2024_learning_base.html index a9072292..97f62f99 100644 --- a/src/templates/src/layouts/jam_2024_learning_base.html +++ b/src/templates/src/layouts/jam_2024_learning_base.html @@ -175,6 +175,32 @@ background-color: rgba(0, 0, 0, 0.4); } + .jam-logo { + max-width: 18rem; + } + + .jam-title { + /* align with the width of the logo */ + font-size: 2.76rem; + font-weight: 700; + /* align with the text's actual bounding box */ + line-height: 1.18; + margin-top: -0.18em; + margin-left: -0.03em; + margin-right: -0.03em; + } + + /* not small */ + @media screen and (min-width: 35em) { + .jam-logo { + max-width: 24rem; + } + + .jam-title { + font-size: 3.7rem; + } + } + /* not small */ @media screen and (min-width: 35em) { diff --git a/src/website/jam.go b/src/website/jam.go index 8d435ada..0d8fa6fe 100644 --- a/src/website/jam.go +++ b/src/website/jam.go @@ -104,7 +104,7 @@ func JamIndex2024_Learning(c *RequestContext) ResponseData { tmpl.UserAvatarUrl = templates.UserAvatarUrl(c.CurrentUser, "dark") projects, err := hmndata.FetchProjects(c, c.Conn, c.CurrentUser, hmndata.ProjectsQuery{ OwnerIDs: []int{c.CurrentUser.ID}, - JamSlugs: []string{hmndata.WRJ2023.Slug}, + JamSlugs: []string{hmndata.LJ2024.Slug}, Limit: 1, }) if err != nil { @@ -121,6 +121,50 @@ func JamIndex2024_Learning(c *RequestContext) ResponseData { } func JamFeed2024_Learning(c *RequestContext) ResponseData { + daysUntilStart := daysUntil(hmndata.LJ2024.StartTime) + daysUntilEnd := daysUntil(hmndata.LJ2024.EndTime) + + baseData := getBaseDataAutocrumb(c, hmndata.LJ2024.Name) + baseData.OpenGraphItems = []templates.OpenGraphItem{ + {Property: "og:title", Value: "Learning Jam"}, + {Property: "og:site_name", Value: "Handmade Network"}, + {Property: "og:type", Value: "website"}, + {Property: "og:image", Value: hmnurl.BuildPublic("learningjam2024/2024LJOpenGraph.png", true)}, + {Property: "og:description", Value: "A two-weekend jam where you dive deep into a topic, then teach it to the rest of the community."}, + {Property: "og:url", Value: hmnurl.BuildJamFeed2024_Learning()}, + {Name: "twitter:card", Value: "summary_large_image"}, + {Name: "twitter:image", Value: hmnurl.BuildPublic("learningjam2024/2024LJTwitterCard.png", true)}, + } + + type JamFeedData struct { + templates.BaseData + UserAvatarUrl string + DaysUntilStart, DaysUntilEnd int + TwitchEmbedUrl string + ProjectSubmissionUrl string + SubmittedProjectUrl string + + TimelineItems []templates.TimelineItem + } + + twitchEmbedUrl := "" + twitchStatus, err := db.QueryOne[models.TwitchLatestStatus](c, c.Conn, + ` + SELECT $columns + FROM twitch_latest_status + WHERE twitch_login = $1 + `, + "handmadenetwork", + ) + if err == nil { + if twitchStatus.Live { + hmnUrl, err := url.Parse(config.Config.BaseUrl) + if err == nil { + twitchEmbedUrl = fmt.Sprintf("https://player.twitch.tv/?channel=%s&parent=%s", twitchStatus.TwitchLogin, hmnUrl.Hostname()) + } + } + } + jamProjects, err := hmndata.FetchProjects(c, c.Conn, c.CurrentUser, hmndata.ProjectsQuery{ JamSlugs: []string{hmndata.LJ2024.Slug}, }) @@ -150,35 +194,35 @@ func JamFeed2024_Learning(c *RequestContext) ResponseData { } } - type JamFeedData struct { - templates.BaseData - DaysUntilStart, DaysUntilEnd int - - TimelineItems []templates.TimelineItem + tmpl := JamFeedData{ + BaseData: baseData, + UserAvatarUrl: templates.UserAvatarDefaultUrl("dark"), + DaysUntilStart: daysUntilStart, + DaysUntilEnd: daysUntilEnd, + TwitchEmbedUrl: twitchEmbedUrl, + ProjectSubmissionUrl: hmnurl.BuildProjectNewJam(), + SubmittedProjectUrl: "", + TimelineItems: timelineItems, } - daysUntilStart := daysUntil(hmndata.LJ2024.StartTime) - daysUntilEnd := daysUntil(hmndata.LJ2024.EndTime) - - baseData := getBaseDataAutocrumb(c, hmndata.LJ2024.Name) - baseData.OpenGraphItems = []templates.OpenGraphItem{ - {Property: "og:site_name", Value: "Handmade Network"}, - {Property: "og:type", Value: "website"}, - {Property: "og:image", Value: hmnurl.BuildPublic("learningjam2024/opengraph.png", true)}, - {Property: "og:description", Value: "Need desc"}, - {Property: "og:url", Value: hmnurl.BuildJamFeed2024_Learning()}, + if c.CurrentUser != nil { + tmpl.UserAvatarUrl = templates.UserAvatarUrl(c.CurrentUser, "dark") + projects, err := hmndata.FetchProjects(c, c.Conn, c.CurrentUser, hmndata.ProjectsQuery{ + OwnerIDs: []int{c.CurrentUser.ID}, + JamSlugs: []string{hmndata.LJ2024.Slug}, + Limit: 1, + }) + if err != nil { + return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch jam projects for current user")) + } + if len(projects) > 0 { + urlContext := hmndata.UrlContextForProject(&projects[0].Project) + tmpl.SubmittedProjectUrl = urlContext.BuildHomepage() + } } var res ResponseData - res.MustWriteTemplate("jam_2024_lj_feed.html", JamFeedData{ - BaseData: baseData, - DaysUntilStart: daysUntilStart, - DaysUntilEnd: daysUntilEnd, - TimelineItems: timelineItems, - // ProjectSubmissionUrl: hmnurl.BuildProjectNewJam(), - // SubmittedProjectUrl: submittedProjectUrl, - // JamProjects: pageProjects, - }, c.Perf) + res.MustWriteTemplate("jam_2024_lj_feed.html", tmpl, c.Perf) return res }