Only register the xdg-open handlers for openoffice if the plugin is enabled.

This commit is contained in:
Gabe Van Engel 2024-07-20 00:00:53 -07:00
parent 179d8694ae
commit 0c7cf16e72
2 changed files with 21 additions and 5 deletions

View file

@ -194,13 +194,24 @@ func (this Get) FrontendOverrides() []string {
return overrides
}
var xdg_open []string
var xdg_open []func() string
func (this Register) XDGOpen(jsString string) {
xdg_open = append(xdg_open, jsString)
xdg_open = append(xdg_open, func() string {
return jsString
})
}
func (this Register) XDGOpenFunc(fn func() string) {
xdg_open = append(xdg_open, fn)
}
func (this Get) XDGOpen() []string {
return xdg_open
var s []string
for i := 0; i < len(xdg_open); i++ {
s = append(s, xdg_open[i]())
}
return s
}
var cssOverride []func() string

View file

@ -108,14 +108,19 @@ func init() {
).Methods("GET")
return nil
})
Hooks.Register.XDGOpen(`
Hooks.Register.XDGOpenFunc(func() string {
if plugin_enable() == false {
return ""
}
return `
if(mime === "application/word" || mime === "application/msword" ||
mime === "application/vnd.oasis.opendocument.text" || mime === "application/vnd.oasis.opendocument.spreadsheet" ||
mime === "application/excel" || mime === "application/vnd.ms-excel" || mime === "application/powerpoint" ||
mime === "application/vnd.ms-powerpoint" || mime === "application/vnd.oasis.opendocument.presentation" ) {
return ["appframe", {"endpoint": "/api/onlyoffice/iframe"}];
}
`)
`
})
}
func StaticHandler(res http.ResponseWriter, req *http.Request) {