From c04cbc2a24a12bc5ba7f96240bfa28904ec2c5c1 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sun, 3 Nov 2024 02:41:09 -0500 Subject: [PATCH] moves package with data and page handlers for one and all --- web/pages/moves/moves.go | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 web/pages/moves/moves.go diff --git a/web/pages/moves/moves.go b/web/pages/moves/moves.go new file mode 100644 index 0000000..4c09b28 --- /dev/null +++ b/web/pages/moves/moves.go @@ -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, + ) +}