Compare commits

...

3 Commits

Author SHA1 Message Date
Asaf Gartner f085858e9e Merge remote-tracking branch 'origin/beta' 2024-03-11 20:17:44 +02:00
Asaf Gartner 639ea17a88 Timeline and projects for learning jam 2024-03-11 20:15:32 +02:00
Asaf Gartner 2eb3288b2a LJ jam feed basics 2024-03-11 18:27:34 +02:00
6 changed files with 213 additions and 89 deletions

View File

@ -103,6 +103,9 @@ func ProjectToTemplate(
func ProjectAndStuffToTemplate(p *hmndata.ProjectAndStuff, url string, theme string) Project {
res := ProjectToTemplate(&p.Project, url)
res.Logo = ProjectLogoUrl(&p.Project, p.LogoLightAsset, p.LogoDarkAsset, theme)
for _, o := range p.Owners {
res.Owners = append(res.Owners, UserToTemplate(o, theme))
}
return res
}

View File

@ -1,46 +1,85 @@
{{ template "jam_2024_learning_base.html" . }}
{{ define "content-top" }}
<div class="flex flex-column items-center pa3 g3">
<img class="mw5" src="{{ static "visjam2023/logo.svg" }}">
<div class="f1 fw7">The Learning Jam</div>
<div class="flex flex-row g5 lh-solid">
<div>
<div class="fw7 f3">Learn</div>
<div class="fw3 f4">March 15-17, 2024</div>
</div>
<div>
<div class="fw7 f3">Teach</div>
<div class="fw3 f4">March 22-24, 2024</div>
<div class="mw7 margin-center">
<div class="flex flex-column pv4 tc">
<img class="jam-logo margin-center" src="{{ static "learningjam2024/logo.svg" }}">
<div class="margin-center mt3 mt4-ns mb4">
<div class="jam-title mb3">Learning Jam</div>
<div class="flex flex-column flex-row-ns justify-between lh-solid g3 g0-ns">
<div>
<div class="fw7 f3 mb1">Learn</div>
<div class="fw3 f4">March 15-17, 2024</div>
</div>
<div>
<div class="fw7 f3 mb1">Share</div>
<div class="fw3 f4">March 22-24, 2024</div>
</div>
</div>
</div>
<div class="mt3">
<a href="{{ .DiscordInviteUrl }}" class="db ph2 pv1 button-simple">Join the Discord</a>
<div class="flex g3 justify-center link--white">
{{ if and (eq .DaysUntilStart 0) (gt .DaysUntilEnd 0) }}
{{ if .SubmittedProjectUrl }}
<a class="btn--jam" href="{{ .SubmittedProjectUrl }}">Share your progress</a>
{{ else }}
<a class="btn--jam" href="{{ .ProjectSubmissionUrl }}">Create your project</a>
{{ end }}
{{ end }}
<a href="{{ .DiscordInviteUrl }}" class="btn--jam">Join the Discord</a>
</div>
</div>
</div>
{{ end }}
{{ define "content" }}
<div class="flex flex-column g3 items-center pa3">
<div class="w6">
<div class="mw7 margin-center flex flex-column">
<div class="ph3 pv4 bb b--rich-gray">
<h2 class="c--theme-gradient-light">Projects</h2>
<div class="flex flex-row flex-wrap g2">
{{ if .Projects }}
{{ range .Projects }}
<div class="flex-basis-40-ns flex-grow-1 flex-shrink-1 bg--rich-gray pa3 flex flex-column g1">
<div class="f3">
<a href="{{ .Url }}" class="fw6">{{ .Name }}</a>
</div>
<div class="flex-grow-1">{{ .Blurb }}</div>
<div class="f7">
by
{{ $owners := .Owners }}
{{ range $idx, $owner := .Owners }}
<a href="{{ $owner.ProfileUrl }}" class="fw6 link--white">{{ $owner.Name }}</a>{{ if not (lastidx $idx (len $owners)) }},{{ end }}
{{ end }}
</div>
</div>
{{ end }}
{{ if isodd (len .Projects) }}
<div class="flex-basis-40-ns flex-grow-1 flex-shrink-1"></div>
{{ end }}
{{ end }}
</div>
</div>
<div class="ph3 pv4 bb b--rich-gray">
<h2 class="c--theme-gradient-light">Recent activity</h2>
<div class="flex flex-column g3">
<div class="flex flex-column g2">
{{ if .TimelineItems }}
{{ range .TimelineItems }}
<div class="flex flex-column g2 bg--rich-gray pa2">
<div class="flex flex-row g2">
<div class="flex flex-column g3 bg--rich-gray pa3">
<div class="flex flex-row g3 items-start">
{{ if .OwnerAvatarUrl }}
<a class="flex flex-shrink-0 br-100 square items-center justify-center overflow-hidden bg--gray" href="{{ .OwnerUrl }}">
<img class="w2" src="{{ .OwnerAvatarUrl }}" />
<img class="w2-5" src="{{ .OwnerAvatarUrl }}" />
</a>
{{ end }}
<div class="flex flex-column">
<div class="fw6">{{ .OwnerName }}</div>
<div class="f7">{{ timehtml (relativedate .Date) .Date }}</div>
<div class="">
<a title="{{ (index .Projects 0).Blurb }}" href="{{ (index .Projects 0).Url }}" class="link--white fw6">{{ (index .Projects 0).Name }}</a>
by
<a href="{{ .OwnerUrl }}" class="link--white fw6">{{ .OwnerName }}</a>
<span class="f7 c--gray nowrap">{{ timehtml (relativedate .Date) .Date }}</span>
</div>
<div>{{ trim .Description }}</div>
</div>
</div>
{{ if .Description }}
<div>{{ trim .Description }}</div>
{{ end }}
{{ range .EmbedMedia }}
<div class="flex flex-column {{ if eq .Type mediaembed }}wide-screen{{ end }} justify-stretch iframe-fill">
{{ if eq .Type mediaimage }}
@ -57,7 +96,7 @@
{{ .EmbedHTML }}
{{ else }}
<div class="">
<a href="{{ .AssetUrl }}" target="_blank">{{ .Filename }} ({{ filesize .FileSize }})</a>
<a href="{{ .AssetUrl }}" target="_blank">💾{{ .Filename }} ({{ filesize .FileSize }})</a>
</div>
{{ end }}
</div>
@ -69,6 +108,11 @@
{{ end }}
</div>
</div>
<div>
<div class="mv5 h3 fill-current link--white">
<a href="{{ .Header.HMNHomepageUrl }}">{{ svg "hmn_circuit" }}</a>
</div>
</div>
</div>
{{ end }}

View File

@ -1,35 +1,5 @@
{{ template "jam_2024_learning_base.html" . }}
{{ define "extrahead" }}
<style>
.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;
}
}
</style>
{{ end }}
{{ define "content-top" }}
<div class="mw7 margin-center">
<div class="flex flex-column pv4 tc">
@ -47,17 +17,19 @@
</div>
</div>
</div>
{{ if lt .DaysUntilStart 0 }}
<div class="flex flex-row g3 mt2">
{{ if .SubmittedProjectUrl }}
<a class="db ph3 pv2 f4 button-simple" href="{{ .SubmittedProjectUrl }}">Share your progress</a>
<div class="flex g3 justify-center link--white">
{{ if eq .DaysUntilStart 0 }}
{{ if gt .DaysUntilEnd 0 }}
{{ if .SubmittedProjectUrl }}
<a class="btn--jam" href="{{ .SubmittedProjectUrl }}">Share your progress</a>
{{ else }}
<a class="btn--jam" href="{{ .ProjectSubmissionUrl }}">Create your project</a>
{{ end }}
<a class="btn--jam" href="{{ .JamFeedUrl }}">Recent activity</a>
{{ else }}
<a class="db ph3 pv2 f4 button-simple" href="{{ .ProjectSubmissionUrl }}">Create your project</a>
<a class="btn--jam" href="{{ .JamFeedUrl }}">See the results</a>
{{ end }}
<a class="db ph3 pv2 f4 button-simple" href="{{ .JamFeedUrl }}">Recent activity</a>
</div>
{{ end }}
<div class="flex g3 justify-center">
{{ end }}
<a href="{{ .DiscordInviteUrl }}" class="btn--jam">Join the Discord</a>
</div>
</div>

