Remove showcase, obliterate landing stuff

This commit is contained in:
Ben Visness 2024-06-17 20:37:58 -05:00
parent 8cd968a495
commit 3ff6ba6563
9 changed files with 14 additions and 664 deletions

View File

@ -40,10 +40,6 @@ func TestHomepage(t *testing.T) {
AssertSubdomain(t, hero.BuildHomepage(), "hero") AssertSubdomain(t, hero.BuildHomepage(), "hero")
} }
func TestShowcase(t *testing.T) {
AssertRegexMatch(t, BuildShowcase(), RegexShowcase, nil)
}
func TestWhenIsIt(t *testing.T) { func TestWhenIsIt(t *testing.T) {
AssertRegexMatch(t, BuildWhenIsIt(), RegexWhenIsIt, nil) AssertRegexMatch(t, BuildWhenIsIt(), RegexWhenIsIt, nil)
} }
@ -96,8 +92,6 @@ func TestStaticPages(t *testing.T) {
AssertRegexMatch(t, BuildManifesto(), RegexManifesto, nil) AssertRegexMatch(t, BuildManifesto(), RegexManifesto, nil)
AssertRegexMatch(t, BuildAbout(), RegexAbout, nil) AssertRegexMatch(t, BuildAbout(), RegexAbout, nil)
AssertRegexMatch(t, BuildFoundation(), RegexFoundation, nil) AssertRegexMatch(t, BuildFoundation(), RegexFoundation, nil)
AssertRegexMatch(t, BuildStaffRole("test"), RegexStaffRole, nil)
AssertRegexMatch(t, BuildStaffRolesIndex(), RegexStaffRolesIndex, nil)
AssertRegexMatch(t, BuildCommunicationGuidelines(), RegexCommunicationGuidelines, nil) AssertRegexMatch(t, BuildCommunicationGuidelines(), RegexCommunicationGuidelines, nil)
AssertRegexMatch(t, BuildContactPage(), RegexContactPage, nil) AssertRegexMatch(t, BuildContactPage(), RegexContactPage, nil)
AssertRegexMatch(t, BuildMonthlyUpdatePolicy(), RegexMonthlyUpdatePolicy, nil) AssertRegexMatch(t, BuildMonthlyUpdatePolicy(), RegexMonthlyUpdatePolicy, nil)
@ -459,7 +453,7 @@ func TestTimeMachineFormDone(t *testing.T) {
} }
func TestNewsletterSignup(t *testing.T) { func TestNewsletterSignup(t *testing.T) {
AssertRegexMatch(t, BuildAPINewsletterSignup(), RegexNewsletterSignup, nil) AssertRegexMatch(t, BuildAPINewsletterSignup(), RegexAPINewsletterSignup, nil)
AssertSubdomain(t, BuildAPINewsletterSignup(), "") AssertSubdomain(t, BuildAPINewsletterSignup(), "")
} }

View File

