add ability for menus to contain images (needed to handle EMInds top menu "hack")

This commit is contained in:
2026-03-06 22:09:02 -07:00
parent 89f70a3aa5
commit 406de6985e
4 changed files with 77 additions and 31 deletions
+10
View File
@@ -29,5 +29,15 @@
"AMSTERDAM_CONFIG": "${workspaceFolder}/test2.yaml" "AMSTERDAM_CONFIG": "${workspaceFolder}/test2.yaml"
} }
}, },
{
"name": "EMinds Reborn",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"env": {
"AMSTERDAM_CONFIG": "/u01/home/amy/Erbosoft/emreborn/amsterdam.yaml"
}
},
] ]
} }
+1
View File
@@ -31,6 +31,7 @@ import (
type MenuItem struct { type MenuItem struct {
Text string `yaml:"text"` Text string `yaml:"text"`
Link string `yaml:"link"` Link string `yaml:"link"`
Image string `yaml:"image"`
Disabled bool `yaml:"disabled"` Disabled bool `yaml:"disabled"`
Hazard bool `yaml:"hazard"` Hazard bool `yaml:"hazard"`
Permission string `yaml:"permission"` Permission string `yaml:"permission"`
+26 -2
View File
@@ -8,13 +8,25 @@
*} *}
{{ block leftMenu(menu) }} {{ block leftMenu(menu) }}
<div class="mb-2 mt-2"> <div class="mb-2 mt-2">
{{ if menu.Title != "" }}
<div class="font-bold mb-1">{{ menu.Title }}</div> <div class="font-bold mb-1">{{ menu.Title }}</div>
{{ end }}
{{ range _, it := menu.Items }} {{ range _, it := menu.Items }}
{{ if it.Show(.) }} {{ if it.Show(.) }}
{{ if it.Image != "" }}
{{ if it.Link != "" && !it.Disabled }}
<a href="{{ it.Link }}"><img src="{{ it.Image }}" alt="{{ it.Text }}"></a>
{{ else }}
<img src="{{ it.Image }}" alt="{{ it.Text }}">
{{ end }}
{{ else }}
{{ if it.Disabled }} {{ if it.Disabled }}
<div class="text-gray-500 mb-1">{{ it.Text }}</div> <div class="text-gray-500 mb-1">{{ it.Text }}</div>
{{ else }} {{ else if it.Link != "" }}
<a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a> <a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a>
{{ else }}
<div class="mb-1">{{ it.Text }}</div>
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
@@ -26,13 +38,25 @@
<div class="mb-1"> <div class="mb-1">
<img src="{{ ExtractCommunityLogo(__comm, .) }}" alt="{{ __comm.Name }}" class="w-28 h-16 rounded"> <img src="{{ ExtractCommunityLogo(__comm, .) }}" alt="{{ __comm.Name }}" class="w-28 h-16 rounded">
</div> </div>
{{ if menu.Title != "" }}
<div class="font-bold mb-1">{{ menu.Title }}</div> <div class="font-bold mb-1">{{ menu.Title }}</div>
{{ end }}
{{ range _, it := menu.Items }} {{ range _, it := menu.Items }}
{{ if it.Show(.) }} {{ if it.Show(.) }}
{{ if it.Image != "" }}
{{ if it.Link != "" && !it.Disabled }}
<a href="{{ it.Link }}"><img src="{{ it.Image }}" alt="{{ it.Text }}"></a>
{{ else }}
<img src="{{ it.Image }}" alt="{{ it.Text }}">
{{ end }}
{{ else }}
{{ if it.Disabled }} {{ if it.Disabled }}
<div class="text-gray-500 mb-1">{{ it.Text }}</div> <div class="text-gray-500 mb-1">{{ it.Text }}</div>
{{ else }} {{ else if it.Link != "" }}
<div class="mb-1"><a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a></div> <div class="mb-1"><a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a></div>
{{ else }}
<div class="mb-1">{{ it.Text }}</div>
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
+21 -10
View File
@@ -8,6 +8,7 @@
*} *}
<div class="p-4"> <div class="p-4">
<!-- Page Title --> <!-- Page Title -->
{{ if menu.Title != "" }}
<div class="mb-6"> <div class="mb-6">
{{ if menu.Subtitle != "" }} {{ if menu.Subtitle != "" }}
<div class="flex items-baseline gap-3 mb-2"> <div class="flex items-baseline gap-3 mb-2">
@@ -19,25 +20,35 @@
{{ end }} {{ end }}
<hr class="border-2 border-gray-400 w-4/5 mb-4"> <hr class="border-2 border-gray-400 w-4/5 mb-4">
</div> </div>
{{ end }}
<!-- Administration Menu --> <!-- Rendered Menu -->
<div class="max-w-2xl"> <div class="max-w-2xl">
<div class="bg-gray-50 p-6 rounded-lg"> <div class="bg-gray-50 p-6 rounded-lg">
<nav class="space-y-3"> <nav class="space-y-3">
{{ ctxt := . }} {{ range _, m := menu.Items }}
{{ range menu.Items }}
{{ vis := true }} {{ vis := true }}
{{ if .Ifdef != "" && !defs[.Ifdef] }}{{ vis = false }}{{ end }} {{ if m.Ifdef != "" && !defs[m.Ifdef] }}{{ vis = false }}{{ end }}
{{ if vis && .Show(ctxt) }} {{ if vis && m.Show(.) }}
<div class="flex items-start gap-3"> <div class="flex items-start gap-3">
{{ if m.Image != "" }}
{{ if it.Link != "" && !it.Disabled }}
<a href="{{ it.Link }}"><img src="{{ it.Image }}" alt="{{ it.Text }}"></a>
{{ else }}
<img src="{{ it.Image }}" alt="{{ it.Text }}">
{{ end }}
{{ else }}
<span class="text-lg pt-0.5">🟣</span> <span class="text-lg pt-0.5">🟣</span>
{{ if .Disabled }} {{ if m.Disabled }}
<span class="text-gray-500 font-medium">{{ .Text }}</span> <span class="text-gray-500 font-medium">{{ m.Text }}</span>
{{ else if m.Link != "" }}
{{ if m.Hazard }}
<a href="{{ m.Link }}" class="text-red-700 hover:text-red-900 font-medium">⚠️ {{ m.Text }}</a>
{{ else }} {{ else }}
{{ if .Hazard }} <a href="{{ m.Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ m.Text }}</a>
<a href="{{ .Link }}" class="text-red-700 hover:text-red-900 font-medium">⚠️ {{ .Text }}</a> {{ end }}
{{ else }} {{ else }}
<a href="{{ .Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ .Text }}</a> <span class="font-medium">{{ m.Text }}</span>
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </div>