feat: initial brick templates

This commit is contained in:
efim
2023-11-15 06:55:12 +00:00
parent 83e81ec011
commit 4764300d08
4 changed files with 199 additions and 1 deletions

View File

@@ -41,6 +41,8 @@ func registerPageRoutes(
authedPageMiddleware(
sessionSM,
http.StripPrefix(subscribeRoomPath, streamingRoomStates(templateFs, roomsM))))
http.HandleFunc("/rooms/preview-templates", roomTemplatesPreview(templateFs))
}
func streamingRoomStates(
@@ -186,7 +188,7 @@ func roomPageRoute(
room, found, err := roomsM.Get(roomName)
if err != nil || !found {
log.Printf("/room room for name %s not found or err: %s / found %d", roomName, err, found)
log.Printf("/room room for name %s not found or err: %s / found %s", roomName, err, found)
// TODO here should be append to error place
w.Header().Add("HX-Redirect", "/")
return
@@ -234,3 +236,55 @@ func roomPageRoute(
}
}
}
func roomTemplatesPreview(
templateFs *embed.FS,
) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
type BrickData struct {
ColorClass template.CSS
Name string
}
contentData := struct {
Bricks []BrickData
}{
Bricks: []BrickData{
{
Name: "expand",
ColorClass: "--expand-color",
},
{
Name: "probing question",
ColorClass: "--probing-q-color",
},
{
Name: "change topic",
ColorClass: "--change-topic-color",
},
{
Name: "clarifying question",
ColorClass: "--clarifying-q-color",
},
{
Name: "meta",
ColorClass: "--meta-color",
},
},
}
pageData := pageData{
Header: headerData{Title: "look at the room templates"},
Content: contentData,
}
baseFile := "templates/base.gohtml"
tmpl := template.Must(template.ParseFS(templateFs, baseFile, "templates/tableTemplates.gohtml"))
err := tmpl.ExecuteTemplate(w, "full-page", pageData)
if err != nil {
log.Printf("yoyo, error %s", err)
}
}
}