moves package with data and page handlers for one and all
This commit is contained in:
parent
e5afc16a04
commit
c04cbc2a24
1 changed files with 76 additions and 0 deletions
76
web/pages/moves/moves.go
Normal file
76
web/pages/moves/moves.go
Normal 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,
|
||||||
|
)
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue