This commit is contained in:
Zhi Wang 2022-01-20 16:40:32 -05:00
parent a82e90499b
commit 0acf1a95af
3 changed files with 83 additions and 7 deletions

39
assets/signin.css Normal file
View File

@ -0,0 +1,39 @@
html,
body {
height: 100%;
}
body {
display: flex;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}
.form-signin {
width: 100%;
max-width: 330px;
padding: 15px;
margin: auto;
}
.form-signin .checkbox {
font-weight: 400;
}
.form-signin .form-floating:focus-within {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}

View File

@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>WiTTY Login</title>
<script src="/assets/external/bootstrap.min.js"></script>
<link href="/assets/external/bootstrap.min.css" rel="stylesheet">
<link href="/assets/signin.css" rel="stylesheet">
</head>
<body class="text-center">
<main class="form-signin">
<form action="/sign-in" method="post">
<img class="mb-4" src="/assets/img/logo.svg" alt="" width="64">
<div class="form-floating">
<input type="text" class="form-control" id="username" name="username" placeholder="User Name">
<label for="username">User Name</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" id="passwd" name="passwd" placeholder="Password">
<label for="passwd">Password</label>
</div>
<div class="checkbox mb-3">
<label><input type="checkbox" name="remember" value="true"> Remember me</label>
</div>
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">WiTTY: Web-based Interactive TTY</p>
</form>
</main>
</body>
</html>

12
main.go
View File

@ -147,13 +147,12 @@ func main() {
// Fill in the index page // Fill in the index page
rt.GET("/", func(c *gin.Context) { rt.GET("/", func(c *gin.Context) {
host = &c.Request.Host host = &c.Request.Host
players, records := collectTabData(c)
c.HTML(http.StatusOK, "index.html", gin.H{ c.HTML(http.StatusOK, "index.html", gin.H{})
"title": "interactive terminal", })
"players": players,
"records": records, rt.GET("/sign-in", func(c *gin.Context) {
}) c.HTML(http.StatusOK, "signin.html", gin.H{})
}) })
rt.GET("/favicon.ico", func(c *gin.Context) { rt.GET("/favicon.ico", func(c *gin.Context) {
@ -175,7 +174,6 @@ func main() {
active1 = "active" active1 = "active"
} }
host = &c.Request.Host
players, records := collectTabData(c) players, records := collectTabData(c)
c.HTML(http.StatusOK, "tab.html", gin.H{ c.HTML(http.StatusOK, "tab.html", gin.H{