forked from statping/statping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.go
48 lines (45 loc) · 1.01 KB
/
export.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
package core
import (
"bytes"
"github.com/hunterlong/statup/utils"
"html/template"
"io/ioutil"
)
func ExportIndexHTML() string {
CoreApp.OfflineAssets = true
//out := index{*CoreApp, CoreApp.Services}
nav, _ := TmplBox.String("nav.html")
footer, _ := TmplBox.String("footer.html")
render, err := TmplBox.String("index.html")
if err != nil {
utils.Log(3, err)
}
t := template.New("message")
t.Funcs(template.FuncMap{
"js": func(html string) template.JS {
return template.JS(html)
},
"safe": func(html string) template.HTML {
return template.HTML(html)
},
"VERSION": func() string {
return VERSION
},
"underscore": func(html string) string {
return utils.UnderScoreString(html)
},
})
t, _ = t.Parse(nav)
t, _ = t.Parse(footer)
t.Parse(render)
var tpl bytes.Buffer
if err := t.Execute(&tpl, nil); err != nil {
utils.Log(3, err)
}
result := tpl.String()
return result
}
func SaveFile(filename string, data []byte) error {
err := ioutil.WriteFile(filename, data, 0644)
return err
}