@ -28,13 +28,6 @@ func (c *UrlContext) BuildHomepage() string {
return c.Url("/", nil) return c.Url("/", nil)
} }
var RegexShowcase = regexp.MustCompile("^/showcase$")
func BuildShowcase() string {
defer CatchPanic()
return Url("/showcase", nil)
}
var RegexWhenIsIt = regexp.MustCompile("^/whenisit$") var RegexWhenIsIt = regexp.MustCompile("^/whenisit$")
func BuildWhenIsIt() string { func BuildWhenIsIt() string {

View File

@ -1,48 +0,0 @@
<script src="{{ static "js/showcase.js" }}"></script>
<template id="showcase_item">
<div data-tmpl="container" class="showcase-item ba b--theme flex-shrink-0 bg-dark-gray hide-child relative overflow-hidden pointer">
<div data-tmpl="thumbnail" class="absolute absolute--fill z-0 flex justify-start items-center bg-left cover"></div>
<div class="overlay absolute absolute--fill z-1 child">
<div class="gradient relative">
<div class="user-info flex pa2 white f7 lh-title items-center">
<div data-tmpl="avatar" class="br-100 w2 h2 cover flex-shrink-0"></div>
<div class="flex-grow-1 flex flex-column pl1">
<div data-tmpl="username">Unknown User</div>
<div data-tmpl="when" class="i f8">Unknown Time</div>
</div>
</div>
</div>
</div>
</div>
</template>
<template id="timeline_modal">
<div data-tmpl="overlay" class="timeline-modal fixed absolute--fill bg-black-80 z-999 flex flex-column justify-center items-center">
<div data-tmpl="container" class="container timeline-item relative flex-shrink-0 shadow-1 flex flex-column items-stretch w-100 mh0 mh3-ns br2-ns overflow-hidden">
<div data-tmpl="asset_container" class="bg-dark-gray flex justify-center"></div>
<div class="bg--content pa3 overflow-y-auto">
<div class="timeline-user-info mb2 flex items-center">
<img class="avatar lite mr2" data-tmpl="avatar"/>
<a class="user" data-tmpl="userLink"></a>
<a data-tmpl="date" class="datetime tr" style="flex: 1 1 auto;"></a>
</div>
<div class="overflow-auto" data-tmpl="description">
Unknown description
</div>
<div data-tmpl="projects" class="pt2 flex g2"></div>
<div class="i f7 pt2">
<a data-tmpl="discord_link" target="_blank">View original message on Discord</a>
</div>
</div>
<div data-tmpl="close" class="absolute right-0 top-0 w2 h2 flex justify-center items-center bg-black-80 white br-100 ma1 pointer svgicon svgicon-nofix">{{ svg "close" }}</div>
</div>
</div>
</template>
<template id="project_link">
<a data-tmpl="root" class="snippet-project flex flex-row items-center bg-theme-dimmer ph2 pv1 br2">
<img data-tmpl="logo" class="db mr1 br1 h1-5" />
<div data-tmpl="name"></div>
</a>
</template>

View File

@ -1,423 +1,13 @@
{{ template "base.html" . }} {{ template "base-2024.html" . }}
{{ define "extrahead" }} {{ define "extrahead" }}
<script src="{{ static "js/templates.js" }}"></script> <script src="{{ static "js/templates.js" }}"></script>
<style>
.landing-layout {
display: grid;
gap: var(--spacing-medium);
}
.landing-layout > * {
overflow: hidden;
}
@media screen and (min-width: 60em) {
.landing-layout {
grid-template-columns: 1fr;
grid-auto-columns: 1fr;
}
.landing-layout > * {
grid-column: 1 / 2;
}
.landing-layout > .landing-right {
grid-column: 2 / 3;
grid-row: 1 / 20; /* increase this number if somehow you ever add that much garbage to the home page :) */
}
}
</style>
{{ end }} {{ end }}
{{ define "content" }} {{ define "content" }}
{{/*
<div class="mb3 ph3 ph0-ns">
<style>
#hms-banner {
height: 10rem;
background-color: #0b0243;
color: white !important;
text-align: center;
position: relative;
overflow: hidden;
}
#hms-banner::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('{{ static "hms/banner.jpg" }}');
background-size: auto 100%;
z-index: 0;
opacity: 0.4;
}
#hms-banner h3 {
font-family: 'MohaveHMN', sans-serif;
font-weight: normal;
font-size: 2.6rem;
line-height: 0.8;
margin: 0;
text-transform: uppercase;
}
#hms-details {
font-family: 'MohaveHMN', sans-serif;
font-variant: small-caps;
font-size: 1.3rem;
line-height: 0.8;
margin-top: 0.6rem;
letter-spacing: 0.02rem;
}
#hms-learn-more {
font-size: 1rem;
}
@media screen and (min-width: 30rem) {
#hms-banner {
height: 12rem;
text-align: left;
color: #0b0243 !important;
}
#hms-banner::before {
opacity: 1;
}
#hms-title-container {
padding-left: 13.4rem;
}
}
@media screen and (min-width: 60em) {
#hms-banner {
height: 15rem;
text-align: left;
color: #0b0243 !important;
}
#hms-title-container {
padding-left: 16rem;
}
#hms-banner h3 {
font-size: 3rem;
}
#hms-details {
font-size: 1.5rem;
}
}
</style>
<a id="hms-banner" class="pv3 ph3 ph4-l br3 flex flex-column flex-row-ns items-center" href="https://guide.handmade-seattle.com/c/2022/" target="_blank">
<div id="hms-title-container" class="flex flex-column pl3-m pl4-l pv3 pv0-ns z-1">
<h3 id="hms-title">Handmade Seattle</h3>
<div id="hms-details">November 16 - 18. In person and online.</div>
</div>
<div class="flex-grow-1"></div>
<div id="hms-learn-more" class="z-1">
{{ if gt .HMSDaysUntilEnd 0 }}
{{ if eq .HMSDaysUntilStart 0 }}
Watch live
{{ else }}
Get tickets
{{ end }}
{{ else }}
Catch up
{{ end }}
<div class="dib svgicon">{{ svg "chevron-right" }}</div>
</div>
</a>
</div>
*/}}
<div class="mb3 ph3 ph0-ns">
<style>
#cities-banner {
background: url("{{ static "cities/banner.png" }}");
background-repeat: no-repeat;
color: white !important;
text-align: center;
background-size: contain;
background-position: bottom;
background-color: black;
}
#cities-banner h3 {
font-family: 'MohaveHMN', sans-serif;
font-weight: normal;
font-size: 2.2rem;
line-height: 0.8;
margin: 0;
text-transform: uppercase;
}
.cities-details {
font-family: 'MohaveHMN', sans-serif;
font-variant: small-caps;
font-size: 1.2rem;
line-height: 0.8;
margin-top: 0.6rem;
letter-spacing: 0.02rem;
}
#cities-learn-more {
font-size: 1rem;
}
#cities-title-container{
padding-left: 8.5rem;
}
@media screen and (min-width: 30rem) {
#cities-banner {
text-align: left;
}
#cities-title-container {
padding-top: 0.2rem;
}
}
@media screen and (max-width: 960px) {
#cities-title-container {
padding-left: 7.5rem;
}
#cities-banner{
background-size: 200%;
background-position: 0 100%;
}
}
@media screen and (max-width: 560px) {
#cities-banner {
text-align: left;
}
#cities-title-container {
padding-top: 0.2rem;
padding-left: 0;
text-align: center;
}
}
</style>
<a id="cities-banner" class="pv3 ph3 ph4-l br3 flex flex-column flex-row-ns items-center" href="https://handmadecities.com/tickets">
<div id="cities-title-container" class="flex flex-column pl3-m pl4-l pv3 pv0-ns">
<h3 id="cities-title">Handmade cities</h3>
<div class="cities-details">
Boston - Aug 9-10 2024.
{{ if gt .HMBostonDaysUntilEnd 0 }}
{{ if eq .HMBostonDaysUntilStart 0 }}
<b>Happening now.</b>
{{ else if eq .HMBostonDaysUntilStart 1 }}
<b>Starting tomorrow.</b>
{{ else if lt .HMBostonDaysUntilStart 31 }}
<b>In {{ .HMBostonDaysUntilStart }} days.</b>
{{ end }}
{{ end }}
</div>
<div class="cities-details">
Seattle - Nov 20-22 2024.
{{ if gt .HMSDaysUntilEnd 0 }}
{{ if eq .HMSDaysUntilStart 0 }}
<b>Happening now.</b>
{{ else if eq .HMSDaysUntilStart 1 }}
<b>Starting tomorrow.</b>
{{ else if lt .HMSDaysUntilStart 31 }}
<b>In {{ .HMSDaysUntilStart }} days.</b>
{{ end }}
{{ end }}
</div>
</div>
<div class="flex-grow-1"></div>
<div id="cities-learn-more">
Tickets available now
<div class="dib svgicon">{{ svg "chevron-right" }}</div>
</div>
</a>
</div>
<div class="mb3 ph3 ph0-ns">
<style>
#jam-banner {
background: linear-gradient(to bottom right, #003c83, #019AD2);
color: white !important;
text-align: center;
}
#jam-banner .jam-logo {
height: 7.25rem;
}
#jam-banner h3 {
font-family: 'Inter', sans-serif;
font-weight: 700;
font-size: 2.31rem;
/* line-height: 0.8; */
margin: 0;
}
#jam-title-container {
line-height: 1.25;
}
#jam-details {
font-family: 'Inter', sans-serif;
font-size: 1.2rem;
/* line-height: 0.8; */
margin-top: 0.2rem;
}
#jam-learn-more {
font-size: 1rem;
}
@media screen and (min-width: 30rem) {
#jam-banner {
text-align: left;
}
#jam-banner h3 {
font-size: 2.2rem;
}
#jam-banner .jam-logo {
height: 5.25rem;
}
}
</style>
<a id="jam-banner" class="pv3 ph3 ph4-l br3 flex flex-column flex-row-ns items-center" href="{{ .JamUrl }}">
<img class="jam-logo" src="{{ static "learningjam2024/logo.svg" }}">
<div id="jam-title-container" class="flex flex-column pl3-m pl4-l pv3 pv0-ns">
<h3 id="jam-title">Learning Jam</h3>
<div id="jam-details">
<div class="db dn-ns">
<div>
March 15-17. March 22-24.
</div>
<div>
{{ if gt .JamDaysUntilEnd 0 }}
{{ if eq .JamDaysUntilStart 0 }}
<b>Happening now.</b>
{{ else if eq .JamDaysUntilStart 1 }}
<b>Starting tomorrow.</b>
{{ else }}
<b>In {{ .JamDaysUntilStart }} days.</b>
{{ end }}
{{ else }}
<b>See the results.</b>
{{ end }}
</div>
</div>
<div class="dn db-ns">
<div>
March 15-17.
</div>
<div>
March 22-24.
{{ if gt .JamDaysUntilEnd 0 }}
{{ if eq .JamDaysUntilStart 0 }}
<b>Happening now.</b>
{{ else if eq .JamDaysUntilStart 1 }}
<b>Starting tomorrow.</b>
{{ else }}
<b>In {{ .JamDaysUntilStart }} days.</b>
{{ end }}
{{ else }}
<b>See the results.</b>
{{ end }}
</div>
</div>
</div>
</div>
<div class="flex-grow-1"></div>
<div id="jam-learn-more">
Learn more
<div class="dib svgicon">{{ svg "chevron-right" }}</div>
</div>
</a>
</div>
{{/*
<div class="mb3 ph3 ph0-ns">
<style>
#jam-banner {
background: linear-gradient(174deg, #23CE76, #299CE0);
color: white !important;
text-align: center;
}
#jam-banner h3 {
font-family: 'MohaveHMN', sans-serif;
font-weight: normal;
font-size: 2.2rem;
line-height: 0.8;
margin: 0;
text-transform: uppercase;
}
#jam-details {
font-family: 'MohaveHMN', sans-serif;
font-variant: small-caps;
font-size: 1.2rem;
line-height: 0.8;
margin-top: 0.6rem;
letter-spacing: 0.02rem;
}
#jam-learn-more {
font-size: 1rem;
}
@media screen and (min-width: 30rem) {
#jam-banner {
text-align: left;
}
#jam-title-container {
padding-top: 0.2rem;
}
}
</style>
<a id="jam-banner" class="pv3 ph3 ph4-l br3 flex flex-column flex-row-ns items-center" href="{{ .JamUrl }}">
<img class="h3" src="{{ static "wheeljam2023/logo.svg" }}">
<div id="jam-title-container" class="flex flex-column pl3-m pl4-l pv3 pv0-ns">
<h3 id="jam-title">Wheel Reinvention Jam</h3>
<div id="jam-details">
September 25 - October 1.
{{ if gt .JamDaysUntilEnd 0 }}
{{ if eq .JamDaysUntilStart 0 }}
<b>Happening now.</b>
{{ else if eq .JamDaysUntilStart 1 }}
<b>Starting tomorrow.</b>
{{ else }}
<b>In {{ .JamDaysUntilStart }} days.</b>
{{ end }}
{{ else }}
<b>See the results.</b>
{{ end }}
</div>
</div>
<div class="flex-grow-1"></div>
<div id="jam-learn-more">
Learn more
<div class="dib svgicon">{{ svg "chevron-right" }}</div>
</div>
</a>
</div>
*/}}
{{ if not .User }} {{ if not .User }}
<!--
<div class="mb3 ph3 ph0-ns"> <div class="mb3 ph3 ph0-ns">
<style> <style>
#welcome { #welcome {
@ -488,66 +78,9 @@
</div> </div>
</div> </div>
</div> </div>
-->
{{ end }} {{ end }}
<div class="landing-layout ph3 ph0-ns"> wowoaohaoh
{{/*
The order of the grid children should be as desired on mobile, then adapted to larger
sizes using CSS grid properties.
*/}}
{{ with .NewsPost }}
<div>
<h2>Latest News</h2>
{{ template "timeline_item.html" . }}
</div>
{{ end }}
<div class="landing-right">
<h2>Around the Network</h2>
<div class="optionbar mb2">
<div class="options">
<a class="button" href="{{ .AtomFeedUrl }}"><span class="icon big pr1">4</span> RSS Feed</a>
{{ if .User }}
<form method="POST" action="{{ .MarkAllReadUrl }}">
{{ csrftoken .Session }}
<button type="submit"><span class="big pr1">&#x2713;</span> Mark all posts on site as read</button>
</form>
{{ end }}
</div>
<div class="options">
{{ template "pagination.html" .Pagination }}
</div>
</div>
{{ range .TimelineItems }}
{{ template "timeline_item.html" . }}
{{ end }}
<div class="optionbar bottom mt2">
<div class="options"></div>
<div class="options">
{{ template "pagination.html" .Pagination }}
</div>
</div>
</div>
{{ if .ShowcaseTimelineJson }}
<div>
{{ template "showcase_templates.html" }}
<div>
<h2>Community Showcase</h2>
<div class="bg--card pa3 br3">
<div class="mb3">
This is a selection of recent work done by community members. Want to participate? <a href="https://discord.gg/hmn" target="_blank">Join us on Discord.</a>
</div>
<div id="showcase-container"></div>
<div>
<a class="db w-100 tc pa2" href="{{ .ShowcaseUrl }}">View all »</a>
</div>
</div>
</div>
<script>
const showcaseItems = JSON.parse("{{ .ShowcaseTimelineJson }}");
initShowcaseContainer(document.querySelector('#showcase-container'), showcaseItems, 200);
</script>
</div>
{{ end }}
</div>
{{ end }} {{ end }}

