-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkails.go
97 lines (71 loc) · 2.56 KB
/
kails.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//Kails is a simple spaced repetition web application.
package main
import (
_ "bitbucket.com/abijr/kails/db"
"bitbucket.com/abijr/kails/middleware"
"bitbucket.com/abijr/kails/models"
"bitbucket.com/abijr/kails/routes"
"bitbucket.com/abijr/kails/websocks"
"bitbucket.com/abijr/kails/websocks2"
"github.com/abijr/render"
"github.com/go-martini/martini"
"github.com/martini-contrib/binding"
"github.com/martini-contrib/sessions"
)
func main() {
// Set cookie store
cookieStore := sessions.NewCookieStore([]byte("randomStuff"))
m := martini.Classic()
// Start the cookie handler
m.Use(sessions.Sessions("kails_session", cookieStore))
// Setup templates
m.Use(render.Renderer(render.Options{
Directory: "templates",
Languages: []string{"en-us", "es-mx"},
TranslationDirectory: "translations/all",
Extensions: []string{".tmpl.html"},
}))
m.Use(middleware.InitContext())
m.Use(middleware.Localizer)
m.Use(martini.Static("webapp/dist"))
// Start the language handler
// Serve the application on '/'
m.Group("/webapp", func(r martini.Router) {
m.Get("/study", routes.StudyPage)
r.Get("/study/:id", routes.Study)
r.Post("/study/:id", routes.StudyPost)
m.Get("/words", routes.WordsPage)
m.Get("/words/all", routes.Words)
// m.Post("/words", routes.WordsPost)
// Muestra los ajustes actuales y permite editarlos
r.Get("/settings", routes.Settings)
r.Post("/settings", binding.Bind(routes.SettingsForm{}), routes.SettingsPost)
m.Get("/program", routes.Program)
// Busqueda de usuarios (con "prefix" search)
m.Get("/search/:name", routes.UserSearch)
// Obtiene la informacion del usuario
m.Get("/user/:name", routes.UserPage)
// Chat
m.Get("/chat", routes.Chat)
m.Get("/videochat", routes.Videochat)
m.Get("/friends", routes.Friends)
m.Get("/flashcard", routes.Flashcard)
})
m.Get("/userinfo/:user", routes.UserInfo)
m.Get("/signup", routes.SignUp)
m.Post("/signup", binding.Bind(models.UserSignupForm{}), routes.SignUpPost)
m.Get("/login", routes.Login)
m.Post("/login", binding.Bind(models.UserLoginForm{}), routes.LoginPost)
m.Get("/logout", routes.Logout)
m.Get("/ws", websocks.ServeWs)
m.Get("/ws2", websocks2.ServeWs)
m.Get("/friends/connected", websocks2.ServeConnectedFriends)
// Default route, should be the last one loaded
// Returns the angular main page so that if the
// route's managed by angular it gets handled by it
m.Get("/**", routes.Home)
// Launch server
// It will automatically serve files under the "public" folder
// public/css/file = localhost/css/file
m.Run()
}