/
init.go
56 lines (44 loc) 路 1.12 KB
/
init.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
package rest
import (
"crypto/sha256"
"github.com/beauxarts/fedorov/data"
"github.com/beauxarts/fedorov/stencil_app"
"github.com/beauxarts/fedorov/view_models"
"github.com/boggydigital/kvas"
"github.com/boggydigital/middleware"
"github.com/boggydigital/stencil"
"html/template"
"io/fs"
)
const (
SearchResultsLimit = 24 // divides by 2,3,4,6 to allow that many columns
)
var (
rdx kvas.ReadableRedux
tmpl *template.Template
app *stencil.AppConfiguration
)
func SetUsername(role, u string) {
middleware.SetUsername(role, sha256.Sum256([]byte(u)))
}
func SetPassword(role, p string) {
middleware.SetPassword(role, sha256.Sum256([]byte(p)))
}
func InitTemplates(templatesFS fs.FS, stencilAppStyles fs.FS) {
tmpl = template.Must(
template.
New("").
Funcs(view_models.FuncMap()).
ParseFS(templatesFS, "templates/*.gohtml"))
stencil.InitAppTemplates(stencilAppStyles, "stencil_app/styles/css.gohtml")
}
func Init() error {
var err error
if rdx, err = data.NewReduxReader(data.ReduxProperties()...); err != nil {
return err
}
if app, err = stencil_app.Init(rdx); err != nil {
return err
}
return err
}