|
2 | 2 | <html lang="en" class="{{ .Theme }}"> |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8" /> |
| 5 | + <title>{{ .UI.Title }}</title> |
5 | 6 | <script type="text/javascript"> |
6 | | - window.config = {logo: "{{ .UI.Logo }}", header: "{{ .UI.Header }}", dashboardHeading: "{{ .UI.DashboardHeading }}", dashboardSubheading: "{{ .UI.DashboardSubheading }}", link: "{{ .UI.Link }}", buttons: [], maximumNumberOfResults: "{{ .UI.MaximumNumberOfResults }}", defaultSortBy: "{{ .UI.DefaultSortBy }}", defaultFilterBy: "{{ .UI.DefaultFilterBy }}"};{{- range .UI.Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}} |
7 | | - // Initialize theme immediately to prevent flash |
8 | 7 | (function() { |
| 8 | + // String is percent-encoded to prevent it from being replaced when ui config is injected |
| 9 | + if (document.title !== decodeURIComponent("%7B%7B%20.UI.Title%20%7D%7D")) { |
| 10 | + window.config = { |
| 11 | + logo: "{{ .UI.Logo }}", |
| 12 | + header: "{{ .UI.Header }}", |
| 13 | + dashboardHeading: "{{ .UI.DashboardHeading }}", |
| 14 | + dashboardSubheading: "{{ .UI.DashboardSubheading }}", |
| 15 | + link: "{{ .UI.Link }}", |
| 16 | + buttons: [], |
| 17 | + maximumNumberOfResults: "{{ .UI.MaximumNumberOfResults }}", |
| 18 | + defaultSortBy: "{{ .UI.DefaultSortBy }}", |
| 19 | + defaultFilterBy: "{{ .UI.DefaultFilterBy }}" |
| 20 | + }; |
| 21 | + {{- range .UI.Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}} |
| 22 | + } else { |
| 23 | + console.warn('Running in development mode; UI configuration is not injected.'); |
| 24 | + document.title= 'Gatus (Development)'; |
| 25 | + } |
| 26 | + // Initialize theme immediately to prevent flash |
9 | 27 | const themeFromCookie = document.cookie.match(/theme=(dark|light);?/)?.[1]; |
10 | 28 | const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; |
11 | 29 | if (themeFromCookie === 'dark' || (!themeFromCookie && prefersDark)) { |
|
15 | 33 | } |
16 | 34 | })(); |
17 | 35 | </script> |
18 | | - <title>{{ .UI.Title }}</title> |
19 | 36 | <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
20 | 37 | <meta name="viewport" content="width=device-width,initial-scale=1.0" /> |
21 | 38 | <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" /> |
|
0 commit comments