mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-08 04:20:59 -05: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`
|
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`.
|
which defaults to `$OCIS_BASE_DATA_PATH/web/assets`.
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/5735
|
||||||
https://github.com/owncloud/ocis/pull/5559
|
https://github.com/owncloud/ocis/pull/5559
|
||||||
|
|||||||
@@ -167,37 +167,34 @@ func (p Web) updateLogoThemeConfig(logoPath string) error {
|
|||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
_ = json.NewDecoder(f).Decode(&m)
|
_ = 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{})
|
webCfg, ok := m["web"].(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return errInvalidThemeConfig
|
return errInvalidThemeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultCfg, ok := webCfg["default"].(map[string]interface{})
|
// iterate over all possible themes and replace logo
|
||||||
if !ok {
|
for theme := range webCfg {
|
||||||
return errInvalidThemeConfig
|
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)
|
dst, err := p.fs.Create(_themesConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user