forked from pydio/cells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootconf.go
114 lines (100 loc) · 4.3 KB
/
bootconf.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package frontend
import (
"context"
"strings"
"go.uber.org/zap"
"github.com/pydio/cells/common"
"github.com/pydio/cells/common/config"
"github.com/pydio/cells/common/log"
"github.com/pydio/cells/common/utils"
)
type BackendConf struct {
BuildRevision string
BuildStamp string
License string
PackageLabel string
PackageType string
Version string
}
type CustomWording struct {
Title string `json:"title"`
Icon string `json:"icon"`
IconBinary string `json:"iconBinary"`
}
type BootConf struct {
AjxpResourcesFolder string `json:"ajxpResourcesFolder"`
AjxpServerAccess string `json:"ajxpServerAccess"`
ENDPOINT_REST_API string
ENDPOINT_S3_GATEWAY string
ENDPOINT_WEBSOCKET string
FRONTEND_URL string
PUBLIC_BASEURI string
ZipEnabled bool `json:"zipEnabled"`
MultipleFilesDownloadEnabled bool `json:"multipleFilesDownloadEnabled"`
CustomWording CustomWording `json:"customWording"`
UsersEnabled bool `json:"usersEnabled"`
LoggedUser bool `json:"loggedUser"`
CurrentLanguage string `json:"currentLanguage"`
Session_timeout int `json:"session_timeout"`
Client_timeout int `json:"client_timeout"`
Client_timeout_warning int `json:"client_timeout_warning"`
AvailableLanguages map[string]string `json:"availableLanguages"`
UsersEditable bool `json:"usersEditable"`
AjxpVersion string `json:"ajxpVersion"`
AjxpVersionDate string `json:"ajxpVersionDate"`
I18nMessages map[string]string `json:"i18nMessages"`
Streaming_supported bool `json:"streaming_supported"`
Theme string `json:"theme"`
AjxpImagesCommon bool `json:"ajxpImagesCommon"`
Backend BackendConf `json:"backend"`
Other map[string]interface{} `json:"other,omitempty"`
}
func ComputeBootConf(pool *PluginsPool) *BootConf {
url := config.Get("defaults", "url").String("")
wsUrl := strings.Replace(strings.Replace(url, "https", "wss", -1), "http", "ws", -1)
lang := config.Get("frontend", "plugin", "core.pydio", "DEFAULT_LANGUAGE").String("en-us")
b := &BootConf{
AjxpResourcesFolder: "plug/gui.ajax/res",
AjxpServerAccess: "index.php",
ENDPOINT_REST_API: url + "/a",
ENDPOINT_S3_GATEWAY: url + "/io",
ENDPOINT_WEBSOCKET: wsUrl + "/ws/event",
FRONTEND_URL: url,
PUBLIC_BASEURI: "/public",
ZipEnabled: true,
MultipleFilesDownloadEnabled: true,
UsersEditable: true,
UsersEnabled: true,
LoggedUser: false,
CurrentLanguage: lang,
Session_timeout: 1440,
Client_timeout: 1440,
Client_timeout_warning: 3,
AjxpVersion: common.Version().String(),
AjxpVersionDate: common.BuildStamp,
Streaming_supported: true,
Theme: "material",
AjxpImagesCommon: true,
CustomWording: CustomWording{
Title: config.Get("frontend", "plugin", "core.pydio", "APPLICATION_TITLE").String("Pydio Cells"),
Icon: "plug/gui.ajax/res/themes/common/images/LoginBoxLogo.png",
},
AvailableLanguages: utils.AvailableLanguages,
I18nMessages: pool.I18nMessages(lang).Messages,
Backend: BackendConf{
PackageType: common.PackageType,
PackageLabel: common.PackageLabel,
Version: common.Version().String(),
BuildRevision: common.BuildRevision,
BuildStamp: common.BuildStamp,
License: "agplv3",
},
}
if icBinary := config.Get("frontend", "plugin", "gui.ajax", "CUSTOM_ICON_BINARY").String(""); icBinary != "" {
b.CustomWording.IconBinary = icBinary
}
if e := ApplyBootConfModifiers(b); e != nil {
log.Logger(context.Background()).Error("Error while applying BootConf modifiers", zap.Error(e))
}
return b
}