-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
53 lines (44 loc) · 1.15 KB
/
utils.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
package admin
import (
"html/template"
"path/filepath"
"reflect"
"github.com/qor/assetfs"
"github.com/qor/qor"
"github.com/qor/qor/utils"
"github.com/qor/roles"
)
var (
globalViewPaths []string
globalAssetFSes []assetfs.Interface
)
// HasPermissioner has permission interface
type HasPermissioner interface {
HasPermission(roles.PermissionMode, *qor.Context) bool
}
// ResourceNamer is an interface for models that defined method `ResourceName`
type ResourceNamer interface {
ResourceName() string
}
// I18n define admin's i18n interface
type I18n interface {
Scope(scope string) I18n
Default(value string) I18n
T(locale string, key string, args ...interface{}) template.HTML
}
// RegisterViewPath register view path for all assetfs
func RegisterViewPath(pth string) {
globalViewPaths = append(globalViewPaths, pth)
for _, assetFS := range globalAssetFSes {
if assetFS.RegisterPath(filepath.Join(utils.AppRoot, "vendor", pth)) != nil {
for _, gopath := range utils.GOPATH() {
if assetFS.RegisterPath(filepath.Join(gopath, "src", pth)) == nil {
break
}
}
}
}
}
func equal(a, b interface{}) bool {
return reflect.DeepEqual(a, b)
}