Skip to content

Commit c88fd52

Browse files
committed
Merge branch 'dev'
2 parents 9044e64 + f0541ea commit c88fd52

File tree

9 files changed

+63
-69
lines changed

9 files changed

+63
-69
lines changed

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ FROM alpine:3.21
99
WORKDIR /app
1010
COPY --from=builder /app/glance .
1111

12-
HEALTHCHECK --timeout=10s --start-period=60s --interval=60s \
13-
CMD wget --spider -q http://localhost:8080/api/healthz
14-
1512
EXPOSE 8080/tcp
1613
ENTRYPOINT ["/app/glance", "--config", "/app/config/glance.yml"]

Dockerfile.goreleaser

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ FROM alpine:3.21
33
WORKDIR /app
44
COPY glance .
55

6-
HEALTHCHECK --timeout=10s --start-period=60s --interval=60s \
7-
CMD wget --spider -q http://localhost:8080/api/healthz
8-
96
EXPOSE 8080/tcp
107
ENTRYPOINT ["/app/glance", "--config", "/app/config/glance.yml"]

docs/configuration.md

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Environment variables](#environment-variables)
77
- [Other ways of providing tokens/passwords/secrets](#other-ways-of-providing-tokenspasswordssecrets)
88
- [Including other config files](#including-other-config-files)
9+
- [Icons](#icons)
910
- [Config schema](#config-schema)
1011
- [Authentication](#authentication)
1112
- [Server](#server)
@@ -185,6 +186,30 @@ docker run --rm -v ./glance.yml:/app/config/glance.yml glanceapp/glance config:p
185186

186187
This assumes that the config you want to print is in your current working directory and is named `glance.yml`.
187188

189+
## Icons
190+
191+
For widgets which provide you with the ability to specify icons such as the monitor, bookmarks, docker containers, etc, you can use the `icon` property to specify a URL to an image or use icon names from multiple libraries via prefixes:
192+
193+
```yml
194+
icon: si:immich # si for Simple icons https://simpleicons.org/
195+
icon: sh:immich # sh for selfh.st icons https://selfh.st/icons/
196+
icon: di:immich # di for Dashboard icons https://github.com/homarr-labs/dashboard-icons
197+
icon: mdi:camera # mdi for Material Design icons https://pictogrammers.com/library/mdi/
198+
```
199+
200+
> [!NOTE]
201+
>
202+
> The icons are loaded externally and are hosted on `cdn.jsdelivr.net`, if you do not wish to depend on a 3rd party you are free to download the icons individually and host them locally.
203+
204+
Icons from the Simple icons library as well as Material Design icons will automatically invert their color to match your light or dark theme, however you may want to enable this manually for other icons. To do this, you can use the `auto-invert` prefix:
205+
206+
```yaml
207+
icon: auto-invert https://example.com/path/to/icon.png # with a URL
208+
icon: auto-invert sh:glance-dark # with a selfh.st icon
209+
```
210+
211+
This expects the icon to be black and will automatically invert it to white when using a dark theme.
212+
188213
## Config schema
189214

190215
For property descriptions, validation and autocompletion of the config within your IDE, @not-first has kindly created a [schema](https://github.com/not-first/glance-schema). Massive thanks to them for this, go check it out and give them a star!
@@ -1962,17 +1987,7 @@ If the monitored service returns an error, the user will be redirected here. If
19621987

19631988
`icon`
19641989

1965-
Optional URL to an image which will be used as the icon for the site. Can be an external URL or internal via [server configured assets](#assets-path). You can also directly use [Simple Icons](https://simpleicons.org/) via a `si:` prefix or [Dashboard Icons](https://github.com/walkxcode/dashboard-icons) via a `di:` prefix:
1966-
1967-
```yaml
1968-
icon: si:jellyfin
1969-
icon: si:gitea
1970-
icon: si:adguard
1971-
```
1972-
1973-
> [!WARNING]
1974-
>
1975-
> Simple Icons are loaded externally and are hosted on `cdn.jsdelivr.net`, if you do not wish to depend on a 3rd party you are free to download the icons individually and host them locally.
1990+
See [Icons](#icons) for more information on how to specify icons.
19761991

19771992
`timeout`
19781993

@@ -2280,7 +2295,7 @@ Whether to only show running containers. If set to `true` only containers that a
22802295
| Name | Description |
22812296
| ---- | ----------- |
22822297
| glance.name | The name displayed in the UI. If not specified, the name of the container will be used. |
2283-
| glance.icon | The icon displayed in the UI. Can be an external URL or an icon prefixed with si:, sh: or di: like with the bookmarks and monitor widgets |
2298+
| glance.icon | See [Icons](#icons) for more information on how to specify icons |
22842299
| glance.url | The URL that the user will be redirected to when clicking on the container. |
22852300
| glance.same-tab | Whether to open the link in the same or a new tab. Default is `false`. |
22862301
| glance.description | A short description displayed in the UI. Default is empty. |
@@ -2595,17 +2610,7 @@ An array of groups which can optionally have a title and a custom color.
25952610

25962611
`icon`
25972612

2598-
URL pointing to an image. You can also directly use [Simple Icons](https://simpleicons.org/) via a `si:` prefix or [Dashboard Icons](https://github.com/walkxcode/dashboard-icons) via a `di:` prefix:
2599-
2600-
```yaml
2601-
icon: si:gmail
2602-
icon: si:youtube
2603-
icon: si:reddit
2604-
```
2605-
2606-
> [!WARNING]
2607-
>
2608-
> Simple Icons are loaded externally and are hosted on `cdn.jsdelivr.net`, if you do not wish to depend on a 3rd party you are free to download the icons individually and host them locally.
2613+
See [Icons](#icons) for more information on how to specify icons.
26092614

26102615
`same-tab`
26112616

internal/glance/config-fields.go

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -131,52 +131,45 @@ func (d *durationField) UnmarshalYAML(node *yaml.Node) error {
131131

132132
type customIconField struct {
133133
URL template.URL
134-
IsFlatIcon bool
135-
// TODO: along with whether the icon is flat, we also need to know
136-
// whether the icon is black or white by default in order to properly
137-
// invert the color based on the theme being light or dark
134+
AutoInvert bool
138135
}
139136

140137
func newCustomIconField(value string) customIconField {
141138
const autoInvertPrefix = "auto-invert "
142139
field := customIconField{}
143140

141+
if strings.HasPrefix(value, autoInvertPrefix) {
142+
field.AutoInvert = true
143+
value = strings.TrimPrefix(value, autoInvertPrefix)
144+
}
145+
144146
prefix, icon, found := strings.Cut(value, ":")
145147
if !found {
146-
if strings.HasPrefix(value, autoInvertPrefix) {
147-
field.IsFlatIcon = true
148-
value = strings.TrimPrefix(value, autoInvertPrefix)
149-
}
150-
151148
field.URL = template.URL(value)
152149
return field
153150
}
154151

155-
switch prefix {
156-
case "si":
157-
field.URL = template.URL("https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/" + icon + ".svg")
158-
field.IsFlatIcon = true
159-
case "di", "sh":
160-
// syntax: di:<icon_name>[.svg|.png]
161-
// syntax: sh:<icon_name>[.svg|.png]
162-
// if the icon name is specified without extension, it is assumed to be wanting the SVG icon
163-
// otherwise, specify the extension of either .svg or .png to use either of the CDN offerings
164-
// any other extension will be interpreted as .svg
165-
basename, ext, found := strings.Cut(icon, ".")
166-
if !found {
167-
ext = "svg"
168-
basename = icon
169-
}
152+
basename, ext, found := strings.Cut(icon, ".")
153+
if !found {
154+
ext = "svg"
155+
basename = icon
156+
}
170157

171-
if ext != "svg" && ext != "png" {
172-
ext = "svg"
173-
}
158+
if ext != "svg" && ext != "png" {
159+
ext = "svg"
160+
}
174161

175-
if prefix == "di" {
176-
field.URL = template.URL("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/" + ext + "/" + basename + "." + ext)
177-
} else {
178-
field.URL = template.URL("https://cdn.jsdelivr.net/gh/selfhst/icons/" + ext + "/" + basename + "." + ext)
179-
}
162+
switch prefix {
163+
case "si":
164+
field.AutoInvert = true
165+
field.URL = template.URL("https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/" + basename + ".svg")
166+
case "di":
167+
field.URL = template.URL("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/" + ext + "/" + basename + "." + ext)
168+
case "mdi":
169+
field.AutoInvert = true
170+
field.URL = template.URL("https://cdn.jsdelivr.net/npm/@mdi/svg@latest/svg/" + basename + ".svg")
171+
case "sh":
172+
field.URL = template.URL("https://cdn.jsdelivr.net/gh/selfhst/icons/" + ext + "/" + basename + "." + ext)
180173
default:
181174
field.URL = template.URL(value)
182175
}

internal/glance/static/js/page.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function setupSearchBoxes() {
194194

195195
document.addEventListener("keydown", (event) => {
196196
if (['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)) return;
197-
if (event.key != "s") return;
197+
if (event.code != "KeyS") return;
198198

199199
inputElement.focus();
200200
event.preventDefault();
@@ -643,13 +643,14 @@ async function setupCalendars() {
643643
}
644644

645645
async function setupTodos() {
646-
const elems = document.getElementsByClassName("todo");
646+
const elems = Array.from(document.getElementsByClassName("todo"));
647647
if (elems.length == 0) return;
648648

649649
const todo = await import ('./todo.js');
650650

651-
for (let i = 0; i < elems.length; i++)
651+
for (let i = 0; i < elems.length; i++){
652652
todo.default(elems[i]);
653+
}
653654
}
654655

655656
function setupTruncatedElementTitles() {
@@ -661,7 +662,8 @@ function setupTruncatedElementTitles() {
661662

662663
for (let i = 0; i < elements.length; i++) {
663664
const element = elements[i];
664-
if (element.getAttribute("title") === null) element.title = element.innerText;
665+
if (element.getAttribute("title") === null)
666+
element.title = element.innerText.trim().replace(/\s+/g, " ");
665667
}
666668
}
667669

internal/glance/static/js/popover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function repositionContainer() {
130130
} else if (left + containerBounds.width > window.innerWidth) {
131131
containerElement.style.removeProperty("left");
132132
containerElement.style.right = 0;
133-
containerElement.style.setProperty("--triangle-offset", containerBounds.width - containerInlinePadding - (window.innerWidth - targetBounds.left - targetBoundsWidthOffset) + -1 + "px");
133+
containerElement.style.setProperty("--triangle-offset", containerBounds.width - containerInlinePadding - (document.documentElement.clientWidth - targetBounds.left - targetBoundsWidthOffset) + -1 + "px");
134134
} else {
135135
containerElement.style.removeProperty("right");
136136
containerElement.style.left = left + "px";

internal/glance/templates/bookmarks.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="flex items-center gap-10">
1414
{{- if ne "" .Icon.URL }}
1515
<div class="bookmarks-icon-container">
16-
<img class="bookmarks-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
16+
<img class="bookmarks-icon{{ if .Icon.AutoInvert }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
1717
</div>
1818
{{- end }}
1919
<a href="{{ .URL | safeURL }}" class="bookmarks-link {{ if .HideArrow }}bookmarks-link-no-arrow {{ end }}color-highlight size-h4" {{ if .Target }}target="{{ .Target }}"{{ end }} rel="noreferrer">{{ .Title }}</a>

internal/glance/templates/docker-containers.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{- range .Containers }}
66
<li class="docker-container flex items-center gap-15">
77
<div class="shrink-0" data-popover-type="html" data-popover-position="above" data-popover-offset="0.25" data-popover-margin="0.1rem" data-popover-max-width="400px" aria-hidden="true">
8-
<img class="docker-container-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
8+
<img class="docker-container-icon{{ if .Icon.AutoInvert }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
99
<div data-popover-html>
1010
<div class="color-highlight text-truncate block">{{ .Image }}</div>
1111
<div>{{ .StateText }}</div>

internal/glance/templates/monitor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
{{ define "site" }}
2424
{{ if .Icon.URL }}
25-
<img class="monitor-site-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
25+
<img class="monitor-site-icon{{ if .Icon.AutoInvert }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
2626
{{ end }}
2727
<div class="grow min-width-0">
2828
<a class="size-h3 color-highlight text-truncate block" href="{{ .URL | safeURL }}" {{ if not .SameTab }}target="_blank"{{ end }} rel="noreferrer">{{ .Title }}</a>

0 commit comments

Comments
 (0)