Enswankinate the project page completely
This commit is contained in:
parent
25cc5ef11b
commit
c6893f3f3f
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import boto3
|
||||
|
||||
# You must already have configured your "AWS" (DigitalOcean) credentials via the AWS CLI.
|
||||
|
|
|
@ -450,7 +450,7 @@ func BuildAtomFeedForShowcase() string {
|
|||
* Projects
|
||||
*/
|
||||
|
||||
var RegexProjectIndex = regexp.MustCompile(`^/projects(/(?P<category>[a-z][a-z0-9]+))?(/(?P<page>\d+))?$`)
|
||||
var RegexProjectIndex = regexp.MustCompile(`^/projects(/(?P<category>[a-z0-9-]+)(/(?P<page>\d+))?)?$`)
|
||||
|
||||
func BuildProjectIndex(page int, category string) string {
|
||||
defer CatchPanic()
|
||||
|
|
|
@ -32,10 +32,21 @@
|
|||
</div>
|
||||
{{ end }}
|
||||
<div class="flex flex-column g3">
|
||||
{{ if .CurrentJamProjects }}
|
||||
<div class="ph3 pt3 bg--dim br2 flex flex-column">
|
||||
<h2>{{ template "jam_name" .CurrentJamSlug }}</h2>
|
||||
<p>These projects are submissions to the {{ template "jam_name" .CurrentJamSlug }}, which is happening <b>right now!</b> <a href="{{ .CurrentJamLink }}">Learn more »</a>
|
||||
<div class="grid grid-1 grid-2-ns g3">
|
||||
{{ range .CurrentJamProjects }}
|
||||
{{ template "project_card.html" projectcarddata . "" }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<a href="{{ .CurrentJamProjectsLink }}" class="pa3 tc">See more »</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if .OfficialProjects }}
|
||||
<div class="ph3 pt3 bg--dim br2 flex flex-column">
|
||||
<h2>Official Projects</h2>
|
||||
<p>These projects are boop boop hahahaa:</p>
|
||||
<div class="grid grid-1 grid-2-ns g3">
|
||||
{{ range .OfficialProjects }}
|
||||
{{ template "project_card.html" projectcarddata . "" }}
|
||||
|
@ -47,7 +58,7 @@
|
|||
{{ if .PersonalProjects }}
|
||||
<div class="ph3 pt3 bg--dim br2 flex flex-column">
|
||||
<h2>Personal Projects</h2>
|
||||
<p>Many community members have projects of their own. Here's a few:</p>
|
||||
<p>Many community members have projects of their own. Want to join them? <a href="{{ .CreateProjectLink }}">Create your own.</a></p>
|
||||
<div class="grid grid-1 grid-2-ns g3">
|
||||
{{ range .PersonalProjects }}
|
||||
{{ template "project_card.html" projectcarddata . "" }}
|
||||
|
@ -56,28 +67,16 @@
|
|||
<a href="{{ .PersonalProjectsLink }}" class="pa3 tc">See more »</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if .CurrentJamProjects }}
|
||||
<div class="ph3 pt3 bg--dim br2 flex flex-column">
|
||||
<h2>JAM! NOWS!</h2>
|
||||
<p>wowowowow</p>
|
||||
<div class="grid grid-1 grid-2-ns g3">
|
||||
{{ range .CurrentJamProjects }}
|
||||
{{ template "project_card.html" projectcarddata . "" }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<a href="{{ .CurrentJamLink }}" class="pa3 tc">See more »</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if .PreviousJamProjects }}
|
||||
<div class="ph3 pt3 bg--dim br2 flex flex-column">
|
||||
<h2>JAM! THENS!</h2>
|
||||
<p>nonononoono</p>
|
||||
<h2>{{ template "jam_name" .PreviousJamSlug }}</h2>
|
||||
<p>The following projects were submissions to our most recent jam. <a href="{{ .PreviousJamLink }}">Learn more »</a></p>
|
||||
<div class="grid grid-1 grid-2-ns g3">
|
||||
{{ range .PreviousJamProjects }}
|
||||
{{ template "project_card.html" projectcarddata . "" }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<a href="{{ .PreviousJamLink }}" class="pa3 tc">See more »</a>
|
||||
<a href="{{ .PreviousJamProjectsLink }}" class="pa3 tc">See more »</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
@ -91,14 +90,25 @@
|
|||
{{ end }}
|
||||
|
||||
{{ define "single_category" }}
|
||||
{{ if eq .Category "official" }}
|
||||
<h2>Official Projects</h2>
|
||||
{{ else if eq .Category "personal" }}
|
||||
<h2>Personal Projects</h2>
|
||||
<p>Many community members have projects of their own. Want to join them? <a href="{{ .CreateProjectLink }}">Create your own.</a></p>
|
||||
{{ else }}
|
||||
{{/* Here we are assuming everything else is a jam. */}}
|
||||
<h2>{{ template "jam_name" .Category }}</h2>
|
||||
<p>The following projects were submissions to the {{ template "jam_name" .Category }}. <a href="{{ .PageJamLink }}">Learn more »</a></p>
|
||||
{{ end }}
|
||||
<div class="bg--dim-ns br2">
|
||||
<div class="clear"></div>
|
||||
<div class="optionbar pv2 ph3">
|
||||
<div class="options"></div>
|
||||
<div class="options">
|
||||
{{ template "pagination.html" .Pagination }}
|
||||
{{ if gt .Pagination.Total 1 }}
|
||||
<div class="optionbar pv2 ph3">
|
||||
<div class="options"></div>
|
||||
<div class="options">
|
||||
{{ template "pagination.html" .Pagination }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="projectlist pa3 grid grid-1 grid-2-ns g3">
|
||||
{{ range .PageProjects }}
|
||||
|
@ -106,13 +116,27 @@
|
|||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="optionbar bottom pv2 ph3">
|
||||
<div class="options order-1"></div>
|
||||
<div class="options order-0 order-last-ns">{{ template "pagination.html" .Pagination }}</div>
|
||||
</div>
|
||||
{{ if gt .Pagination.Total 1 }}
|
||||
<div class="optionbar bottom pv2 ph3">
|
||||
<div class="options order-1"></div>
|
||||
<div class="options order-0 order-last-ns">{{ template "pagination.html" .Pagination }}</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ define "jam_name" }}
|
||||
{{- if eq . "2022" -}}
|
||||
2022 Wheel Reinvention Jam
|
||||
{{- else if eq . "2023" -}}
|
||||
2023 Wheel Reinvention Jam
|
||||
{{- else if eq . "visibility-2023" -}}
|
||||
2023 Visibility Jam
|
||||
{{- else -}}
|
||||
???
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
{{ if .AllProjects }}
|
||||
{{ template "all_projects" . }}
|
||||
|
|
|
@ -77,18 +77,27 @@ type ProjectTemplateData struct {
|
|||
AllProjects bool
|
||||
|
||||
// Stuff for all projects
|
||||
OfficialProjects []templates.Project
|
||||
OfficialProjectsLink string
|
||||
PersonalProjects []templates.Project
|
||||
PersonalProjectsLink string
|
||||
CurrentJamProjects []templates.Project
|
||||
CurrentJamLink string
|
||||
PreviousJamProjects []templates.Project
|
||||
PreviousJamLink string
|
||||
OfficialProjects []templates.Project
|
||||
OfficialProjectsLink string
|
||||
PersonalProjects []templates.Project
|
||||
PersonalProjectsLink string
|
||||
CurrentJamProjects []templates.Project
|
||||
CurrentJamProjectsLink string
|
||||
CurrentJamLink string
|
||||
CurrentJamSlug string
|
||||
PreviousJamProjects []templates.Project
|
||||
PreviousJamProjectsLink string
|
||||
PreviousJamLink string
|
||||
PreviousJamSlug string
|
||||
|
||||
// Stuff for pages of projects only
|
||||
Category string
|
||||
Pagination templates.Pagination
|
||||
PageProjects []templates.Project
|
||||
PageJamLink string
|
||||
|
||||
// Stuff for both
|
||||
CreateProjectLink string
|
||||
}
|
||||
|
||||
func ProjectIndex(c *RequestContext) ResponseData {
|
||||
|
@ -135,14 +144,20 @@ func ProjectIndex(c *RequestContext) ResponseData {
|
|||
OfficialProjectsLink: hmnurl.BuildProjectIndex(1, "official"),
|
||||
PersonalProjects: personalProjects[:utils.IntMin(len(personalProjects), projectsPerSection)],
|
||||
PersonalProjectsLink: hmnurl.BuildProjectIndex(1, "personal"),
|
||||
CurrentJamProjects: currentJamProjects[:utils.IntMin(len(currentJamProjects), projectsPerSection)],
|
||||
// CurrentJamLink set later
|
||||
PreviousJamProjects: previousJamProjects[:utils.IntMin(len(previousJamProjects), projectsPerSection)],
|
||||
PreviousJamLink: hmnurl.BuildJamIndexAny(previousJam.UrlSlug),
|
||||
// Current jam stuff set later
|
||||
PreviousJamProjects: previousJamProjects[:utils.IntMin(len(previousJamProjects), projectsPerSection)],
|
||||
PreviousJamProjectsLink: hmnurl.BuildProjectIndex(1, previousJam.UrlSlug),
|
||||
PreviousJamLink: hmnurl.BuildJamIndexAny(previousJam.UrlSlug),
|
||||
PreviousJamSlug: previousJam.UrlSlug,
|
||||
|
||||
CreateProjectLink: hmnurl.BuildProjectNew(),
|
||||
}
|
||||
|
||||
if hmndata.CurrentJam() != nil {
|
||||
tmpl.CurrentJamLink = hmnurl.BuildJamIndexAny(hmndata.CurrentJam().UrlSlug)
|
||||
if currentJam != nil {
|
||||
tmpl.CurrentJamProjects = currentJamProjects[:utils.IntMin(len(currentJamProjects), projectsPerSection)]
|
||||
tmpl.CurrentJamProjectsLink = hmnurl.BuildProjectIndex(1, currentJam.UrlSlug)
|
||||
tmpl.CurrentJamLink = hmnurl.BuildJamIndexAny(currentJam.UrlSlug)
|
||||
tmpl.CurrentJamSlug = currentJam.UrlSlug
|
||||
}
|
||||
|
||||
var res ResponseData
|
||||
|
@ -151,19 +166,32 @@ func ProjectIndex(c *RequestContext) ResponseData {
|
|||
} else {
|
||||
const projectsPerPage = 20
|
||||
|
||||
var breadcrumb templates.Breadcrumb
|
||||
breadcrumbUrl := hmnurl.BuildProjectIndex(1, cat)
|
||||
|
||||
var projects []templates.Project
|
||||
var jamLink string
|
||||
|
||||
var err error
|
||||
switch cat {
|
||||
case hmndata.WRJ2022.UrlSlug:
|
||||
projects, err = getPersonalProjects(c, hmndata.WRJ2022.Slug)
|
||||
case hmndata.VJ2023.Slug:
|
||||
breadcrumb = templates.Breadcrumb{Name: "Wheel Reinvention Jam 2022"}
|
||||
jamLink = hmnurl.BuildJamIndex2022()
|
||||
case hmndata.VJ2023.UrlSlug:
|
||||
projects, err = getPersonalProjects(c, hmndata.VJ2023.Slug)
|
||||
case hmndata.WRJ2023.Slug:
|
||||
breadcrumb = templates.Breadcrumb{"2023 Visibility Jam", breadcrumbUrl}
|
||||
jamLink = hmnurl.BuildJamIndex2023_Visibility()
|
||||
case hmndata.WRJ2023.UrlSlug:
|
||||
projects, err = getPersonalProjects(c, hmndata.WRJ2023.Slug)
|
||||
breadcrumb = templates.Breadcrumb{"Wheel Reinvention Jam 2023", breadcrumbUrl}
|
||||
jamLink = hmnurl.BuildJamIndex2023()
|
||||
case "personal":
|
||||
projects, err = getPersonalProjects(c, "")
|
||||
breadcrumb = templates.Breadcrumb{"Personal Projects", breadcrumbUrl}
|
||||
case "official":
|
||||
projects, err = getShuffledOfficialProjects(c)
|
||||
breadcrumb = templates.Breadcrumb{"Official Projects", breadcrumbUrl}
|
||||
default:
|
||||
return c.Redirect(hmnurl.BuildProjectIndex(1, ""), http.StatusSeeOther)
|
||||
}
|
||||
|
@ -191,6 +219,7 @@ func ProjectIndex(c *RequestContext) ResponseData {
|
|||
|
||||
baseData := getBaseData(c, "Projects", []templates.Breadcrumb{
|
||||
{"Projects", hmnurl.BuildProjectIndex(1, "")},
|
||||
breadcrumb,
|
||||
})
|
||||
var res ResponseData
|
||||
res.MustWriteTemplate("project_index.html", ProjectTemplateData{
|
||||
|
@ -198,8 +227,11 @@ func ProjectIndex(c *RequestContext) ResponseData {
|
|||
|
||||
AllProjects: false,
|
||||
|
||||
Pagination: pagination,
|
||||
PageProjects: pageProjects,
|
||||
Category: cat,
|
||||
Pagination: pagination,
|
||||
PageProjects: pageProjects,
|
||||
CreateProjectLink: hmnurl.BuildProjectNew(),
|
||||
PageJamLink: jamLink,
|
||||
}, c.Perf)
|
||||
return res
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue