mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:08:31 +02:00
feat(loading_page): move loading page css to style.css and serve as static asset
This commit is contained in:
@@ -47,6 +47,10 @@ func isFaviconPath(path string) bool {
|
|||||||
return path == "/favicon.ico"
|
return path == "/favicon.ico"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isLoadingPageCSSPath(path string) bool {
|
||||||
|
return path == "/style.css"
|
||||||
|
}
|
||||||
|
|
||||||
func (w *Watcher) redirectToStartEndpoint(rw http.ResponseWriter, r *http.Request) {
|
func (w *Watcher) redirectToStartEndpoint(rw http.ResponseWriter, r *http.Request) {
|
||||||
uri := "/"
|
uri := "/"
|
||||||
if w.cfg.StartEndpoint != "" {
|
if w.cfg.StartEndpoint != "" {
|
||||||
@@ -96,6 +100,13 @@ func (w *Watcher) wakeFromHTTP(rw http.ResponseWriter, r *http.Request) (shouldN
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isLoadingPageCSSPath(r.URL.Path) {
|
||||||
|
rw.Header().Set("Content-Type", "text/css")
|
||||||
|
rw.WriteHeader(http.StatusOK)
|
||||||
|
rw.Write(cssBytes)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Check if start endpoint is configured and request path matches
|
// Check if start endpoint is configured and request path matches
|
||||||
if w.cfg.StartEndpoint != "" && r.URL.Path != w.cfg.StartEndpoint {
|
if w.cfg.StartEndpoint != "" && r.URL.Path != w.cfg.StartEndpoint {
|
||||||
http.Error(rw, "Forbidden: Container can only be started via configured start endpoint", http.StatusForbidden)
|
http.Error(rw, "Forbidden: Container can only be started via configured start endpoint", http.StatusForbidden)
|
||||||
|
|||||||
@@ -4,109 +4,8 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
<style>
|
<link rel="stylesheet" href="/style.css" />
|
||||||
/* size variables */
|
<link rel="icon" href="/favicon.ico" />
|
||||||
:root {
|
|
||||||
--dot-size: 12px;
|
|
||||||
--logo-size: 100px;
|
|
||||||
}
|
|
||||||
/* Global Styles */
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
font-family:
|
|
||||||
"Inter",
|
|
||||||
-apple-system,
|
|
||||||
BlinkMacSystemFont,
|
|
||||||
"Segoe UI",
|
|
||||||
Roboto,
|
|
||||||
Oxygen,
|
|
||||||
Ubuntu,
|
|
||||||
Cantarell,
|
|
||||||
"Open Sans",
|
|
||||||
"Helvetica Neue",
|
|
||||||
sans-serif;
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 1.5;
|
|
||||||
color: #f8f9fa;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
height: 100vh;
|
|
||||||
margin: 0;
|
|
||||||
gap: 32px;
|
|
||||||
background: linear-gradient(135deg, #121212 0%, #1e1e1e 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Container */
|
|
||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 48px;
|
|
||||||
border-radius: 16px;
|
|
||||||
background-color: rgba(30, 30, 30, 0.6);
|
|
||||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
|
||||||
backdrop-filter: blur(8px);
|
|
||||||
max-width: 90%;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Spinner Styles */
|
|
||||||
.loading-dots {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding-top: 20px;
|
|
||||||
padding-bottom: 6px;
|
|
||||||
}
|
|
||||||
.dot {
|
|
||||||
width: var(--dot-size);
|
|
||||||
height: var(--dot-size);
|
|
||||||
background-color: #66d9ef;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: bounce 1.3s infinite ease-in-out;
|
|
||||||
}
|
|
||||||
.dot:nth-child(1) {
|
|
||||||
animation-delay: -0.32s;
|
|
||||||
}
|
|
||||||
.dot:nth-child(2) {
|
|
||||||
animation-delay: -0.16s;
|
|
||||||
}
|
|
||||||
@keyframes bounce {
|
|
||||||
0%,
|
|
||||||
80%,
|
|
||||||
100% {
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
40% {
|
|
||||||
transform: translateY(-10px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Message Styles */
|
|
||||||
.message {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 500;
|
|
||||||
text-align: center;
|
|
||||||
color: #f8f9fa;
|
|
||||||
max-width: 500px;
|
|
||||||
letter-spacing: 0.3px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Logo */
|
|
||||||
.logo {
|
|
||||||
width: var(--logo-size);
|
|
||||||
height: var(--logo-size);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
91
internal/idlewatcher/html/style.css
Normal file
91
internal/idlewatcher/html/style.css
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/* size variables */
|
||||||
|
:root {
|
||||||
|
--dot-size: 12px;
|
||||||
|
--logo-size: 100px;
|
||||||
|
}
|
||||||
|
/* Global Styles */
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||||
|
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #f8f9fa;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
gap: 32px;
|
||||||
|
background: linear-gradient(135deg, #121212 0%, #1e1e1e 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Container */
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 48px;
|
||||||
|
border-radius: 16px;
|
||||||
|
background-color: rgba(30, 30, 30, 0.6);
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
max-width: 90%;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Spinner Styles */
|
||||||
|
.loading-dots {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
.dot {
|
||||||
|
width: var(--dot-size);
|
||||||
|
height: var(--dot-size);
|
||||||
|
background-color: #66d9ef;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: bounce 1.3s infinite ease-in-out;
|
||||||
|
}
|
||||||
|
.dot:nth-child(1) {
|
||||||
|
animation-delay: -0.32s;
|
||||||
|
}
|
||||||
|
.dot:nth-child(2) {
|
||||||
|
animation-delay: -0.16s;
|
||||||
|
}
|
||||||
|
@keyframes bounce {
|
||||||
|
0%,
|
||||||
|
80%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
40% {
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Message Styles */
|
||||||
|
.message {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: center;
|
||||||
|
color: #f8f9fa;
|
||||||
|
max-width: 500px;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Logo */
|
||||||
|
.logo {
|
||||||
|
width: var(--logo-size);
|
||||||
|
height: var(--logo-size);
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package idlewatcher
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"text/template"
|
"html/template"
|
||||||
|
|
||||||
"github.com/yusing/goutils/http/httpheaders"
|
"github.com/yusing/goutils/http/httpheaders"
|
||||||
)
|
)
|
||||||
@@ -18,6 +18,9 @@ type templateData struct {
|
|||||||
var loadingPage []byte
|
var loadingPage []byte
|
||||||
var loadingPageTmpl = template.Must(template.New("loading_page").Parse(string(loadingPage)))
|
var loadingPageTmpl = template.Must(template.New("loading_page").Parse(string(loadingPage)))
|
||||||
|
|
||||||
|
//go:embed html/style.css
|
||||||
|
var cssBytes []byte
|
||||||
|
|
||||||
func (w *Watcher) makeLoadingPageBody() []byte {
|
func (w *Watcher) makeLoadingPageBody() []byte {
|
||||||
msg := w.cfg.ContainerName() + " is starting..."
|
msg := w.cfg.ContainerName() + " is starting..."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user