mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
feat: light/dark variant icons and selfh.st tag as default category
- code refactor - reduce memory usage
This commit is contained in:
@@ -81,7 +81,7 @@ func TestApplyLabel(t *testing.T) {
|
||||
"proxy.a.middlewares.request.set_headers.X-Header": "value1",
|
||||
"proxy.a.middlewares.request.add_headers.X-Header2": "value2",
|
||||
"proxy.a.homepage.show": "true",
|
||||
"proxy.a.homepage.icon": "png/adguard-home.png",
|
||||
"proxy.a.homepage.icon": "@selfhst/adguard-home.png",
|
||||
"proxy.a.healthcheck.path": "/ping",
|
||||
"proxy.a.healthcheck.interval": "10s",
|
||||
},
|
||||
@@ -127,9 +127,8 @@ func TestApplyLabel(t *testing.T) {
|
||||
expect.Equal(t, b.Container.IdlewatcherConfig.StopSignal, "SIGTERM")
|
||||
|
||||
expect.Equal(t, a.Homepage.Show, true)
|
||||
expect.Equal(t, a.Homepage.Icon.Value, "png/adguard-home.png")
|
||||
expect.Equal(t, a.Homepage.Icon.Extra.FileType, "png")
|
||||
expect.Equal(t, a.Homepage.Icon.Extra.Name, "adguard-home")
|
||||
expect.Equal(t, a.Homepage.Icon.Extra.Ref, "adguard-home")
|
||||
|
||||
expect.Equal(t, a.HealthCheck.Path, "/ping")
|
||||
expect.Equal(t, a.HealthCheck.Interval, 10*time.Second)
|
||||
|
||||
@@ -479,35 +479,29 @@ func (r *Route) FinalizeHomepageConfig() {
|
||||
r.Homepage = r.Homepage.GetOverride(r.Alias)
|
||||
|
||||
hp := r.Homepage
|
||||
ref := r.Reference()
|
||||
meta, ok := homepage.GetHomepageMeta(ref)
|
||||
if ok {
|
||||
if hp.Name == "" {
|
||||
hp.Name = meta.DisplayName
|
||||
}
|
||||
if hp.Category == "" {
|
||||
hp.Category = meta.Tag
|
||||
}
|
||||
}
|
||||
|
||||
var key string
|
||||
if hp.Name == "" {
|
||||
if r.Container != nil {
|
||||
key = r.Container.Image.Name
|
||||
} else {
|
||||
key = r.Alias
|
||||
}
|
||||
displayName, ok := homepage.GetDisplayName(key)
|
||||
if ok {
|
||||
hp.Name = displayName
|
||||
} else {
|
||||
hp.Name = strutils.Title(
|
||||
strings.ReplaceAll(
|
||||
strings.ReplaceAll(key, "-", " "),
|
||||
"_", " ",
|
||||
),
|
||||
)
|
||||
}
|
||||
hp.Name = strutils.Title(
|
||||
strings.ReplaceAll(
|
||||
strings.ReplaceAll(ref, "-", " "),
|
||||
"_", " ",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if hp.Category == "" {
|
||||
if config.GetInstance().Value().Homepage.UseDefaultCategories {
|
||||
if isDocker {
|
||||
key = r.Container.Image.Name
|
||||
} else {
|
||||
key = strings.ToLower(r.Alias)
|
||||
}
|
||||
if category, ok := homepage.PredefinedCategories[key]; ok {
|
||||
if category, ok := homepage.PredefinedCategories[ref]; ok {
|
||||
hp.Category = category
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user