-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
70 lines (54 loc) · 1.88 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"html/template"
"log"
"github.com/go-martini/martini"
"github.com/martini-contrib/render"
"github.com/gophergala2016/Pomodoro_Crew/routes"
"github.com/gophergala2016/Pomodoro_Crew/server"
"github.com/gophergala2016/Pomodoro_Crew/session"
"github.com/google/cayley/graph"
"net/http"
"github.com/gophergala2016/Pomodoro_Crew/models"
)
func unescape(x string) interface{} {
return template.HTML(x)
}
func main() {
path := "/tmp/pc"
graph.InitQuadStore("bolt", path, nil)
m := martini.Classic()
unescapeFuncMap := template.FuncMap{"unescape": unescape}
m.Use(session.Middleware)
m.Use(render.Renderer(render.Options{
Directory: "templates", // Specify what path to load the templates from.
Layout: "layout", // Specify a layout template. Layouts can call {{ yield }} to render the current template.
Extensions: []string{".tmpl", ".html"}, // Specify extensions to load for templates.
Funcs: []template.FuncMap{unescapeFuncMap}, // Specify helper function maps for templates to access.
Charset: "UTF-8", // Sets encoding for json and html content-types. Default is "UTF-8".
IndentJSON: true, // Output human readable JSON
}))
storage, err := models.GetStorage()
if err != nil {
log.Fatalln(err)
}
server, err := server.NewServer(storage)
if err != nil {
log.Fatalln(err)
}
user := models.NewUser("admin")
user.Iteration()
staticOptions := martini.StaticOptions{Prefix: "assets"}
m.Use(martini.Static("assets", staticOptions))
m.Get("/", routes.IndexHandler)
m.Get("/login", routes.GetLoginHandler)
m.Get("/logout", routes.LogoutHandler)
m.Post("/login", routes.PostLoginHandler)
m.Get("/view:id", routes.ViewHandler)
m.Post("/gethtml", routes.GetHtmlHandler)
m.Get("/socket.io/", func(w http.ResponseWriter, rnd render.Render, r *http.Request, s *session.Session) {
server.SetSession(s)
server.ServeHTTP(w, r)
})
m.Run()
}