Hardcoded web options (#6188)

* use custom struct for web options

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* update envvar descriptions

Co-authored-by: Martin <github@diemattels.at>

* Use correct defaults

* fix code style

---------

Signed-off-by: jkoberg <jkoberg@owncloud.com>
Co-authored-by: Michael Barz <michael.barz@zeitgestalten.eu>
Co-authored-by: Martin <github@diemattels.at>
Co-authored-by: Michael Barz <mbarz@owncloud.com>
This commit is contained in:
kobergj
2023-05-02 10:55:18 +02:00
committed by GitHub
parent ee9a524bf5
commit 44de28843f
4 changed files with 112 additions and 12 deletions

View File

@@ -66,8 +66,20 @@ func DefaultConfig() *config.Config {
},
},
},
Options: map[string]interface{}{
"previewFileMimeTypes": []string{"image/gif", "image/png", "image/jpeg", "text/plain", "image/tiff", "image/bmp", "image/x-ms-bmp"},
Options: config.Options{
ContextHelpersReadMore: true,
PreviewFileMimeTypes: []string{"image/gif", "image/png", "image/jpeg", "text/plain", "image/tiff", "image/bmp", "image/x-ms-bmp"},
SharingRecipientsPerPage: 200,
AccountEditLink: &config.AccountEditLink{},
Editor: &config.Editor{},
FeedbackLink: &config.FeedbackLink{},
Routing: config.Routing{
IDBased: true,
},
Sidebar: config.Sidebar{
Shares: config.SidebarShares{},
},
Upload: &config.Upload{},
},
},
},
@@ -121,4 +133,22 @@ func Sanitize(cfg *config.Config) {
if cfg.Web.Config.OpenIDConnect.MetadataURL == "" {
cfg.Web.Config.OpenIDConnect.MetadataURL = strings.TrimRight(cfg.Web.Config.OpenIDConnect.Authority, "/") + "/.well-known/openid-configuration"
}
// remove AccountEdit parent if no value is set
if cfg.Web.Config.Options.AccountEditLink.Href == "" {
cfg.Web.Config.Options.AccountEditLink = nil
}
// remove Editor parent if no value is set
if !cfg.Web.Config.Options.Editor.AutosaveEnabled {
cfg.Web.Config.Options.Editor = nil
}
// remove FeedbackLink parent if no value is set
if cfg.Web.Config.Options.FeedbackLink.Href == "" &&
cfg.Web.Config.Options.FeedbackLink.AriaLabel == "" &&
cfg.Web.Config.Options.FeedbackLink.Description == "" {
cfg.Web.Config.Options.FeedbackLink = nil
}
// remove Upload parent if no value is set
if cfg.Web.Config.Options.Upload.XHR.Timeout == 0 {
cfg.Web.Config.Options.Upload = nil
}
}