Merge pull request #189 from linuxserver/badges

This commit is contained in:
Roxedus 2023-11-23 21:29:06 +01:00 committed by GitHub
commit efc975f151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -271,6 +271,8 @@ params:
disrupted: "#cc4400"
down: "#e60000"
notice: "#24478f"
badge_ok: "#4c1"
badge_down: "#e05d44"
# If the status page shows that
# there are disruptions or outages
@ -339,8 +341,17 @@ outputs:
- html
- json
- rss
- badge
mediaTypes:
application/badge:
suffixes:
- badge
outputFormats:
svg:
isPlainText: true
mediaType: image/svg+xml
badge:
isPlainText: true
mediaType: application/badge

View File

@ -0,0 +1,25 @@
{{ $incidents := .Pages }}{{ $active := where $incidents "Params.resolved" "=" false }}{{ $isNotice := where $active "Params.severity" "=" "notice" }}{{ $isDisrupted := where $active "Params.severity" "=" "disrupted" }}{{ $isDown := where $active "Params.severity" "=" "down" -}}
{{ $status_color := .Site.Params.badge_ok -}}
{{ $status_text := "OK" -}}
{{ $status_error := false -}}
{{ if $isDown -}}
{{ $status_text := "Important message" -}}
{{ $status_error := true -}}
{{ $status_color = .Site.Params.badge_down -}}
{{ else if $isDisrupted -}}
{{ $status_text := "Notice" -}}
{{ $status_error := true -}}
{{ $status_color = .Site.Params.disrupted -}}
{{ else if $isNotice -}}
{{ $status_text := "Notice" -}}
{{ $status_error := true -}}
{{ $status_color = .Site.Params.notice -}}
{{ end -}}
{
"schemaVersion": 1,
"label": "Info",
"message": "{{ $status_text }}",
"color": "{{ $status_color }}",
"labelColor": "#555555",
"isError": {{ $status_error }}
}