Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ module github.com/ColoradoSchoolOfMines/mineshspc.com
go 1.25.0

require (
github.com/a-h/templ v0.2.697
github.com/golang-jwt/jwt/v4 v4.5.2
github.com/mattn/go-sqlite3 v1.14.42
github.com/rs/zerolog v1.35.0
github.com/sendgrid/sendgrid-go v3.16.1+incompatible
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
go.mau.fi/util v0.9.7
go.mau.fi/zeroconfig v0.2.0
golang.org/x/net v0.52.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
github.com/a-h/templ v0.2.697 h1:OILxtWvD0NRJaoCOiZCopRDPW8paroKlGsrAiHLykNE=
github.com/a-h/templ v0.2.697/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8=
457 changes: 241 additions & 216 deletions internal/archive.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions internal/contextkeys/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package contextkeys

type contextKey int

const (
ContextKeyLoggedInTeacher contextKey = iota
ContextKeyPageName
ContextKeyRegistrationEnabled
ContextKeyHostedByHTML
)
145 changes: 145 additions & 0 deletions internal/templates/archive.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package templates

import "strconv"

type Link struct {
URL templ.SafeURL
Title string
}

type WinningTeam struct {
Place string
Name string
School string
Location string
}

type CompetitionResult struct {
Name string
Shortname string
Teams []WinningTeam
}

type YearInfo struct {
Year int
RecapParagraphs []string
Links []Link
Results []CompetitionResult
}

func accordionHeadingID(year int, shortname string) string {
return "heading" + strconv.Itoa(year) + shortname
}

func accordionCollapseCSSID(year int, shortname string) string {
return "#" + accordionCollapseID(year, shortname)
}

func accordionCollapseID(year int, shortname string) string {
return "winners" + strconv.Itoa(year) + shortname
}

func trophyColor(place int) string {
switch place + 1 {
case 1:
return "#FFD700"
case 2:
return "#C0C0C0"
default:
return "#CD7F32"
}
}

templ Archive(years []YearInfo) {
<div class="container">
<div class="row page-header">
<div class="col">
<h1>Archive</h1>
<p class="header-paragraph">
Since 2018, the CS@Mines High School Programming
Competition has provided high school students an opportunity to
demonstrate their programming and problem solving skills in a
competitive environment. For more information on all of our competitions
and past problems, view
<a href="https://sumnerevans.com/tags/high-school-programming-competition/" target="_blank">
competition summaries
</a>.
</p>
</div>
</div>
</div>
<div class="container page-content archive pb-5">
for _, y := range years {
@year(y)
@yearLinks(y)
}
</div>
}

templ year(y YearInfo) {
<div class="row mb-4">
<div class="col-lg-5 mt-4 mx-4">
<h2>{ strconv.Itoa(y.Year) }</h2>
for _, p := range y.RecapParagraphs {
<p>{ p }</p>
}
</div>
<div class="col mt-5">
<div class="accordion">
for _, r := range y.Results {
<div class="accordion-item">
<h2 class="accordion-header" id={ accordionHeadingID(y.Year, r.Shortname) }>
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target={ accordionCollapseCSSID(y.Year, r.Shortname) }
aria-expanded="true"
aria-controls={ accordionCollapseID(y.Year, r.Shortname) }
>
<strong>{ r.Name } Competition Winners</strong>
</button>
</h2>
<div
id={ accordionCollapseID(y.Year, r.Shortname) }
class="accordion-collapse collapse"
aria-labelledby={ accordionHeadingID(y.Year, r.Shortname) }
>
<div class="accordion-body">
for i, t := range r.Teams {
@winningTeam(i, t)
}
</div>
</div>
</div>
}
</div>
</div>
</div>
}

templ yearLinks(y YearInfo) {
<div class="row">
<div class="col mx-4">
for i, link := range y.Links {
if i > 0 {
&nbsp;&bull;
}
<a href={ link.URL } target="_blank">{ link.Title }</a>
}
</div>
</div>
}

templ winningTeam(i int, team WinningTeam) {
<li class="list-group-item">
<span class="badge bg-primary rounded-pill">
<i class="fa fa-trophy" { templ.Attributes{"style": "color: " + trophyColor(i) + ";"}... } role="img" aria-label="Trophy"></i>
{ team.Place }
</span>
<strong>{ team.Name }</strong>
<p class="mb-1 text-secondary">
{ team.School } &bull; { team.Location }
</p>
</li>
}
Loading
Loading