-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome_ctrl.go
65 lines (50 loc) · 1.15 KB
/
home_ctrl.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
package main
import (
"net/http"
//"github.com/c0gent/unframed"
"github.com/c0gent/unframed/log"
)
func homeReg() {
homeTemplates()
homeRoutes()
otherStmts()
}
func homeTemplates() {
net.TemplateFiles(
"tmpl/home.html.tmpl",
"tmpl/help.html.tmpl",
)
}
func homeRoutes() {
net.Get("/", home)
net.Get("/help", help)
}
func home(w http.ResponseWriter, r *http.Request) {
lfgsA := new(lfgsAdapter).list()
lfmsA := new(lfmsAdapter).list()
ra := new(rankingPagesAdapter).list()
net.SetSession(r)
if flashes := net.Session.Flashes(); len(flashes) > 0 {
// Just print the flash values.
log.Message(flashes)
}
lfm_id := 0
if val,ok := net.Session.Values["lfm_id"]; ok {
lfm_id = val.(int)
}
lfg_id := 0
if val,ok := net.Session.Values["lfg_id"]; ok {
lfg_id = val.(int)
}
ou := ""
if val,ok := net.Session.Values["ousts"]; ok {
ou = val.(string)
//log.Message("ousts session value found and sent to tmpl")
}
net.Session.Save(r,w)
//log.Message(len(dataModel.Lfgs))
net.ExeTmpl(w, "home", lfgsA, lfmsA, ra, lfg_id, lfm_id, ou)
}
func help(w http.ResponseWriter, r *http.Request) {
net.ExeTmpl(w, "help", nil)
}