diff --git a/config.json b/config.json index b67fd75..6b61fd6 100644 --- a/config.json +++ b/config.json @@ -35,7 +35,8 @@ }, "hackathon": { "start_time": "2024-03-20T00:15:00-08:00", - "duration": "150m" + "duration": "150m", + "location": "EC 063" }, "open_registration_time": "2024-03-17T00:00:00-08:00" } diff --git a/internal/config/config.go b/internal/config/config.go index 75ecdab..ec22e98 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -37,6 +37,7 @@ type ProblemModule struct { type HackathonConfig struct { StartTime time.Time `json:"start_time"` Duration Duration `json:"duration"` + Location string `json:"location"` } func (c HackathonConfig) EndTime() time.Time { diff --git a/server/frontend/frontend.go b/server/frontend/frontend.go index aa8a1b6..675cd16 100644 --- a/server/frontend/frontend.go +++ b/server/frontend/frontend.go @@ -9,6 +9,7 @@ import ( "time" "github.com/Masterminds/sprig/v3" + "github.com/dustin/go-humanize" "github.com/yuin/goldmark" "libdb.so/tmplutil" ) @@ -65,6 +66,7 @@ func NewTemplater(fs fs.FS) *tmplutil.Templater { int(d.Seconds())%60) } }, + "ordinal": humanize.Ordinal, }, ), } diff --git a/server/frontend/pages/hackathon.html b/server/frontend/pages/hackathon.html index b49dcfe..e272c49 100644 --- a/server/frontend/pages/hackathon.html +++ b/server/frontend/pages/hackathon.html @@ -13,12 +13,18 @@

Mini Hackathon

- Think, create and present at this mini hackathon geared towards - beginners + {{ .StartTime.Format "Monday, January" }} + {{ .StartTime.Day | ordinal }} + in + {{ .Location }}

+

+ Think, create and present at this mini Hackathon geared towards + beginners. +

Move quickly, you've only got 2 hours!

diff --git a/server/frontend/pages/index.html b/server/frontend/pages/index.html index 7f95d62..42a5227 100644 --- a/server/frontend/pages/index.html +++ b/server/frontend/pages/index.html @@ -37,7 +37,12 @@

Getting Started

Week of Code

-

Monday, February 19th until 23rd

+

+ {{ .Problems.StartedAt.Format "Monday, January" }} + {{ .Problems.StartedAt.Day | ordinal }} + until the + {{ .Problems.EndingAt.Day | ordinal }} +

A week of coding challenges designed and curated by ACM to promote good problem-solving @@ -58,7 +63,12 @@

Week of Code

Mini Hackathon

-

Monday, February 23rd at ??? in CS ???

+

+ {{ .HackathonConfig.StartTime.Format "Monday, January" }} + {{ .HackathonConfig.StartTime.Day | ordinal }} + in + {{ .HackathonConfig.Location }} +

diff --git a/server/frontend/pages/problems.html b/server/frontend/pages/problems.html index fa1126e..79fd78b 100644 --- a/server/frontend/pages/problems.html +++ b/server/frontend/pages/problems.html @@ -8,13 +8,21 @@

Week of Code

-

A new coding problem every day

+

+ {{ .Problems.StartedAt.Format "Monday, January" }} + {{ .Problems.StartedAt.Day | ordinal }} + until the + {{ .Problems.EndingAt.Day | ordinal }} +

-

- Completing at least one part each day will result in a - 1337 score bonus for your team! -

+
+

A new coding problem every day!

+

+ You may get more points for solving problems as soon as they are released, so keep an + eye out for the next problem! +

+
{{ if not (eq .Problems.TotalProblems 1) }}
    diff --git a/server/problem/problemset.go b/server/problem/problemset.go index 8036d1d..05d3475 100644 --- a/server/problem/problemset.go +++ b/server/problem/problemset.go @@ -44,6 +44,15 @@ func (p *ProblemSet) StartedAt() time.Time { return p.schedule.StartReleaseAt } +// EndingAt returns the time at which the last problem is released. If the +// problem set does not have a release schedule, it returns the zero time. +func (p *ProblemSet) EndingAt() time.Time { + if p.schedule == nil { + return time.Time{} + } + return p.schedule.StartReleaseAt.Add(time.Duration(len(p.problems)) * p.schedule.ReleaseEvery) +} + // Problems returns all available problems in the set. func (p *ProblemSet) Problems() []Problem { return p.problems[:p.AvailableProblems()] diff --git a/server/server.go b/server/server.go index d58eafe..7e57041 100644 --- a/server/server.go +++ b/server/server.go @@ -109,7 +109,9 @@ func writeError(w http.ResponseWriter, code int, err error) { type indexPageData struct { frontend.ComponentContext - InviteCode string + Problems *problem.ProblemSet + HackathonConfig config.HackathonConfig + InviteCode string } func (s *Server) index(w http.ResponseWriter, r *http.Request) { @@ -130,7 +132,9 @@ func (s *Server) index(w http.ResponseWriter, r *http.Request) { TeamName: u.TeamName, Username: u.Username, }, - InviteCode: inviteCode, + Problems: s.problems, + HackathonConfig: s.config.HackathonConfig, + InviteCode: inviteCode, }) }