diff --git a/src/hmnurl/hmnurl_test.go b/src/hmnurl/hmnurl_test.go index 73b5ec7d..4bb806db 100644 --- a/src/hmnurl/hmnurl_test.go +++ b/src/hmnurl/hmnurl_test.go @@ -40,10 +40,6 @@ func TestHomepage(t *testing.T) { AssertSubdomain(t, hero.BuildHomepage(), "hero") } -func TestShowcase(t *testing.T) { - AssertRegexMatch(t, BuildShowcase(), RegexShowcase, nil) -} - func TestWhenIsIt(t *testing.T) { AssertRegexMatch(t, BuildWhenIsIt(), RegexWhenIsIt, nil) } @@ -96,8 +92,6 @@ func TestStaticPages(t *testing.T) { AssertRegexMatch(t, BuildManifesto(), RegexManifesto, nil) AssertRegexMatch(t, BuildAbout(), RegexAbout, nil) AssertRegexMatch(t, BuildFoundation(), RegexFoundation, nil) - AssertRegexMatch(t, BuildStaffRole("test"), RegexStaffRole, nil) - AssertRegexMatch(t, BuildStaffRolesIndex(), RegexStaffRolesIndex, nil) AssertRegexMatch(t, BuildCommunicationGuidelines(), RegexCommunicationGuidelines, nil) AssertRegexMatch(t, BuildContactPage(), RegexContactPage, nil) AssertRegexMatch(t, BuildMonthlyUpdatePolicy(), RegexMonthlyUpdatePolicy, nil) @@ -459,7 +453,7 @@ func TestTimeMachineFormDone(t *testing.T) { } func TestNewsletterSignup(t *testing.T) { - AssertRegexMatch(t, BuildAPINewsletterSignup(), RegexNewsletterSignup, nil) + AssertRegexMatch(t, BuildAPINewsletterSignup(), RegexAPINewsletterSignup, nil) AssertSubdomain(t, BuildAPINewsletterSignup(), "") } diff --git a/src/hmnurl/urls.go b/src/hmnurl/urls.go index eba526ea..158dd813 100644 --- a/src/hmnurl/urls.go +++ b/src/hmnurl/urls.go @@ -28,13 +28,6 @@ func (c *UrlContext) BuildHomepage() string { return c.Url("/", nil) } -var RegexShowcase = regexp.MustCompile("^/showcase$") - -func BuildShowcase() string { - defer CatchPanic() - return Url("/showcase", nil) -} - var RegexWhenIsIt = regexp.MustCompile("^/whenisit$") func BuildWhenIsIt() string { diff --git a/src/templates/src/include/showcase_templates.html b/src/templates/src/include/showcase_templates.html deleted file mode 100644 index 1b438bcd..00000000 --- a/src/templates/src/include/showcase_templates.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - diff --git a/src/templates/src/landing.html b/src/templates/src/landing.html index abe53983..b28977b8 100644 --- a/src/templates/src/landing.html +++ b/src/templates/src/landing.html @@ -1,423 +1,13 @@ -{{ template "base.html" . }} +{{ template "base-2024.html" . }} {{ define "extrahead" }} - {{ end }} {{ define "content" }} -{{/* -
- - -
-

Handmade Seattle

-
November 16 - 18. In person and online.
-
-
-
- {{ if gt .HMSDaysUntilEnd 0 }} - {{ if eq .HMSDaysUntilStart 0 }} - Watch live - {{ else }} - Get tickets - {{ end }} - {{ else }} - Catch up - {{ end }} -
{{ svg "chevron-right" }}
-
-
-
-*/}} - -
- - -
-

Handmade cities

-
- Boston - Aug 9-10 2024. - {{ if gt .HMBostonDaysUntilEnd 0 }} - {{ if eq .HMBostonDaysUntilStart 0 }} - Happening now. - {{ else if eq .HMBostonDaysUntilStart 1 }} - Starting tomorrow. - {{ else if lt .HMBostonDaysUntilStart 31 }} - In {{ .HMBostonDaysUntilStart }} days. - {{ end }} - {{ end }} -
-
- Seattle - Nov 20-22 2024. - {{ if gt .HMSDaysUntilEnd 0 }} - {{ if eq .HMSDaysUntilStart 0 }} - Happening now. - {{ else if eq .HMSDaysUntilStart 1 }} - Starting tomorrow. - {{ else if lt .HMSDaysUntilStart 31 }} - In {{ .HMSDaysUntilStart }} days. - {{ end }} - {{ end }} -
- -
-
-
- Tickets available now -
{{ svg "chevron-right" }}
-
-
-
- -
- - - -
-

Learning Jam

-
-
-
- March 15-17. March 22-24. -
-
- {{ if gt .JamDaysUntilEnd 0 }} - {{ if eq .JamDaysUntilStart 0 }} - Happening now. - {{ else if eq .JamDaysUntilStart 1 }} - Starting tomorrow. - {{ else }} - In {{ .JamDaysUntilStart }} days. - {{ end }} - {{ else }} - See the results. - {{ end }} -
-
-
-
- March 15-17. -
-
- March 22-24. - {{ if gt .JamDaysUntilEnd 0 }} - {{ if eq .JamDaysUntilStart 0 }} - Happening now. - {{ else if eq .JamDaysUntilStart 1 }} - Starting tomorrow. - {{ else }} - In {{ .JamDaysUntilStart }} days. - {{ end }} - {{ else }} - See the results. - {{ end }} -
-
-
-
-
-
- Learn more -
{{ svg "chevron-right" }}
-
-
-
- -{{/* -
- - - -
-

Wheel Reinvention Jam

-
- September 25 - October 1. - {{ if gt .JamDaysUntilEnd 0 }} - {{ if eq .JamDaysUntilStart 0 }} - Happening now. - {{ else if eq .JamDaysUntilStart 1 }} - Starting tomorrow. - {{ else }} - In {{ .JamDaysUntilStart }} days. - {{ end }} - {{ else }} - See the results. - {{ end }} -
-
-
-
- Learn more -
{{ svg "chevron-right" }}
-
-
-
-*/}} - {{ if not .User }} + {{ end }} -
- {{/* - The order of the grid children should be as desired on mobile, then adapted to larger - sizes using CSS grid properties. - */}} +wowoaohaoh - {{ with .NewsPost }} -
-

Latest News

- {{ template "timeline_item.html" . }} -
- {{ end }} -
-

Around the Network

-
-
- 4 RSS Feed - {{ if .User }} -
- {{ csrftoken .Session }} - -
- {{ end }} -
-
- {{ template "pagination.html" .Pagination }} -
-
- {{ range .TimelineItems }} - {{ template "timeline_item.html" . }} - {{ end }} -
-
-
- {{ template "pagination.html" .Pagination }} -
-
-
- {{ if .ShowcaseTimelineJson }} -
- {{ template "showcase_templates.html" }} -
-

Community Showcase

-
-
- This is a selection of recent work done by community members. Want to participate? Join us on Discord. -
-
-
- View all ยป -
-
-
- -
- {{ end }} -
{{ end }} diff --git a/src/website/feed.go b/src/website/feed.go index 7e9ed3ad..07186554 100644 --- a/src/website/feed.go +++ b/src/website/feed.go @@ -180,30 +180,6 @@ func AtomFeed(c *RequestContext) ResponseData { updated = feedData.Projects[0].DateApproved } feedData.Updated = updated - case "showcase": - feedData.Title = "Showcase | Site-wide | Handmade Network" - feedData.Subtitle = feedData.Title - feedData.FeedType = FeedTypeShowcase - feedData.FeedID = FeedIDShowcase - feedData.AtomFeedUrl = hmnurl.BuildAtomFeedForShowcase() - feedData.FeedUrl = hmnurl.BuildShowcase() - - snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{ - Limit: itemsPerFeed, - }) - if err != nil { - return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets")) - } - for _, s := range snippets { - timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false) - feedData.Snippets = append(feedData.Snippets, timelineItem) - } - c.Perf.EndBlock() - updated := time.Now() - if len(feedData.Snippets) > 0 { - updated = feedData.Snippets[0].Date - } - feedData.Updated = updated default: return FourOhFour(c) } diff --git a/src/website/landing.go b/src/website/landing.go index 391fe204..bcd273b3 100644 --- a/src/website/landing.go +++ b/src/website/landing.go @@ -2,7 +2,6 @@ package website import ( "html/template" - "math" "net/http" "git.handmade.network/hmn/hmn/src/hmndata" @@ -10,21 +9,19 @@ import ( "git.handmade.network/hmn/hmn/src/models" "git.handmade.network/hmn/hmn/src/oops" "git.handmade.network/hmn/hmn/src/templates" - "git.handmade.network/hmn/hmn/src/utils" ) type LandingTemplateData struct { templates.BaseData - NewsPost *templates.TimelineItem - TimelineItems []templates.TimelineItem - Pagination templates.Pagination - ShowcaseTimelineJson string + NewsPost *templates.TimelineItem + FollowingItems []templates.TimelineItem + FeaturedItems []templates.TimelineItem + RecentItems []templates.TimelineItem + NewsItems []templates.TimelineItem ManifestoUrl string - FeedUrl string PodcastUrl string - ShowcaseUrl string AtomFeedUrl string MarkAllReadUrl string @@ -43,30 +40,6 @@ func Index(c *RequestContext) ResponseData { var timelineItems []templates.TimelineItem - numPosts, err := hmndata.CountPosts(c, c.Conn, c.CurrentUser, hmndata.PostsQuery{ - ThreadTypes: feedThreadTypes, - }) - if err != nil { - return c.ErrorResponse(http.StatusInternalServerError, err) - } - - numPages := int(math.Ceil(float64(numPosts) / feedPostsPerPage)) - - page, numPages, ok := getPageInfo("1", numPosts, feedPostsPerPage) - if !ok { - return c.Redirect(hmnurl.BuildFeed(), http.StatusSeeOther) - } - - pagination := templates.Pagination{ - Current: page, - Total: numPages, - - FirstUrl: hmnurl.BuildFeed(), - LastUrl: hmnurl.BuildFeedWithPage(numPages), - NextUrl: hmnurl.BuildFeedWithPage(utils.IntClamp(1, page+1, numPages)), - PreviousUrl: hmnurl.BuildFeedWithPage(utils.IntClamp(1, page-1, numPages)), - } - // This is essentially an alternate for feed page 1. posts, err := hmndata.FetchPosts(c, c.Conn, c.CurrentUser, hmndata.PostsQuery{ ThreadTypes: feedThreadTypes, @@ -112,45 +85,21 @@ func Index(c *RequestContext) ResponseData { } c.Perf.EndBlock() - snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{ - Limit: 40, - }) - if err != nil { - return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets")) - } - showcaseItems := make([]templates.TimelineItem, 0, len(snippets)) - for _, s := range snippets { - timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false) - if timelineItem.CanShowcase { - showcaseItems = append(showcaseItems, timelineItem) - } - } - c.Perf.EndBlock() - - c.Perf.StartBlock("SHOWCASE", "Convert to json") - showcaseJson := templates.TimelineItemsToJSON(showcaseItems) - c.Perf.EndBlock() - baseData := getBaseData(c, "", nil) - baseData.BodyClasses = append(baseData.BodyClasses, "hmdev", "landing") // TODO: Is "hmdev" necessary any more? baseData.OpenGraphItems = append(baseData.OpenGraphItems, templates.OpenGraphItem{ Property: "og:description", - Value: "A community of programmers committed to producing quality software through deeper understanding.", + Value: "A community of low-level programmers with high-level goals, working to correct the course of the software industry.", }) var res ResponseData err = res.WriteTemplate("landing.html", LandingTemplateData{ BaseData: baseData, - NewsPost: newsPostItem, - TimelineItems: timelineItems, - Pagination: pagination, - ShowcaseTimelineJson: showcaseJson, + NewsPost: newsPostItem, + FollowingItems: timelineItems, ManifestoUrl: hmnurl.BuildManifesto(), - FeedUrl: hmnurl.BuildFeed(), PodcastUrl: hmnurl.BuildPodcast(), - ShowcaseUrl: hmnurl.BuildShowcase(), AtomFeedUrl: hmnurl.BuildAtomFeed(), MarkAllReadUrl: hmnurl.HMNProjectContext.BuildForumMarkRead(0), diff --git a/src/website/routes.go b/src/website/routes.go index f87bab6e..609088c7 100644 --- a/src/website/routes.go +++ b/src/website/routes.go @@ -160,9 +160,8 @@ func NewWebsiteRoutes(conn *pgxpool.Pool) http.Handler { hmnOnly.POST(hmnurl.RegexAdminSetUserOptions, adminsOnly(csrfMiddleware(UserProfileAdminSetOptions))) hmnOnly.POST(hmnurl.RegexAdminNukeUser, adminsOnly(csrfMiddleware(UserProfileAdminNuke))) - hmnOnly.GET(hmnurl.RegexFeed, Feed) + hmnOnly.GET(hmnurl.RegexFeed, Feed) // TODO: Remove / rework this page hmnOnly.GET(hmnurl.RegexAtomFeed, AtomFeed) - hmnOnly.GET(hmnurl.RegexShowcase, Showcase) hmnOnly.GET(hmnurl.RegexSnippet, Snippet) hmnOnly.GET(hmnurl.RegexProjectIndex, ProjectIndex) diff --git a/src/website/showcase.go b/src/website/showcase.go deleted file mode 100644 index ffd399eb..00000000 --- a/src/website/showcase.go +++ /dev/null @@ -1,45 +0,0 @@ -package website - -import ( - "net/http" - - "git.handmade.network/hmn/hmn/src/hmndata" - "git.handmade.network/hmn/hmn/src/hmnurl" - "git.handmade.network/hmn/hmn/src/oops" - "git.handmade.network/hmn/hmn/src/templates" -) - -type ShowcaseData struct { - templates.BaseData - ShowcaseItems string // NOTE(asaf): JSON string - ShowcaseAtomFeedUrl string -} - -func Showcase(c *RequestContext) ResponseData { - snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{}) - if err != nil { - return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets")) - } - - showcaseItems := make([]templates.TimelineItem, 0, len(snippets)) - for _, s := range snippets { - timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false) - if timelineItem.CanShowcase { - showcaseItems = append(showcaseItems, timelineItem) - } - } - c.Perf.EndBlock() - - c.Perf.StartBlock("SHOWCASE", "Convert to json") - jsonItems := templates.TimelineItemsToJSON(showcaseItems) - c.Perf.EndBlock() - - baseData := getBaseDataAutocrumb(c, "Community Showcase") - var res ResponseData - res.MustWriteTemplate("showcase.html", ShowcaseData{ - BaseData: baseData, - ShowcaseItems: jsonItems, - ShowcaseAtomFeedUrl: hmnurl.BuildAtomFeedForShowcase(), - }, c.Perf) - return res -} diff --git a/src/website/user.go b/src/website/user.go index 57142e0b..fc511b31 100644 --- a/src/website/user.go +++ b/src/website/user.go @@ -189,7 +189,6 @@ func UserProfile(c *RequestContext) ResponseData { ProfileUserProjects: templateProjects, TimelineItems: timelineItems, OwnProfile: (c.CurrentUser != nil && c.CurrentUser.ID == profileUser.ID), - ShowcaseUrl: hmnurl.BuildShowcase(), CanAddProject: numPersonalProjects < maxPersonalProjects, NewProjectUrl: hmnurl.BuildProjectNew(),