diff --git a/local/download_database.py b/local/download_database.py old mode 100644 new mode 100755 index a447f2d..be872d8 --- a/local/download_database.py +++ b/local/download_database.py @@ -1,18 +1,20 @@ -import boto3 - -# You must already have configured your "AWS" (DigitalOcean) credentials via the AWS CLI. - -s3 = boto3.resource("s3") -bucket = s3.Bucket("hmn-backup") -for obj in bucket.objects.filter(Prefix="db"): - print(obj.key) - -print() -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\"):") -filename = input() - -s3 = boto3.client("s3") -s3.download_file("hmn-backup", f"db/{filename}", f"local/backups/{filename}") - -print(f"Downloaded {filename} to local/backups.") +#!/usr/bin/env python3 + +import boto3 + +# You must already have configured your "AWS" (DigitalOcean) credentials via the AWS CLI. + +s3 = boto3.resource("s3") +bucket = s3.Bucket("hmn-backup") +for obj in bucket.objects.filter(Prefix="db"): + print(obj.key) + +print() +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\"):") +filename = input() + +s3 = boto3.client("s3") +s3.download_file("hmn-backup", f"db/{filename}", f"local/backups/{filename}") + +print(f"Downloaded {filename} to local/backups.") diff --git a/src/hmnurl/urls.go b/src/hmnurl/urls.go index 0c143db..55d20bd 100644 --- a/src/hmnurl/urls.go +++ b/src/hmnurl/urls.go @@ -450,7 +450,7 @@ func BuildAtomFeedForShowcase() string { * Projects */ -var RegexProjectIndex = regexp.MustCompile(`^/projects(/(?P[a-z][a-z0-9]+))?(/(?P\d+))?$`) +var RegexProjectIndex = regexp.MustCompile(`^/projects(/(?P[a-z0-9-]+)(/(?P\d+))?)?$`) func BuildProjectIndex(page int, category string) string { defer CatchPanic() diff --git a/src/templates/src/project_index.html b/src/templates/src/project_index.html index b30aa72..a6c3e86 100644 --- a/src/templates/src/project_index.html +++ b/src/templates/src/project_index.html @@ -32,10 +32,21 @@ {{ end }}
+ {{ if .CurrentJamProjects }} +
+

{{ template "jam_name" .CurrentJamSlug }}

+

These projects are submissions to the {{ template "jam_name" .CurrentJamSlug }}, which is happening right now! Learn more » +

+ {{ range .CurrentJamProjects }} + {{ template "project_card.html" projectcarddata . "" }} + {{ end }} +
+ See more » +
+ {{ end }} {{ if .OfficialProjects }}

Official Projects

-

These projects are boop boop hahahaa:

{{ range .OfficialProjects }} {{ template "project_card.html" projectcarddata . "" }} @@ -47,7 +58,7 @@ {{ if .PersonalProjects }}

Personal Projects

-

Many community members have projects of their own. Here's a few:

+

Many community members have projects of their own. Want to join them? Create your own.

{{ range .PersonalProjects }} {{ template "project_card.html" projectcarddata . "" }} @@ -56,28 +67,16 @@ See more »
{{ end }} - {{ if .CurrentJamProjects }} -
-

JAM! NOWS!

-

wowowowow

-
- {{ range .CurrentJamProjects }} - {{ template "project_card.html" projectcarddata . "" }} - {{ end }} -
- See more » -
- {{ end }} {{ if .PreviousJamProjects }}
-

JAM! THENS!

-

nonononoono

+

{{ template "jam_name" .PreviousJamSlug }}

+

The following projects were submissions to our most recent jam. Learn more »

{{ range .PreviousJamProjects }} {{ template "project_card.html" projectcarddata . "" }} {{ end }}
- See more » + See more »
{{ end }}
@@ -91,14 +90,25 @@ {{ end }} {{ define "single_category" }} + {{ if eq .Category "official" }} +

Official Projects

+ {{ else if eq .Category "personal" }} +

Personal Projects

+

Many community members have projects of their own. Want to join them? Create your own.

+ {{ else }} + {{/* Here we are assuming everything else is a jam. */}} +

{{ template "jam_name" .Category }}

+

The following projects were submissions to the {{ template "jam_name" .Category }}. Learn more »

+ {{ end }}
-
-
-
-
- {{ template "pagination.html" .Pagination }} + {{ if gt .Pagination.Total 1 }} +
+
+
+ {{ template "pagination.html" .Pagination }} +
-
+ {{ end }}
{{ range .PageProjects }} @@ -106,13 +116,27 @@ {{ end }}
-
-
-
{{ template "pagination.html" .Pagination }}
-
+ {{ if gt .Pagination.Total 1 }} +
+
+
{{ template "pagination.html" .Pagination }}
+
+ {{ 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" }} {{ if .AllProjects }} {{ template "all_projects" . }} diff --git a/src/website/projects.go b/src/website/projects.go index b77f28d..c95b8a8 100644 --- a/src/website/projects.go +++ b/src/website/projects.go @@ -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 }