Enswankinate the project page completely

This commit is contained in:
Ben Visness 2023-09-25 10:02:34 -05:00
parent 25cc5ef11b
commit c6893f3f3f
4 changed files with 122 additions and 64 deletions

38
local/download_database.py Normal file → Executable file
View File

@ -1,18 +1,20 @@
import boto3 #!/usr/bin/env python3
# You must already have configured your "AWS" (DigitalOcean) credentials via the AWS CLI. import boto3
s3 = boto3.resource("s3") # You must already have configured your "AWS" (DigitalOcean) credentials via the AWS CLI.
bucket = s3.Bucket("hmn-backup")
for obj in bucket.objects.filter(Prefix="db"): s3 = boto3.resource("s3")
print(obj.key) bucket = s3.Bucket("hmn-backup")
for obj in bucket.objects.filter(Prefix="db"):
print() print(obj.key)
print("Above is a list of all the available database backups.")
print("Enter the name of the one you would like to download (e.g. \"hmn_pg_dump_live_2023-09-24\"):") print()
filename = input() print("Above is a list of all the available database backups.")
print("Enter the name of the one you would like to download (e.g. \"hmn_pg_dump_live_2023-09-24\"):")
s3 = boto3.client("s3") filename = input()
s3.download_file("hmn-backup", f"db/{filename}", f"local/backups/{filename}")
s3 = boto3.client("s3")
print(f"Downloaded {filename} to local/backups.") s3.download_file("hmn-backup", f"db/{filename}", f"local/backups/{filename}")
print(f"Downloaded {filename} to local/backups.")

View File

