From 98393c7b5822dc6f67d1483a42452a634520227f Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Thu, 12 Jan 2023 21:01:01 +0000 Subject: [PATCH] show help page Signed-off-by: Xe Iaso --- cmd/web/main.go | 22 +++++++++++++++++++++- cmd/web/static/css/xess.css | 7 +++++-- cmd/web/tmpl/help.tmpl | 28 ++++++++++++++++++++++++++++ cmd/web/tmpl/showpaste.tmpl | 3 +-- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 cmd/web/tmpl/help.tmpl diff --git a/cmd/web/main.go b/cmd/web/main.go index 836d460..cf0bb39 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -89,6 +89,25 @@ func (s *Server) TailnetIndex(w http.ResponseWriter, r *http.Request) { } } +func (s *Server) TailnetHelp(w http.ResponseWriter, r *http.Request) { + ui, err := upsertUserInfo(r.Context(), s.db, s.lc, r.RemoteAddr) + if err != nil { + s.ShowError(w, r, err, http.StatusInternalServerError) + return + } + + err = s.tmpls.ExecuteTemplate(w, "help.tmpl", struct { + UserInfo *tailcfg.UserProfile + Title string + }{ + UserInfo: ui.UserProfile, + Title: "Help", + }) + if err != nil { + log.Printf("%s: %v", r.RemoteAddr, err) + } +} + func (s *Server) NotFound(w http.ResponseWriter, r *http.Request) { s.tmpls.ExecuteTemplate(w, "notfound.tmpl", struct { UserInfo *tailcfg.UserProfile @@ -185,7 +204,7 @@ VALUES w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "https://%s/paste/%s", s.httpsURL, id) default: - http.Redirect(w, r, fmt.Sprintf("https://%s/paste/%s", s.httpsURL, id), http.StatusSeeOther) + http.Redirect(w, r, fmt.Sprintf("https://%s/paste/%s", s.httpsURL, id), http.StatusCreated) } } @@ -475,6 +494,7 @@ func main() { tailnetMux.HandleFunc("/paste/list", srv.TailnetPasteIndex) tailnetMux.HandleFunc("/api/post", srv.TailnetSubmitPaste) tailnetMux.HandleFunc("/", srv.TailnetIndex) + tailnetMux.HandleFunc("/help", srv.TailnetHelp) funnelMux := http.NewServeMux() funnelMux.Handle("/static/", http.FileServer(http.FS(staticFiles))) diff --git a/cmd/web/static/css/xess.css b/cmd/web/static/css/xess.css index 4a37739..b9a0900 100644 --- a/cmd/web/static/css/xess.css +++ b/cmd/web/static/css/xess.css @@ -2,8 +2,10 @@ --background-color: 0; --text-color: 43; --accent-color: 344; + --font-family: "OpenDyslexic", sans-serif; + --mono-font-family: "OpenDyslexicMono", monospace; - --width: 80ch; + --width: 45rem; --padding: 0; --selection: hsla(var(--accent-color), 80%, 30%, 100%); @@ -31,7 +33,7 @@ } main { - font-family: monospace, monospace; + font-family: var(--font-family); max-width: var(--width); padding: var(--padding); margin: auto; @@ -56,6 +58,7 @@ pre { background-color: var(--pre-background); padding: 1em; border: 0; + font-family: var(--mono-font-family); } a, a:active, a:visited { diff --git a/cmd/web/tmpl/help.tmpl b/cmd/web/tmpl/help.tmpl new file mode 100644 index 0000000..b84c6e1 --- /dev/null +++ b/cmd/web/tmpl/help.tmpl @@ -0,0 +1,28 @@ +{{template "header" .}} + +

Never seen this service before? Want to know how to use it? This page will help you learn more about your tailnet's pastebin tool.

+ + + +

Command-line tool

+ +

You can pipe commands or paste files to the pastebin using the command tailpaste. You can install it by installing the Go compiler toolkit and then running this command:

+ +
go get github.com/tailscale/paste/cmd/tailpaste@main
+ +

Once it is installed, invoke it with the command tailpaste:

+ +
tailpaste ./foo.txt
+ +

and the program will print a URL that you can share with your team. You can also pipe the output from any command to it:

+ +
go test | tailpaste -n go-test.txt
+ +

API

+ +

The pastebin service has an API call that + +{{template "footer" .}} diff --git a/cmd/web/tmpl/showpaste.tmpl b/cmd/web/tmpl/showpaste.tmpl index 7d2aeed..f4a932c 100644 --- a/cmd/web/tmpl/showpaste.tmpl +++ b/cmd/web/tmpl/showpaste.tmpl @@ -4,8 +4,7 @@

Created at {{.CreatedAt}} by {{.PasterDisplayName}}

-

-{{.Data}}
+
{{.Data}}
 
Permalink - Download - Raw