projects package with data and page handlers for one and all
This commit is contained in:
parent
c04cbc2a24
commit
d716bcf70e
1 changed files with 62 additions and 0 deletions
62
web/pages/projects/projects.go
Normal file
62
web/pages/projects/projects.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package projects
|
||||
|
||||
import (
|
||||
"dofdev/tem"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type Project struct {
|
||||
Name string
|
||||
Desc string
|
||||
}
|
||||
|
||||
var Projects = map[string]Project{
|
||||
"braille_xr": {
|
||||
Name: "braille_xr",
|
||||
Desc: "refreshable braille display for rendering and input with handtracking",
|
||||
},
|
||||
"tungtap": {
|
||||
Name: "tungtap",
|
||||
Desc: "easily augment your system's keyboard",
|
||||
},
|
||||
}
|
||||
|
||||
func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
data := struct {
|
||||
Projects map[string]Project
|
||||
}{
|
||||
Projects: Projects,
|
||||
}
|
||||
tem.Render(
|
||||
w, r,
|
||||
"projects.html",
|
||||
"projects",
|
||||
"dof driven projects",
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
||||
func ProjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||
hash := mux.Vars(r)["hash"]
|
||||
|
||||
project, ok := Projects[hash]
|
||||
if !ok {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
data := struct {
|
||||
Project Project
|
||||
}{
|
||||
Project: project,
|
||||
}
|
||||
tem.Render(
|
||||
w, r,
|
||||
"project.html",
|
||||
project.Name,
|
||||
project.Desc,
|
||||
data,
|
||||
)
|
||||
}
|
Loading…
Add table
Reference in a new issue