From c144151c42d81c2fac3821808630d58cc9701301 Mon Sep 17 00:00:00 2001 From: Zhi Wang Date: Sat, 15 Jan 2022 07:13:42 -0500 Subject: [PATCH] replay UI is almost done --- assets/main.css | 2 +- assets/term.html | 6 +++--- main.go | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/main.css b/assets/main.css index 119fca4..257d19a 100644 --- a/assets/main.css +++ b/assets/main.css @@ -1,7 +1,7 @@ #terminal { display: flex; justify-content: center; - margin: 10px 0 20px; + margin: 10px 0 10px; } #terminal #terminal_view { diff --git a/assets/term.html b/assets/term.html index a39aa55..d2f9d93 100644 --- a/assets/term.html +++ b/assets/term.html @@ -47,7 +47,7 @@ btn.innerHTML = btn.value fetch("/record/{{.id}}") } else { - btn.value = "Record"; + btn.value = "Record"; btn.innerHTML = btn.value fetch("/stop/{{.id}}") } @@ -58,12 +58,12 @@ // print something to test output and scroll var str = [ ' ┌────────────────────────────────────────────────────────────────────────────┐\n', - ' │ Powered by \u001b[32;1mGo, Gin, websocket, pty, and xterm.js\x1b[0m │\n', + ' │ \u001b[32;1mhttps://github.com/syssecfsu/witty\x1b[0m <- click it! │\n', ' └────────────────────────────────────────────────────────────────────────────┘\n', '' ].join(''); - term.writeln(str); + term.writeln (str) } Init() diff --git a/main.go b/main.go index a199a0e..f3f4566 100644 --- a/main.go +++ b/main.go @@ -131,6 +131,13 @@ func main() { term_conn.StopRecord(id) }) + // create a viewer of an interactive session + rt.GET("/replay/*id", func(c *gin.Context) { + id := c.Param("id") + log.Println("replay/ called with", id) + c.HTML(http.StatusOK, "replay.html", nil) + }) + // handle static files rt.Static("/assets", "./assets")