View File

@ -54,6 +54,8 @@
--spacing-6: 8rem;
--spacing-7: 16rem;
--border-radius-2: 0.25rem;
--link-color: #8Bd5FF;
}
body {
@ -65,6 +67,14 @@
font-weight: 700;
}
.w2-5 {
width: 3rem;
}
.link--white {
--link-color: var(--white);
}
.post-content p {
/* stupid override, should be done by .post-content instead of .content */
margin: 0.6rem 0;
@ -90,6 +100,10 @@
background: var(--gray);
}
.b--charcoal {
border-color: var(--charcoal);
}
.b--rich-gray {
border-color: var(--rich-gray);
}
@ -108,6 +122,10 @@
color: transparent;
}
.c--gray {
color: var(--gray);
}
.btn--jam {
border: 1px solid var(--white);
border-radius: var(--border-radius-2);
@ -175,9 +193,37 @@
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) {
.flex-basis-40-ns {
flex-basis: 40%;
}
}
</style>
@ -186,7 +232,7 @@
<body class="bg--charcoal flex flex-column">
<div class="c-white bg--theme-gradient-dark">
<div class="bg-black-20 flex flex-row items-center">
<div class="bg-black-20 flex flex-row items-center link--white">
<a href="{{ .Header.HMNHomepageUrl }}" class="hmn-logo flex-shrink-0">
Handmade
</a>

View File

@ -287,6 +287,12 @@ var HMNTemplateFuncs = template.FuncMap{
"trim": func(str template.HTML) template.HTML {
return template.HTML(strings.TrimSpace(string(str)))
},
"lastidx": func(idx int, l int) bool {
return idx == l-1
},
"isodd": func(num int) bool {
return num%2 == 1
},
// NOTE(asaf): Template specific functions:
"projectcarddata": func(project Project, classes string) ProjectCardData {

View File

@ -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,51 @@ 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
Projects []templates.Project
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 +195,43 @@ func JamFeed2024_Learning(c *RequestContext) ResponseData {
}
}
type JamFeedData struct {
templates.BaseData
DaysUntilStart, DaysUntilEnd int
TimelineItems []templates.TimelineItem
projects := make([]templates.Project, 0, len(jamProjects))
for _, jp := range jamProjects {
urlContext := hmndata.UrlContextForProject(&jp.Project)
projectUrl := urlContext.BuildHomepage()
projects = append(projects, templates.ProjectAndStuffToTemplate(&jp, projectUrl, c.Theme))
}
daysUntilStart := daysUntil(hmndata.LJ2024.StartTime)
daysUntilEnd := daysUntil(hmndata.LJ2024.EndTime)
tmpl := JamFeedData{
BaseData: baseData,
UserAvatarUrl: templates.UserAvatarDefaultUrl("dark"),
DaysUntilStart: daysUntilStart,
DaysUntilEnd: daysUntilEnd,
TwitchEmbedUrl: twitchEmbedUrl,
ProjectSubmissionUrl: hmnurl.BuildProjectNewJam(),
SubmittedProjectUrl: "",
Projects: projects,
TimelineItems: timelineItems,
}
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
}