diff options
author | Grail Finder (aider) <wohilas@gmail.com> | 2025-04-06 09:27:45 +0300 |
---|---|---|
committer | Grail Finder (aider) <wohilas@gmail.com> | 2025-04-06 09:27:45 +0300 |
commit | ad29977e1ad64439f2dd620849439e40c8b97860 (patch) | |
tree | 2dce8be52b2446f95188549e8b42f9e57f1da17f /internal/handlers/main.go | |
parent | 42018ec3137dd2af5c84567e7b603f0eaf055048 (diff) |
feat: add MixedUbung buttons to main page
Diffstat (limited to 'internal/handlers/main.go')
-rw-r--r-- | internal/handlers/main.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 41ff85f..4aa8eca 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -154,11 +154,22 @@ func (h *Handlers) renderQuestion(w http.ResponseWriter, question *models.Questi } func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { - question, err := h.repo.DBGetQuestion("1") + ubungs, err := h.repo.DBGetFirst10MixedUbungs() if err != nil { - h.log.Error("failed to get question", "error", err) - abortWithError(w, "Question not found") + h.log.Error("failed to get mixed ubungs", "error", err) + abortWithError(w, "Failed to load exercises") return } - h.renderQuestion(w, question) + + tmpl, err := template.ParseGlob("components/*.html") + if err != nil { + abortWithError(w, err.Error()) + return + } + + w.Header().Set("Content-Type", "text/html") + err = tmpl.ExecuteTemplate(w, "main", ubungs) + if err != nil { + h.log.Error("failed to render template", "error", err) + } } |