From 25cc5ef11b17020aa3314a46b28dd76b9a3efd6c Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 25 Sep 2023 02:40:45 -0500 Subject: [PATCH] Rework structure of project index. Need new copy. --- public/style.css | 21 +++ src/hmndata/jams.go | 36 ++-- src/hmnurl/hmnurl_test.go | 18 +- src/hmnurl/urls.go | 17 +- src/rawdata/scss/_core.scss | 18 ++ src/templates/src/project_index.html | 112 ++++++++---- src/website/base_data.go | 4 +- src/website/feed.go | 2 +- src/website/projects.go | 251 +++++++++++++++++++-------- 9 files changed, 349 insertions(+), 130 deletions(-) diff --git a/public/style.css b/public/style.css index 574382b..8207383 100644 --- a/public/style.css +++ b/public/style.css @@ -7553,6 +7553,15 @@ article code { .g5 { gap: 4rem; } +.grid { + display: grid; } + +.grid-1 { + grid-template-columns: 1fr; } + +.grid-2 { + grid-template-columns: 1fr 1fr; } + .aspect-ratio--2x1 { padding-bottom: 50%; } @@ -7582,6 +7591,10 @@ article code { column-gap: 2rem; } .cg5-ns { column-gap: 4rem; } + .grid-1-ns { + grid-template-columns: 1fr; } + .grid-2-ns { + grid-template-columns: 1fr 1fr; } .bg--dim-ns { background-color: #f0f0f0; background-color: var(--dim-background); } } @@ -7607,6 +7620,10 @@ article code { column-gap: 2rem; } .cg5-m { column-gap: 4rem; } + .grid-1-m { + grid-template-columns: 1fr; } + .grid-2-m { + grid-template-columns: 1fr 1fr; } .bg--dim-m { background-color: #f0f0f0; background-color: var(--dim-background); } } @@ -7632,6 +7649,10 @@ article code { column-gap: 2rem; } .cg5-l { column-gap: 4rem; } + .grid-1-l { + grid-template-columns: 1fr; } + .grid-2-l { + grid-template-columns: 1fr 1fr; } .bg--dim-l { background-color: #f0f0f0; background-color: var(--dim-background); } } diff --git a/src/hmndata/jams.go b/src/hmndata/jams.go index 181e377..3b206f3 100644 --- a/src/hmndata/jams.go +++ b/src/hmndata/jams.go @@ -17,8 +17,9 @@ type Event struct { type Jam struct { Event - Name string - Slug string + Name string + Slug string + UrlSlug string } var WRJ2021 = Jam{ @@ -26,8 +27,9 @@ var WRJ2021 = Jam{ StartTime: time.Date(2021, 9, 27, 0, 0, 0, 0, time.UTC), EndTime: time.Date(2021, 10, 4, 0, 0, 0, 0, time.UTC), }, - Name: "Wheel Reinvention Jam 2021", - Slug: "WRJ2021", + Name: "Wheel Reinvention Jam 2021", + Slug: "WRJ2021", + UrlSlug: "2021", } var WRJ2022 = Jam{ @@ -35,8 +37,9 @@ var WRJ2022 = Jam{ StartTime: time.Date(2022, 8, 15, 0, 0, 0, 0, utils.Must1(time.LoadLocation("America/Los_Angeles"))), EndTime: time.Date(2022, 8, 22, 8, 0, 0, 0, utils.Must1(time.LoadLocation("America/Los_Angeles"))), }, - Name: "Wheel Reinvention Jam 2022", - Slug: "WRJ2022", + Name: "Wheel Reinvention Jam 2022", + Slug: "WRJ2022", + UrlSlug: "2022", } var VJ2023 = Jam{ @@ -44,8 +47,9 @@ var VJ2023 = Jam{ StartTime: time.Date(2023, 4, 14, 0, 0, 0, 0, time.UTC), EndTime: time.Date(2023, 4, 17, 0, 0, 0, 0, time.UTC), }, - Name: "Visibility Jam 2023", - Slug: "VJ2023", + Name: "Visibility Jam 2023", + Slug: "VJ2023", + UrlSlug: "visibility-2023", } var WRJ2023 = Jam{ @@ -53,8 +57,9 @@ var WRJ2023 = Jam{ StartTime: time.Date(2023, 9, 25, 10, 0, 0, 0, utils.Must1(time.LoadLocation("Europe/London"))), EndTime: time.Date(2023, 10, 1, 20, 0, 0, 0, utils.Must1(time.LoadLocation("Europe/London"))), }, - Name: "Wheel Reinvention Jam 2023", - Slug: "WRJ2023", + Name: "Wheel Reinvention Jam 2023", + Slug: "WRJ2023", + UrlSlug: "2023", } var HMS2022 = Event{ @@ -84,6 +89,17 @@ func CurrentJam() *Jam { return nil } +func PreviousJam() *Jam { + now := time.Now() + var mostRecent *Jam + for i, jam := range AllJams { + if jam.EndTime.Before(now) { + mostRecent = &AllJams[i] + } + } + return mostRecent +} + func JamBySlug(slug string) Jam { for _, jam := range AllJams { if jam.Slug == slug { diff --git a/src/hmnurl/hmnurl_test.go b/src/hmnurl/hmnurl_test.go index 1fc502b..cbbaa0a 100644 --- a/src/hmnurl/hmnurl_test.go +++ b/src/hmnurl/hmnurl_test.go @@ -142,9 +142,11 @@ func TestFeed(t *testing.T) { } func TestProjectIndex(t *testing.T) { - AssertRegexMatch(t, BuildProjectIndex(1), RegexProjectIndex, nil) - AssertRegexMatch(t, BuildProjectIndex(2), RegexProjectIndex, map[string]string{"page": "2"}) - assert.Panics(t, func() { BuildProjectIndex(0) }) + AssertRegexMatch(t, BuildProjectIndex(1, ""), RegexProjectIndex, nil) + AssertRegexMatch(t, BuildProjectIndex(2, ""), RegexProjectIndex, map[string]string{"page": "2"}) + AssertRegexMatch(t, BuildProjectIndex(1, "test"), RegexProjectIndex, map[string]string{"category": "test"}) + AssertRegexMatch(t, BuildProjectIndex(2, "test"), RegexProjectIndex, map[string]string{"page": "2", "category": "test"}) + assert.Panics(t, func() { BuildProjectIndex(0, "") }) } func TestProjectNew(t *testing.T) { @@ -415,6 +417,16 @@ func TestJamRecap2023_Visibility(t *testing.T) { AssertSubdomain(t, BuildJamRecap2023_Visibility(), "") } +func TestJamIndex2023(t *testing.T) { + AssertRegexMatch(t, BuildJamIndex2023(), RegexJamIndex2023, nil) + AssertSubdomain(t, BuildJamIndex2023(), "") +} + +func TestJamFeed2023(t *testing.T) { + AssertRegexMatch(t, BuildJamFeed2023(), RegexJamFeed2023, nil) + AssertSubdomain(t, BuildJamFeed2023(), "") +} + func TestTimeMachine(t *testing.T) { AssertRegexMatch(t, BuildTimeMachine(), RegexTimeMachine, nil) AssertSubdomain(t, BuildTimeMachine(), "") diff --git a/src/hmnurl/urls.go b/src/hmnurl/urls.go index af54253..0c143db 100644 --- a/src/hmnurl/urls.go +++ b/src/hmnurl/urls.go @@ -126,6 +126,11 @@ func BuildJamRecap2023_Visibility() string { return Url("/jam/visibility-2023/recap", nil) } +func BuildJamIndexAny(slug string) string { + defer CatchPanic() + return Url(fmt.Sprintf("/jam/%s", slug), nil) +} + var RegexTimeMachine = regexp.MustCompile("^/timemachine$") func BuildTimeMachine() string { @@ -445,17 +450,21 @@ func BuildAtomFeedForShowcase() string { * Projects */ -var RegexProjectIndex = regexp.MustCompile("^/projects(/(?P.+)?)?$") +var RegexProjectIndex = regexp.MustCompile(`^/projects(/(?P[a-z][a-z0-9]+))?(/(?P\d+))?$`) -func BuildProjectIndex(page int) string { +func BuildProjectIndex(page int, category string) string { defer CatchPanic() if page < 1 { panic(oops.New(nil, "page must be >= 1")) } + catpath := "" + if category != "" { + catpath = "/" + category + } if page == 1 { - return Url("/projects", nil) + return Url(fmt.Sprintf("/projects%s", catpath), nil) } else { - return Url(fmt.Sprintf("/projects/%d", page), nil) + return Url(fmt.Sprintf("/projects%s/%d", catpath, page), nil) } } diff --git a/src/rawdata/scss/_core.scss b/src/rawdata/scss/_core.scss index da90023..067cce1 100644 --- a/src/rawdata/scss/_core.scss +++ b/src/rawdata/scss/_core.scss @@ -372,6 +372,18 @@ article code { .g4 { gap: $spacing-large; } .g5 { gap: $spacing-extra-large; } +.grid { + display: grid; +} + +.grid-1 { + grid-template-columns: 1fr; +} + +.grid-2 { + grid-template-columns: 1fr 1fr; +} + .aspect-ratio--2x1 { padding-bottom: 50%; } @@ -392,6 +404,8 @@ article code { .cg3-ns { column-gap: $spacing-medium; } .cg4-ns { column-gap: $spacing-large; } .cg5-ns { column-gap: $spacing-extra-large; } + .grid-1-ns { grid-template-columns: 1fr; } + .grid-2-ns { grid-template-columns: 1fr 1fr; } .bg--dim-ns { @include usevar(background-color, dim-background); @@ -409,6 +423,8 @@ article code { .cg3-m { column-gap: $spacing-medium; } .cg4-m { column-gap: $spacing-large; } .cg5-m { column-gap: $spacing-extra-large; } + .grid-1-m { grid-template-columns: 1fr; } + .grid-2-m { grid-template-columns: 1fr 1fr; } .bg--dim-m { @include usevar(background-color, dim-background); @@ -426,6 +442,8 @@ article code { .cg3-l { column-gap: $spacing-medium; } .cg4-l { column-gap: $spacing-large; } .cg5-l { column-gap: $spacing-extra-large; } + .grid-1-l { grid-template-columns: 1fr; } + .grid-2-l { grid-template-columns: 1fr 1fr; } .bg--dim-l { @include usevar(background-color, dim-background); diff --git a/src/templates/src/project_index.html b/src/templates/src/project_index.html index 36eef58..b30aa72 100644 --- a/src/templates/src/project_index.html +++ b/src/templates/src/project_index.html @@ -4,13 +4,13 @@ {{ end }} -{{ define "content" }} +{{ define "all_projects" }}
- {{ with .CarouselProjects }} + {{ with .OfficialProjects }}