moves package with data and page handlers for one and all

This commit is contained in:
ethan merchant 2024-11-03 02:41:09 -05:00
parent e5afc16a04
commit c04cbc2a24

76
web/pages/moves/moves.go Normal file
View file

@ -0,0 +1,76 @@
package moves
import (
"dofdev/tem"
"net/http"
"github.com/gorilla/mux"
)
type Move struct {
Name string
Desc string
}
var Moves = map[string]Move{
"color_cube": {
Name: "color_cube",
Desc: "color picker & indexer xyz >>> rgb",
},
"oriel": {
Name: "oriel",
Desc: "volumetric graphical control element",
},
"stretch_cursor": {
Name: "stretch_cursor",
Desc: "spatial control using hand distance",
},
"orbital_view": {
Name: "orbital_view",
Desc: "inversely viewed point of interest",
},
"fullstick": {
Name: "fullstick",
Desc: "joystick with full range of motion",
},
}
func Handler(w http.ResponseWriter, r *http.Request) {
data := struct {
Moves map[string]Move
}{
Moves: Moves,
}
tem.Render(
w, r,
"moves.html",
"moves",
"dof driven moves",
data,
)
}
func MoveHandler(w http.ResponseWriter, r *http.Request) {
hash := mux.Vars(r)["hash"]
move, ok := Moves[hash]
if !ok {
w.WriteHeader(http.StatusNotFound)
return
}
data := struct {
Hash string
Move Move
}{
Hash: hash,
Move: move,
}
tem.Render(
w, r,
"move.html",
move.Name,
move.Desc,
data,
)
}