Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Adjust HTML page title to customized AppTitle #107

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
rel="stylesheet"
>

<title>OTS - One Time Secrets</title>
<title>{{ .Customize.AppTitle }}</title>

<script nonce="{{ .InlineContentNonce }}">
window.getTheme = () => localStorage.getItem('set-color-scheme') || (window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark')
Expand Down
2 changes: 1 addition & 1 deletion src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class="mr-1"
:src="customize.appIcon"
>
<span v-if="!customize.disableAppTitle">{{ customize.appTitle || 'OTS - One Time Secrets' }}</span>
<span v-if="!customize.disableAppTitle">{{ customize.appTitle }}</span>
</b-navbar-brand>

<b-navbar-toggle target="nav-collapse" />
Expand Down