View File

@ -180,30 +180,6 @@ func AtomFeed(c *RequestContext) ResponseData {
updated = feedData.Projects[0].DateApproved updated = feedData.Projects[0].DateApproved
} }
feedData.Updated = updated 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: default:
return FourOhFour(c) return FourOhFour(c)
} }

View File

@ -2,7 +2,6 @@ package website
import ( import (
"html/template" "html/template"
"math"
"net/http" "net/http"
"git.handmade.network/hmn/hmn/src/hmndata" "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/models"
"git.handmade.network/hmn/hmn/src/oops" "git.handmade.network/hmn/hmn/src/oops"
"git.handmade.network/hmn/hmn/src/templates" "git.handmade.network/hmn/hmn/src/templates"
"git.handmade.network/hmn/hmn/src/utils"
) )
type LandingTemplateData struct { type LandingTemplateData struct {
templates.BaseData templates.BaseData
NewsPost *templates.TimelineItem NewsPost *templates.TimelineItem
TimelineItems []templates.TimelineItem FollowingItems []templates.TimelineItem
Pagination templates.Pagination FeaturedItems []templates.TimelineItem
ShowcaseTimelineJson string RecentItems []templates.TimelineItem
NewsItems []templates.TimelineItem
ManifestoUrl string ManifestoUrl string
FeedUrl string
PodcastUrl string PodcastUrl string
ShowcaseUrl string
AtomFeedUrl string AtomFeedUrl string
MarkAllReadUrl string MarkAllReadUrl string
@ -43,30 +40,6 @@ func Index(c *RequestContext) ResponseData {
var timelineItems []templates.TimelineItem 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. // This is essentially an alternate for feed page 1.
posts, err := hmndata.FetchPosts(c, c.Conn, c.CurrentUser, hmndata.PostsQuery{ posts, err := hmndata.FetchPosts(c, c.Conn, c.CurrentUser, hmndata.PostsQuery{
ThreadTypes: feedThreadTypes, ThreadTypes: feedThreadTypes,
@ -112,45 +85,21 @@ func Index(c *RequestContext) ResponseData {
} }
c.Perf.EndBlock() 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 := getBaseData(c, "", nil)
baseData.BodyClasses = append(baseData.BodyClasses, "hmdev", "landing") // TODO: Is "hmdev" necessary any more?
baseData.OpenGraphItems = append(baseData.OpenGraphItems, templates.OpenGraphItem{ baseData.OpenGraphItems = append(baseData.OpenGraphItems, templates.OpenGraphItem{
Property: "og:description", 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 var res ResponseData
err = res.WriteTemplate("landing.html", LandingTemplateData{ err = res.WriteTemplate("landing.html", LandingTemplateData{
BaseData: baseData, BaseData: baseData,
NewsPost: newsPostItem, NewsPost: newsPostItem,
TimelineItems: timelineItems, FollowingItems: timelineItems,
Pagination: pagination,
ShowcaseTimelineJson: showcaseJson,
ManifestoUrl: hmnurl.BuildManifesto(), ManifestoUrl: hmnurl.BuildManifesto(),
FeedUrl: hmnurl.BuildFeed(),
PodcastUrl: hmnurl.BuildPodcast(), PodcastUrl: hmnurl.BuildPodcast(),
ShowcaseUrl: hmnurl.BuildShowcase(),
AtomFeedUrl: hmnurl.BuildAtomFeed(), AtomFeedUrl: hmnurl.BuildAtomFeed(),
MarkAllReadUrl: hmnurl.HMNProjectContext.BuildForumMarkRead(0), MarkAllReadUrl: hmnurl.HMNProjectContext.BuildForumMarkRead(0),

View File

@ -160,9 +160,8 @@ func NewWebsiteRoutes(conn *pgxpool.Pool) http.Handler {
hmnOnly.POST(hmnurl.RegexAdminSetUserOptions, adminsOnly(csrfMiddleware(UserProfileAdminSetOptions))) hmnOnly.POST(hmnurl.RegexAdminSetUserOptions, adminsOnly(csrfMiddleware(UserProfileAdminSetOptions)))
hmnOnly.POST(hmnurl.RegexAdminNukeUser, adminsOnly(csrfMiddleware(UserProfileAdminNuke))) 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.RegexAtomFeed, AtomFeed)
hmnOnly.GET(hmnurl.RegexShowcase, Showcase)
hmnOnly.GET(hmnurl.RegexSnippet, Snippet) hmnOnly.GET(hmnurl.RegexSnippet, Snippet)
hmnOnly.GET(hmnurl.RegexProjectIndex, ProjectIndex) hmnOnly.GET(hmnurl.RegexProjectIndex, ProjectIndex)

View File

@ -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
}

View File

@ -189,7 +189,6 @@ func UserProfile(c *RequestContext) ResponseData {
ProfileUserProjects: templateProjects, ProfileUserProjects: templateProjects,
TimelineItems: timelineItems, TimelineItems: timelineItems,
OwnProfile: (c.CurrentUser != nil && c.CurrentUser.ID == profileUser.ID), OwnProfile: (c.CurrentUser != nil && c.CurrentUser.ID == profileUser.ID),
ShowcaseUrl: hmnurl.BuildShowcase(),
CanAddProject: numPersonalProjects < maxPersonalProjects, CanAddProject: numPersonalProjects < maxPersonalProjects,
NewProjectUrl: hmnurl.BuildProjectNew(), NewProjectUrl: hmnurl.BuildProjectNew(),