mirror of
https://github.com/Luzifer/ots.git
synced 2025-02-24 08:59:46 -05:00
Fix: Adjust HTML page title to customized AppTitle (#107)
Co-authored-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f768beb112
commit
ff29af2e47
@ -39,7 +39,7 @@ In order to be adjustable to your needs there are some ways to customize your OT
|
|||||||
appIcon: ''
|
appIcon: ''
|
||||||
|
|
||||||
# Override the app-title, if unset or empty the default app-title
|
# 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: ''
|
appTitle: ''
|
||||||
|
|
||||||
# Disable display of the app-title (for example if you included the
|
# Disable display of the app-title (for example if you included the
|
||||||
|
24
customize.go
24
customize.go
@ -25,14 +25,13 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadCustomize(filename string) (customize, error) {
|
func loadCustomize(filename string) (cust customize, err error) {
|
||||||
if filename == "" {
|
if filename == "" {
|
||||||
// None given, take a shortcut
|
// None given, take a shortcut
|
||||||
return customize{}, nil
|
cust.applyFixes()
|
||||||
|
return cust, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var cust customize
|
|
||||||
|
|
||||||
cf, err := os.Open(filename)
|
cf, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, fs.ErrNotExist) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
@ -43,13 +42,22 @@ func loadCustomize(filename string) (customize, error) {
|
|||||||
}
|
}
|
||||||
defer cf.Close()
|
defer cf.Close()
|
||||||
|
|
||||||
return cust, errors.Wrap(
|
if err = yaml.NewDecoder(cf).Decode(&cust); err != nil {
|
||||||
yaml.NewDecoder(cf).Decode(&cust),
|
return cust, errors.Wrap(err, "decoding customize file")
|
||||||
"decoding customize file",
|
}
|
||||||
)
|
|
||||||
|
cust.applyFixes()
|
||||||
|
|
||||||
|
return cust, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c customize) ToJSON() (string, error) {
|
func (c customize) ToJSON() (string, error) {
|
||||||
j, err := json.Marshal(c)
|
j, err := json.Marshal(c)
|
||||||
return string(j), errors.Wrap(err, "marshalling JSON")
|
return string(j), errors.Wrap(err, "marshalling JSON")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *customize) applyFixes() {
|
||||||
|
if len(c.AppTitle) == 0 {
|
||||||
|
c.AppTitle = "OTS - One Time Secrets"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
>
|
>
|
||||||
|
|
||||||
<title>OTS - One Time Secrets</title>
|
<title>{{ .Customize.AppTitle }}</title>
|
||||||
|
|
||||||
<script nonce="{{ .InlineContentNonce }}">
|
<script nonce="{{ .InlineContentNonce }}">
|
||||||
window.getTheme = () => localStorage.getItem('set-color-scheme') || (window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark')
|
window.getTheme = () => localStorage.getItem('set-color-scheme') || (window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark')
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
class="mr-1"
|
class="mr-1"
|
||||||
:src="customize.appIcon"
|
: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-brand>
|
||||||
|
|
||||||
<b-navbar-toggle target="nav-collapse" />
|
<b-navbar-toggle target="nav-collapse" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user