show help page

Signed-off-by: Xe Iaso <xe@tailscale.com>
This commit is contained in:
Xe Iaso 2023-01-12 21:01:01 +00:00
parent d8cdd736a7
commit 98393c7b58
4 changed files with 55 additions and 5 deletions

View file

@ -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)))

View file

@ -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 {

28
cmd/web/tmpl/help.tmpl Normal file
View file

@ -0,0 +1,28 @@
{{template "header" .}}
<p>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.</p>
<ul>
<li><a href="#cli">Command-line tool</a></li>
<li><a href="#api">API</a></li>
</ul>
<h2 id="cli">Command-line tool</h2>
<p>You can pipe commands or paste files to the pastebin using the command <code>tailpaste</code>. You can install it by installing the <a href="https://go.dev">Go</a> compiler toolkit and then running this command:</p>
<pre><code>go get github.com/tailscale/paste/cmd/tailpaste@main</code></pre>
<p>Once it is installed, invoke it with the command <code>tailpaste</code>:</p>
<pre><code>tailpaste ./foo.txt</code></pre>
<p>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:</p>
<pre><code>go test | tailpaste -n go-test.txt</code></pre>
<h2 id="api">API</h2>
<p>The pastebin service has an API call that
{{template "footer" .}}

View file

@ -4,8 +4,7 @@
<p>Created at {{.CreatedAt}} by {{.PasterDisplayName}}</p>
<pre><code>
{{.Data}}
<pre><code>{{.Data}}
</code></pre>
<a href="/paste/{{.ID}}">Permalink</a> - <a href="/paste/{{.ID}}/dl">Download</a> - <a href="/paste/{{.ID}}/raw">Raw</a>