@ -450,7 +450,7 @@ func BuildAtomFeedForShowcase() string {
* Projects * 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 { func BuildProjectIndex(page int, category string) string {
defer CatchPanic() defer CatchPanic()

View File

@ -32,10 +32,21 @@
</div> </div>
{{ end }} {{ end }}
<div class="flex flex-column g3"> <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 }} {{ if .OfficialProjects }}
<div class="ph3 pt3 bg--dim br2 flex flex-column"> <div class="ph3 pt3 bg--dim br2 flex flex-column">
<h2>Official Projects</h2> <h2>Official Projects</h2>
<p>These projects are boop boop hahahaa:</p>
<div class="grid grid-1 grid-2-ns g3"> <div class="grid grid-1 grid-2-ns g3">
{{ range .OfficialProjects }} {{ range .OfficialProjects }}
{{ template "project_card.html" projectcarddata . "" }} {{ template "project_card.html" projectcarddata . "" }}
@ -47,7 +58,7 @@
{{ if .PersonalProjects }} {{ if .PersonalProjects }}
<div class="ph3 pt3 bg--dim br2 flex flex-column"> <div class="ph3 pt3 bg--dim br2 flex flex-column">
<h2>Personal Projects</h2> <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"> <div class="grid grid-1 grid-2-ns g3">
{{ range .PersonalProjects }} {{ range .PersonalProjects }}
{{ template "project_card.html" projectcarddata . "" }} {{ template "project_card.html" projectcarddata . "" }}
@ -56,28 +67,16 @@
<a href="{{ .PersonalProjectsLink }}" class="pa3 tc">See more »</a> <a href="{{ .PersonalProjectsLink }}" class="pa3 tc">See more »</a>
</div> </div>
{{ end }} {{ 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 }} {{ if .PreviousJamProjects }}
<div class="ph3 pt3 bg--dim br2 flex flex-column"> <div class="ph3 pt3 bg--dim br2 flex flex-column">
<h2>JAM! THENS!</h2> <h2>{{ template "jam_name" .PreviousJamSlug }}</h2>
<p>nonononoono</p> <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"> <div class="grid grid-1 grid-2-ns g3">
{{ range .PreviousJamProjects }} {{ range .PreviousJamProjects }}
{{ template "project_card.html" projectcarddata . "" }} {{ template "project_card.html" projectcarddata . "" }}
{{ end }} {{ end }}
</div> </div>
<a href="{{ .PreviousJamLink }}" class="pa3 tc">See more »</a> <a href="{{ .PreviousJamProjectsLink }}" class="pa3 tc">See more »</a>
</div> </div>
{{ end }} {{ end }}
</div> </div>
@ -91,14 +90,25 @@
{{ end }} {{ end }}
{{ define "single_category" }} {{ 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="bg--dim-ns br2">
<div class="clear"></div> {{ if gt .Pagination.Total 1 }}
<div class="optionbar pv2 ph3"> <div class="optionbar pv2 ph3">
<div class="options"></div> <div class="options"></div>
<div class="options"> <div class="options">
{{ template "pagination.html" .Pagination }} {{ template "pagination.html" .Pagination }}
</div>
</div> </div>
</div> {{ end }}
<div class="projectlist pa3 grid grid-1 grid-2-ns g3"> <div class="projectlist pa3 grid grid-1 grid-2-ns g3">
{{ range .PageProjects }} {{ range .PageProjects }}
@ -106,13 +116,27 @@
{{ end }} {{ end }}
</div> </div>
<div class="optionbar bottom pv2 ph3"> {{ if gt .Pagination.Total 1 }}
<div class="options order-1"></div> <div class="optionbar bottom pv2 ph3">
<div class="options order-0 order-last-ns">{{ template "pagination.html" .Pagination }}</div> <div class="options order-1"></div>
</div> <div class="options order-0 order-last-ns">{{ template "pagination.html" .Pagination }}</div>
</div>
{{ end }}
</div> </div>
{{ end }} {{ 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" }} {{ define "content" }}
{{ if .AllProjects }} {{ if .AllProjects }}
{{ template "all_projects" . }} {{ template "all_projects" . }}

View File

@ -77,18 +77,27 @@ type ProjectTemplateData struct {
AllProjects bool AllProjects bool
// Stuff for all projects // Stuff for all projects
OfficialProjects []templates.Project OfficialProjects []templates.Project
OfficialProjectsLink string OfficialProjectsLink string
PersonalProjects []templates.Project PersonalProjects []templates.Project
PersonalProjectsLink string PersonalProjectsLink string
CurrentJamProjects []templates.Project CurrentJamProjects []templates.Project
CurrentJamLink string CurrentJamProjectsLink string
PreviousJamProjects []templates.Project CurrentJamLink string
PreviousJamLink string CurrentJamSlug string
PreviousJamProjects []templates.Project
PreviousJamProjectsLink string
PreviousJamLink string
PreviousJamSlug string
// Stuff for pages of projects only // Stuff for pages of projects only
Category string
Pagination templates.Pagination Pagination templates.Pagination
PageProjects []templates.Project PageProjects []templates.Project
PageJamLink string
// Stuff for both
CreateProjectLink string
} }
func ProjectIndex(c *RequestContext) ResponseData { func ProjectIndex(c *RequestContext) ResponseData {
@ -135,14 +144,20 @@ func ProjectIndex(c *RequestContext) ResponseData {
OfficialProjectsLink: hmnurl.BuildProjectIndex(1, "official"), OfficialProjectsLink: hmnurl.BuildProjectIndex(1, "official"),
PersonalProjects: personalProjects[:utils.IntMin(len(personalProjects), projectsPerSection)], PersonalProjects: personalProjects[:utils.IntMin(len(personalProjects), projectsPerSection)],
PersonalProjectsLink: hmnurl.BuildProjectIndex(1, "personal"), PersonalProjectsLink: hmnurl.BuildProjectIndex(1, "personal"),
CurrentJamProjects: currentJamProjects[:utils.IntMin(len(currentJamProjects), projectsPerSection)], // Current jam stuff set later
// CurrentJamLink set later PreviousJamProjects: previousJamProjects[:utils.IntMin(len(previousJamProjects), projectsPerSection)],
PreviousJamProjects: previousJamProjects[:utils.IntMin(len(previousJamProjects), projectsPerSection)], PreviousJamProjectsLink: hmnurl.BuildProjectIndex(1, previousJam.UrlSlug),
PreviousJamLink: hmnurl.BuildJamIndexAny(previousJam.UrlSlug), PreviousJamLink: hmnurl.BuildJamIndexAny(previousJam.UrlSlug),
PreviousJamSlug: previousJam.UrlSlug,
CreateProjectLink: hmnurl.BuildProjectNew(),
} }
if hmndata.CurrentJam() != nil { if currentJam != nil {
tmpl.CurrentJamLink = hmnurl.BuildJamIndexAny(hmndata.CurrentJam().UrlSlug) 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 var res ResponseData
@ -151,19 +166,32 @@ func ProjectIndex(c *RequestContext) ResponseData {
} else { } else {
const projectsPerPage = 20 const projectsPerPage = 20
var breadcrumb templates.Breadcrumb
breadcrumbUrl := hmnurl.BuildProjectIndex(1, cat)
var projects []templates.Project var projects []templates.Project
var jamLink string
var err error var err error
switch cat { switch cat {
case hmndata.WRJ2022.UrlSlug: case hmndata.WRJ2022.UrlSlug:
projects, err = getPersonalProjects(c, hmndata.WRJ2022.Slug) 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) 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) projects, err = getPersonalProjects(c, hmndata.WRJ2023.Slug)
breadcrumb = templates.Breadcrumb{"Wheel Reinvention Jam 2023", breadcrumbUrl}
jamLink = hmnurl.BuildJamIndex2023()
case "personal": case "personal":
projects, err = getPersonalProjects(c, "") projects, err = getPersonalProjects(c, "")
breadcrumb = templates.Breadcrumb{"Personal Projects", breadcrumbUrl}
case "official": case "official":
projects, err = getShuffledOfficialProjects(c) projects, err = getShuffledOfficialProjects(c)
breadcrumb = templates.Breadcrumb{"Official Projects", breadcrumbUrl}
default: default:
return c.Redirect(hmnurl.BuildProjectIndex(1, ""), http.StatusSeeOther) return c.Redirect(hmnurl.BuildProjectIndex(1, ""), http.StatusSeeOther)
} }
@ -191,6 +219,7 @@ func ProjectIndex(c *RequestContext) ResponseData {
baseData := getBaseData(c, "Projects", []templates.Breadcrumb{ baseData := getBaseData(c, "Projects", []templates.Breadcrumb{
{"Projects", hmnurl.BuildProjectIndex(1, "")}, {"Projects", hmnurl.BuildProjectIndex(1, "")},
breadcrumb,
}) })
var res ResponseData var res ResponseData
res.MustWriteTemplate("project_index.html", ProjectTemplateData{ res.MustWriteTemplate("project_index.html", ProjectTemplateData{
@ -198,8 +227,11 @@ func ProjectIndex(c *RequestContext) ResponseData {
AllProjects: false, AllProjects: false,
Pagination: pagination, Category: cat,
PageProjects: pageProjects, Pagination: pagination,
PageProjects: pageProjects,
CreateProjectLink: hmnurl.BuildProjectNew(),
PageJamLink: jamLink,
}, c.Perf) }, c.Perf)
return res return res
} }