From 4874013a8c84bb42c1d5f8a62a707748a9af56f4 Mon Sep 17 00:00:00 2001 From: pikachu0542 Date: Sun, 15 Feb 2026 17:33:26 -0500 Subject: [PATCH 1/6] Moved navbar code to its own template --- templates/create.tmpl | 14 ++------------ templates/hidden.tmpl | 15 ++------------- templates/index.tmpl | 13 +------------ templates/nav.tmpl | 17 +++++++++++++++++ templates/poll.tmpl | 13 +------------ templates/result.tmpl | 13 +------------ templates/unauthorized.tmpl | 13 +------------ 7 files changed, 25 insertions(+), 73 deletions(-) create mode 100644 templates/nav.tmpl diff --git a/templates/create.tmpl b/templates/create.tmpl index 1fbeeba..14f1299 100644 --- a/templates/create.tmpl +++ b/templates/create.tmpl @@ -7,18 +7,8 @@ - + {{ template "nav" . }} +

Create Poll

diff --git a/templates/hidden.tmpl b/templates/hidden.tmpl index e7a0969..a2740be 100644 --- a/templates/hidden.tmpl +++ b/templates/hidden.tmpl @@ -20,19 +20,8 @@ - - + {{ template "nav" . }} +
- + {{ template "nav" . }}

Active Polls
diff --git a/templates/nav.tmpl b/templates/nav.tmpl new file mode 100644 index 0000000..748ace3 --- /dev/null +++ b/templates/nav.tmpl @@ -0,0 +1,17 @@ +{{ define "nav" }} + + +{{ end }} \ No newline at end of file diff --git a/templates/poll.tmpl b/templates/poll.tmpl index a501a09..0f074a3 100644 --- a/templates/poll.tmpl +++ b/templates/poll.tmpl @@ -12,18 +12,7 @@ - + {{ template "nav" . }}

{{ .ShortDescription }}

diff --git a/templates/result.tmpl b/templates/result.tmpl index 9e81f54..55b456c 100644 --- a/templates/result.tmpl +++ b/templates/result.tmpl @@ -11,18 +11,7 @@ - + {{ template "nav" . }}

{{ .ShortDescription }}

diff --git a/templates/unauthorized.tmpl b/templates/unauthorized.tmpl index 8d18de1..0a5d226 100644 --- a/templates/unauthorized.tmpl +++ b/templates/unauthorized.tmpl @@ -20,18 +20,7 @@ - + {{ template "nav" . }}
Date: Sun, 15 Feb 2026 18:08:32 -0500 Subject: [PATCH 2/6] Moved closed polls to separate page, added link on navbar to poll creation page --- main.go | 29 ++++++++++++++++++++++++- templates/closed.tmpl | 50 +++++++++++++++++++++++++++++++++++++++++++ templates/index.tmpl | 25 ---------------------- 3 files changed, 78 insertions(+), 26 deletions(-) create mode 100644 templates/closed.tmpl diff --git a/main.go b/main.go index a5f1a2a..a5b3127 100644 --- a/main.go +++ b/main.go @@ -126,7 +126,34 @@ func main() { closedPolls = uniquePolls(closedPolls) c.HTML(200, "index.tmpl", gin.H{ - "Polls": polls, + "Polls": polls, + "Username": claims.UserInfo.Username, + "FullName": claims.UserInfo.FullName, + }) + })) + + r.GET("/closed", csh.AuthWrapper(func(c *gin.Context) { + cl, _ := c.Get("cshauth") + claims := cl.(cshAuth.CSHClaims) + + closedPolls, err := database.GetClosedVotedPolls(c, claims.UserInfo.Username) + if err != nil { + c.JSON(500, gin.H{"error": err.Error()}) + return + } + ownedPolls, err := database.GetClosedOwnedPolls(c, claims.UserInfo.Username) + if err != nil { + c.JSON(500, gin.H{"error": err.Error()}) + return + } + closedPolls = append(closedPolls, ownedPolls...) + + sort.Slice(closedPolls, func(i, j int) bool { + return closedPolls[i].Id > closedPolls[j].Id + }) + closedPolls = uniquePolls(closedPolls) + + c.HTML(200, "closed.tmpl", gin.H{ "ClosedPolls": closedPolls, "Username": claims.UserInfo.Username, "FullName": claims.UserInfo.FullName, diff --git a/templates/closed.tmpl b/templates/closed.tmpl new file mode 100644 index 0000000..a6492b8 --- /dev/null +++ b/templates/closed.tmpl @@ -0,0 +1,50 @@ + + + + CSH Vote + + + + + + + + {{ template "nav" . }} +
+

+
Closed Polls
+

+
+
+ +
+
+ + diff --git a/templates/index.tmpl b/templates/index.tmpl index a262dd6..40b8ac3 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -50,31 +50,6 @@ }}
-
-

Closed Polls

-
-
- -
From 65f0a5db01952e3b24c4a0ae1066e46ef8112032 Mon Sep 17 00:00:00 2001 From: pikachu0542 Date: Mon, 16 Feb 2026 11:31:47 -0500 Subject: [PATCH 3/6] Added open polls link to navbar for more intuitive navigation --- templates/nav.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/nav.tmpl b/templates/nav.tmpl index 748ace3..e16a175 100644 --- a/templates/nav.tmpl +++ b/templates/nav.tmpl @@ -3,6 +3,7 @@
Vote Create Poll + Open Polls Closed Polls