mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 01:10:20 -06:00
add common part, make the logic theme name agnostic
This commit is contained in:
@@ -3,4 +3,5 @@ Enhancement: Add endpoints to upload a custom logo
|
||||
Added endpoints to upload and reset custom logos. The files are stored under the `WEB_ASSET_PATH`
|
||||
which defaults to `$OCIS_BASE_DATA_PATH/web/assets`.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/5735
|
||||
https://github.com/owncloud/ocis/pull/5559
|
||||
|
||||
@@ -167,37 +167,34 @@ func (p Web) updateLogoThemeConfig(logoPath string) error {
|
||||
var m map[string]interface{}
|
||||
_ = json.NewDecoder(f).Decode(&m)
|
||||
|
||||
// change logo in common part
|
||||
commonCfg, ok := m["common"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
commonCfg["logo"] = logoPath
|
||||
|
||||
webCfg, ok := m["web"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
|
||||
defaultCfg, ok := webCfg["default"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
// iterate over all possible themes and replace logo
|
||||
for theme := range webCfg {
|
||||
themeCfg, ok := webCfg[theme].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
|
||||
logoCfg, ok := themeCfg["logo"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
|
||||
logoCfg["login"] = logoPath
|
||||
logoCfg["topbar"] = logoPath
|
||||
}
|
||||
|
||||
logoCfg, ok := defaultCfg["logo"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
|
||||
logoCfg["login"] = logoPath
|
||||
logoCfg["topbar"] = logoPath
|
||||
|
||||
defaultDarkCfg, ok := webCfg["default-dark"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
|
||||
logoDarkCfg, ok := defaultDarkCfg["logo"].(map[string]interface{})
|
||||
if !ok {
|
||||
return errInvalidThemeConfig
|
||||
}
|
||||
|
||||
logoDarkCfg["login"] = logoPath
|
||||
logoDarkCfg["topbar"] = logoPath
|
||||
|
||||
dst, err := p.fs.Create(_themesConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user