Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

ent: Add utf charset to doc and add svg based power button - [ch7623] #239

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions internal/loginsrv/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Server struct {
func loginRedirectHTMLDoc(message string, status string) string {
htmlTemplate := `<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="icon"
Expand Down Expand Up @@ -67,18 +68,28 @@ func loginRedirectHTMLDoc(message string, status string) string {
top: -100px;
opacity: 0;
}
#power svg {
width: 80px;
height: 80px;
}
.power-on {
color: #519a54;
background-color: #a2e0a5;
align-items: center;
animation: glow-green 1s alternate infinite ease-in-out,
slide-down-fade-in 1s normal forwards ease-in-out;
}
.power-on svg {
fill: #519a54;
}
.power-off {
background-color: #dd47641a;
color: #dd4764;
animation: slide-down-fade-in 1s normal forwards ease-in-out;
}
.power-off svg {
fill: #dd4764;
}
#instruction {
position: relative;
top: -100px;
Expand Down Expand Up @@ -155,7 +166,14 @@ func loginRedirectHTMLDoc(message string, status string) string {
></path>
</svg>
<div class="power-{{.Status}}" id="power">
<span>&#9211;</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 310 310">
<path
d="M221.742,46.906c-7.28-3.954-16.387-1.259-20.341,6.021c-3.955,7.279-1.259,16.386,6.02,20.341 C242.937,92.561,265,129.626,265,170c0,60.654-49.346,110-110,110S45,230.654,45,170c0-40.198,21.921-77.186,57.208-96.531 c7.265-3.982,9.925-13.1,5.943-20.364c-3.983-7.264-13.101-9.925-20.364-5.943C42.891,71.775,15,118.844,15,170 c0,77.196,62.804,140,140,140s140-62.804,140-140C295,118.62,266.929,71.453,221.742,46.906z"
></path>
<path
d="M155,130c8.284,0,15-6.716,15-15V15c0-8.284-6.716-15-15-15c-8.284,0-15,6.716-15,15v100 C140,123.284,146.716,130,155,130z"
></path>
</svg>
</div>
<p id="instruction">{{.Message}}</p>
</div>
Expand Down Expand Up @@ -191,7 +209,7 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
case <-ctx.Done():
// Client disconnect. Nothing to do.
case srv.TokenChan <- token:
w.Header().Set("Content-Type", "text/html")
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprint(w, loginRedirectHTMLDoc("You are logged in, you may close this window now.", "on"))
}
Expand Down