-
Notifications
You must be signed in to change notification settings - Fork 9
/
helpers.go
52 lines (43 loc) · 862 Bytes
/
helpers.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
package models
import (
"net/url"
"strconv"
"github.com/gopheracademy/gccms/content"
)
type HomePage struct {
Hotels []content.Hotel
Sponsors SponsorList
Presentations []Presentation
Workshops []Workshop
}
func GetHomePage() (*HomePage, error) {
var hp HomePage
hotels, err := GetHotelList()
if err != nil {
return &hp, err
}
hp.Hotels = hotels
presentations := GetPresentations()
hp.Presentations = presentations
workshops := GetWorkshops()
hp.Workshops = workshops
sponsors, err := GetSponsorList()
if err != nil {
return &hp, err
}
hp.Sponsors = SortedSponsorList(sponsors)
return &hp, nil
}
func getID(s string) (int, error) {
//?type=Module&id=4
u, err := url.Parse(s)
if err != nil {
return 0, err
}
vals := u.Query()
ii, ok := vals["id"]
if !ok {
return 0, err
}
return strconv.Atoi(ii[0])
}