First pass at basic functionality.

This PR introduces the beginnings of Sprint Padawan.

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-05-02 02:01:53 -06:00
parent 3586be0e14
commit 16bed1b8c0
51 changed files with 4597 additions and 1 deletions
+53
View File
@@ -0,0 +1,53 @@
package api
import (
"log"
"net/http"
"sprintpadawan/lib"
)
type RoomView struct {
ID int
Name string
Code string
Scale string
IsOwner bool
MemberCount int
}
func handleIndex(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
user := r.Context().Value(userKey).(*lib.User)
rooms, err := lib.GetRoomSummariesForUser(user.ID)
if err != nil {
http.Error(w, "failed to load rooms", http.StatusInternalServerError)
return
}
data := struct {
*lib.User
Rooms []RoomView
}{
User: user,
}
for _, room := range rooms {
data.Rooms = append(data.Rooms, RoomView{
ID: room.ID,
Name: room.Name,
Code: room.Code,
Scale: room.Scale,
IsOwner: room.OwnerID == user.ID,
MemberCount: room.MemberCount,
})
}
if err := templates.ExecuteTemplate(w, "index.html", data); err != nil {
log.Printf("template error: %v", err)
http.Error(w, "internal server error", http.StatusInternalServerError)
}
}