diff options
author | Runxi Yu <me@runxiyu.org> | 2025-08-18 05:10:14 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-08-18 05:10:14 +0800 |
commit | dd0017446dcd605b3670784336d38c1083895abe (patch) | |
tree | d9882611f6c38560c2490ef918ccfa46f09380c4 /forged/internal | |
parent | Make logging in work (diff) | |
download | forge-dd0017446dcd605b3670784336d38c1083895abe.tar.gz forge-dd0017446dcd605b3670784336d38c1083895abe.tar.zst forge-dd0017446dcd605b3670784336d38c1083895abe.zip |
Diffstat (limited to 'forged/internal')
-rw-r--r-- | forged/internal/incoming/web/handlers/group.go | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/forged/internal/incoming/web/handlers/group.go b/forged/internal/incoming/web/handlers/group.go index e56a3b5..3551ab1 100644 --- a/forged/internal/incoming/web/handlers/group.go +++ b/forged/internal/incoming/web/handlers/group.go @@ -1,9 +1,10 @@ package handlers import ( + "log" "net/http" - "strings" + "go.lindenii.runxiyu.org/forge/forged/internal/database/queries" "go.lindenii.runxiyu.org/forge/forged/internal/incoming/web/templates" wtypes "go.lindenii.runxiyu.org/forge/forged/internal/incoming/web/types" ) @@ -20,9 +21,36 @@ func NewGroupHTTP(r templates.Renderer) *GroupHTTP { func (h *GroupHTTP) Index(w http.ResponseWriter, r *http.Request, _ wtypes.Vars) { base := wtypes.Base(r) - _ = h.r.Render(w, "group/index.html", struct { - GroupPath string + p, err := base.Queries.GetGroupIDDescByPath(r.Context(), base.URLSegments) + if err != nil { + log.Println("failed to get group ID by path", "error", err) + http.Error(w, "Internal Server Error", http.StatusInternalServerError) + return + } + subgroups, err := base.Queries.GetSubgroups(r.Context(), &p.ID) + if err != nil { + log.Println("failed to get subgroups", "error", err) + http.Error(w, "Internal Server Error", http.StatusInternalServerError) + // TODO + } + repos, err := base.Queries.GetReposInGroup(r.Context(), p.ID) + if err != nil { + log.Println("failed to get repos in group", "error", err) + http.Error(w, "Internal Server Error", http.StatusInternalServerError) + // TODO + } + err = h.r.Render(w, "group", struct { + BaseData *wtypes.BaseData + Subgroups []queries.GetSubgroupsRow + Repos []queries.GetReposInGroupRow + Description string }{ - GroupPath: "/" + strings.Join(base.GroupPath, "/") + "/", + BaseData: base, + Subgroups: subgroups, + Repos: repos, + Description: p.Description, }) + if err != nil { + log.Println("failed to render index page", "error", err) + } } |