From 0ef9a5713567f3d21f558eff6a4f051eab264a03 Mon Sep 17 00:00:00 2001 From: Vic Demuzere <65006+sorcix@users.noreply.github.com> Date: Fri, 11 Aug 2023 00:57:30 +0200 Subject: [PATCH] Fix: Adjust HTML page title to customized AppTitle (#107) Co-authored-by: Knut Ahlers --- README.md | 2 +- customize.go | 17 +++++++++++++---- frontend/index.html | 2 +- src/app.vue | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 576f473..a584804 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ In order to be adjustable to your needs there are some ways to customize your OT appIcon: '' # Override the app-title, if unset or empty the default app-title -# "OTS - One Time Secret" will be used +# "OTS - One Time Secrets" will be used appTitle: '' # Disable display of the app-title (for example if you included the diff --git a/customize.go b/customize.go index 9a99e48..93893fe 100644 --- a/customize.go +++ b/customize.go @@ -43,13 +43,22 @@ func loadCustomize(filename string) (customize, error) { } defer cf.Close() - return cust, errors.Wrap( - yaml.NewDecoder(cf).Decode(&cust), - "decoding customize file", - ) + if err = yaml.NewDecoder(cf).Decode(&cust); err != nil { + return cust, errors.Wrap(err, "decoding customize file") + } + + cust.applyFixes() + + return cust, nil } func (c customize) ToJSON() (string, error) { j, err := json.Marshal(c) return string(j), errors.Wrap(err, "marshalling JSON") } + +func (c *customize) applyFixes() { + if len(c.AppTitle) == 0 { + c.AppTitle = "OTS - One Time Secrets" + } +} diff --git a/frontend/index.html b/frontend/index.html index 8c887b8..d74eafb 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -30,7 +30,7 @@ rel="stylesheet" > - OTS - One Time Secrets + {{ .Customize.AppTitle }}