This commit is contained in:
Zhi Wang 2022-01-11 15:22:24 -05:00
parent 91a18a3ff8
commit 2720c1ba3f
4 changed files with 56 additions and 17 deletions

View File

@ -10,19 +10,18 @@
<title>Web Terminal</title>
<!-- Bootstrap core CSS -->
<link href="external/bootstrap.min.css" rel="stylesheet">
</script>
</head>
<link href="/assets/external/bootstrap.min.css" rel="stylesheet">
<link href="/assets/main.css" rel="stylesheet">
<body>
<header>
<nav class="navbar navbar-dark bg-dark shadow-sm">
<nav class="navbar navbar-dark bg-dark shadow-sm navbar-xs">
<div class="container-fluid">
<a class="navbar-brand">
<img src="logo.svg" style="margin-left: 3em;margin-right: 3em;" width="48" height="36"
class="d-inline-block align-text-top" />
<strong>A web-based terminal emulator</strong></a>
<a class="btn btn-primary float-end" href="{{.url}}" role="button">New Session</a>
<img src="/assets/logo.svg" style="margin-left: 2em;margin-right: 1em;" height="24"
class="d-inline-block align-text-top">
Web-based Terminal Emulator
<a class="btn btn-primary btn-sm float-end" href="/new" role="button">New Session</a>
</div>
</nav>
</header>

View File

@ -28,8 +28,28 @@
background-color: #ffffff20;
}
h2 {
font-family: 'Fira Sans', sans-serif;
font-size: 32;
.banner {
position: absolute;
top: 0;
left: 0;
background-color: #0b0b33;
width: 100%;
}
.banner-content {
font-family: sans-serif;
font-size: 22px;
padding: 0.5rem;
color: #ffffffff;
text-align: center;
}
.navbar-xs .navbar-brand {
padding: 0px 12px;
font-size: 22px;
}
.navbar-xs .navbar-nav>li>a {
padding-top: 0px;
padding-bottom: 0px;
}

View File

@ -22,10 +22,18 @@
</head>
<body>
<h2>{{.title}}</h2>
<div class="banner">
<div class="banner-content">
{{.title}}
</div>
</div>
<div style="margin-top: 7em;">
<div id="terminal">
<div id="terminal_view"></div>
</div>
</div>
<script>
term = createTerminal("{{.path}}");
// print something to test output and scroll
@ -41,6 +49,7 @@
term.writeln(str);
</script>
</body>
</html>

17
main.go
View File

@ -57,12 +57,23 @@ func main() {
rt.LoadHTMLGlob("./assets/*.html")
rt.GET("/view/*sname", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{
c.HTML(http.StatusOK, "term.html", gin.H{
"title": "Viewer terminal",
"path": "/ws_view",
})
})
rt.GET("/new", func(c *gin.Context) {
if host == nil {
host = &c.Request.Host
}
c.HTML(http.StatusOK, "term.html", gin.H{
"title": "Interactive terminal",
"path": "/ws_do",
})
})
rt.GET("/ws_do", func(c *gin.Context) {
term_conn.ConnectTerm(c.Writer, c.Request, false, cmdToExec)
})
@ -75,12 +86,12 @@ func main() {
rt.Static("/assets", "./assets")
rt.GET("/", func(c *gin.Context) {
host = &c.Request.Host
c.HTML(http.StatusOK, "index.html", gin.H{
"title": "Interactive terminal",
"path": "/ws_do",
})
host = &c.Request.Host
})
term_conn.Init(checkOrigin)