Skip to content

Commit

Permalink
Merge pull request #5735 from owncloud/branding-improvements
Browse files Browse the repository at this point in the history
add common part, make the logic theme name agnostic
  • Loading branch information
micbar authored Mar 6, 2023
2 parents b517a6c + e05e3b9 commit 8d937a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/branding-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 16 additions & 19 deletions services/web/pkg/service/v0/branding.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,37 +167,34 @@ func (p Web) updateLogoThemeConfig(logoPath string) error {
var m map[string]interface{}
_ = json.NewDecoder(f).Decode(&m)

webCfg, ok := m["web"].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
}

defaultCfg, ok := webCfg["default"].(map[string]interface{})
// change logo in common part
commonCfg, ok := m["common"].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
}
commonCfg["logo"] = logoPath

logoCfg, ok := defaultCfg["logo"].(map[string]interface{})
webCfg, ok := m["web"].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
}

logoCfg["login"] = logoPath
logoCfg["topbar"] = logoPath
// iterate over all possible themes and replace logo
for theme := range webCfg {
themeCfg, ok := webCfg[theme].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
}

defaultDarkCfg, ok := webCfg["default-dark"].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
}
logoCfg, ok := themeCfg["logo"].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
}

logoDarkCfg, ok := defaultDarkCfg["logo"].(map[string]interface{})
if !ok {
return errInvalidThemeConfig
logoCfg["login"] = logoPath
logoCfg["topbar"] = logoPath
}

logoDarkCfg["login"] = logoPath
logoDarkCfg["topbar"] = logoPath

dst, err := p.fs.Create(_themesConfigPath)
if err != nil {
return err
Expand Down

0 comments on commit 8d937a3

Please sign in to comment.