rename to infinipaste

Signed-off-by: Xe Iaso <xe@tailscale.com>
This commit is contained in:
Xe Iaso 2023-01-16 16:06:46 +00:00
parent 14c5989f6c
commit 2d60fbc5cb
8 changed files with 99 additions and 98 deletions

View file

@ -1,6 +1,7 @@
# paste # infinipaste
A self-hostable pastebin for your tailnet. A self-hostable pastebin for your tailnet. It can store an infinite\*
number of pastes.
## Development ## Development
@ -11,7 +12,7 @@ A self-hostable pastebin for your tailnet.
## Building ## Building
``` ```
nix build .#bin nix build .#web
``` ```
``` ```

View file

@ -14,12 +14,12 @@ import (
var ( var (
fname = flag.String("n", "", "filename to use for pastes from standard input") fname = flag.String("n", "", "filename to use for pastes from standard input")
target = flag.String("target", "http://paste", "paste server URL") target = flag.String("target", "http://paste", "infinipaste server URL")
) )
func main() { func main() {
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [filename]\n\nTakes a file or standard in and posts it to your tailnet's paste service. Returns a URL on standard out for sharing.\n\nFlags:\n", filepath.Base(os.Args[0])) fmt.Fprintf(os.Stderr, "Usage: %s [filename]\n\nTakes a file or standard in and posts it to your tailnet's infinipaste service. Returns a URL on standard out for sharing.\n\nFlags:\n", filepath.Base(os.Args[0]))
flag.PrintDefaults() flag.PrintDefaults()
os.Exit(2) os.Exit(2)
} }

View file

@ -9,7 +9,7 @@
<body id="top"> <body id="top">
<main> <main>
<nav> <nav>
<a href="/">Paste</a>{{if .UserInfo}} - <a href="/paste/list">List</a> - <a href="/help">Help</a>{{end}} <a href="/">Infinipaste</a>{{if .UserInfo}} - <a href="/paste/list">List</a> - <a href="/help">Help</a>{{end}}
{{if .UserInfo}}<div class="right">{{.UserInfo.DisplayName}} <img style="width:32px;height:32px" src="{{.UserInfo.ProfilePicURL}}" /></div>{{end}} {{if .UserInfo}}<div class="right">{{.UserInfo.DisplayName}} <img style="width:32px;height:32px" src="{{.UserInfo.ProfilePicURL}}" /></div>{{end}}
</nav> </nav>

View file

@ -13,17 +13,17 @@
<h2 id="cli">Command-line tool</h2> <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> <p>You can pipe commands or paste files to the pastebin using the command <code>infinipaste</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> <pre><code>go get github.com/tailscale/paste/cmd/infinipaste@main</code></pre>
<p>Once it is installed, invoke it with the command <code>tailpaste</code>:</p> <p>Once it is installed, invoke it with the command <code>infinipaste</code>:</p>
<pre><code>tailpaste ./foo.txt</code></pre> <pre><code>infinipaste ./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> <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 &amp;2&lt;1 | tailpaste -n go-test.txt</code></pre> <pre><code>go test &amp;2&lt;1 | infinipaste -n go-test.txt</code></pre>
<h2 id="api">API</h2> <h2 id="api">API</h2>
@ -52,13 +52,13 @@
<h3 id="emacs">Emacs package</h3> <h3 id="emacs">Emacs package</h3>
<p>The default distribution of tailpaste ships with a package for <a href="https://www.gnu.org/software/emacs/">GNU Emacs</a>. This package will let you submit pastes from your editor. It requires the <a href="https://github.com/tkf/emacs-request"><code>request</code></a> package and exposes two interactive functions:</p> <p>The default distribution of infinipaste ships with a package for <a href="https://www.gnu.org/software/emacs/">GNU Emacs</a>. This package will let you submit pastes from your editor. It requires the <a href="https://github.com/tkf/emacs-request"><code>request</code></a> package and exposes two interactive functions:</p>
<ul> <ul>
<li><code>M-x tailpaste-submit-region</code> - submits the currently highlighted region to tailpaste</li> <li><code>M-x infinipaste-submit-region</code> - submits the currently highlighted region to infinipaste</li>
<li><code>M-x tailpaste-submit-buffer</code> - submits the contents of the current buffer to tailpaste</li> <li><code>M-x infinipaste-submit-buffer</code> - submits the contents of the current buffer to infinipaste</li>
</ul> </ul>
<p>You can download this package <a href="https://github.com/tailscale/paste/blob/main/contrib/tailpaste.el">from the tailpaste repository</a>. You can install it by using <code>M-x package-install-file</code> or by opening it in Emacs and running <code>M-x package-install-from-buffer</code>. Please be sure that <code>request</code> is installed.</p> <p>You can download this package <a href="https://github.com/tailscale-dev/infinipaste/blob/main/contrib/infinipaste.el">from the infinipaste repository</a>. You can install it by using <code>M-x package-install-file</code> or by opening it in Emacs and running <code>M-x package-install-from-buffer</code>. Please be sure that <code>request</code> is installed.</p>
{{template "footer" .}} {{template "footer" .}}

View file

@ -2,6 +2,6 @@
<div class="right"><img style="width:32px;height:32px" src="{{.PasterProfilePicURL}}" /></div> <div class="right"><img style="width:32px;height:32px" src="{{.PasterProfilePicURL}}" /></div>
There are no pastes in the list. Try <a href="/">creating some</a> <p>There are no pastes in the list. Try <a href="/">creating some</a>!</p>
{{template "footer" .}} {{template "footer" .}}

81
contrib/infinipaste.el Normal file
View file

@ -0,0 +1,81 @@
;;; infinipaste.el --- infinipaste client for Emacs -*- lexical-binding: t; -*-
;; Copyright (C)
;; 2023 Tailscale, Inc.
;; Author: Xe Iaso <xe@tailscale.com>
;; Maintainer: Xe Iaso <xe@tailscale.com>
;; Created: 2023-01-13
;; Version: 0.1
;; Keywords: tailscale, pastebin, sharing
;; Homepage: https://github.com/tailscale-dev/infinipaste
;;; Commentary:
;;
;; This uses request-el to make requests to your tailnet's infinipaste server. You
;; can install request-el with M-x package-install.
;;
;; This package requires that you have a infinipaste server set up. This package
;; reaches out to a infinipaste server over either plain HTTP, or HTTPS should you
;; configure the variable `infinipaste-server'.
;;
;; Usage:
;;
;; To submit the contents of the current buffer to infinipaste:
;; M-x infinipaste-submit-buffer
;; To submit the contents of the currently highlighted region to infinipaste:
;; M-x infinipaste-submit-region
;;
;; Customization:
;;
;; To customize the infinipaste server this package reaches out to:
;; M-x customize-group infinipaste
;;
;; You can customize the infinipaste server URL by changing the value of `infinipaste-server':
;; (setq infinipaste-server "https://paste.shark-harmonic.ts.net")
;;; Code:
(require 'request)
(defgroup infinipaste nil
"Infinipaste server configuration."
:prefix "infinipaste-"
:group 'infinipaste)
(defcustom infinipaste-server "http://paste"
"The server that is running infinipaste or a service with a compatible API to infinipaste. This should NOT end with a trailing slash."
:group 'infinipaste
:type 'string)
(defun infinipaste--send-paste (fname content)
"Internal function that actually fires off the paste with name FNAME and content CONTENT to the infinipaste server."
(request (format "%s/api/post" infinipaste-server)
:type "POST"
:data `(("filename" . ,fname)
("content" . ,content))
:headers '(("Accept" . "text/plain"))
:timeout 60
:success (cl-function
(lambda (&key response &allow-other-keys)
(message "%s" (request-response-data response))))))
(defun infinipaste-submit-buffer ()
"Submits the entire current buffer to infinipaste."
(interactive)
(let ((fname (format "%s.%s"
(file-name-base (buffer-file-name))
(file-name-extension (buffer-file-name))))
(content (buffer-string)))
(infinipaste--send-paste fname content)))
(defun infinipaste-submit-region ()
"Submits the highlighted region to infinipaste."
(interactive)
(let ((fname (format "%s.%s"
(file-name-base (buffer-file-name))
(file-name-extension (buffer-file-name))))
(content (buffer-substring-no-properties (region-beginning) (region-end))))
(infinipaste--send-paste fname content)))
(provide 'infinipaste)
;;; infinipaste.el ends here

View file

@ -1,81 +0,0 @@
;;; tailpaste.el --- tailpaste client for Emacs -*- lexical-binding: t; -*-
;; Copyright (C)
;; 2023 Tailscale, Inc.
;; Author: Xe Iaso <xe@tailscale.com>
;; Maintainer: Xe Iaso <xe@tailscale.com>
;; Created: 2023-01-13
;; Version: 0.1
;; Keywords: tailscale, pastebin, sharing
;; Homepage: https://github.com/tailscale/paste
;;; Commentary:
;;
;; This uses request-el to make requests to your tailnet's tailpaste server. You
;; can install request-el with M-x package-install.
;;
;; This package requires that you have a tailpaste server set up. This package
;; reaches out to a tailpaste server over either plain HTTP, or HTTPS should you
;; configure the variable `tailpaste-server'.
;;
;; Usage:
;;
;; To submit the contents of the current buffer to tailpaste:
;; M-x tailpaste-submit-buffer
;; To submit the contents of the currently highlighted region to tailpaste:
;; M-x tailpaste-submit-region
;;
;; Customization:
;;
;; To customize the tailpaste server this package reaches out to:
;; M-x customize-group tailpaste
;;
;; You can customize the tailpaste server URL by changing the value of `tailpaste-server':
;; (setq tailpaste-server "https://paste.shark-harmonic.ts.net")
;;; Code:
(require 'request)
(defgroup tailpaste nil
"Tailpaste server configuration."
:prefix "tailpaste-"
:group 'tailpaste)
(defcustom tailpaste-server "http://paste"
"The server that is running tailpaste or a service with a compatible API to tailpaste. This should NOT end with a trailing slash."
:group 'tailpaste
:type 'string)
(defun tailpaste--send-paste (fname content)
"Internal function that actually fires off the paste with name FNAME and content CONTENT to the tailpaste server."
(request (format "%s/api/post" tailpaste-server)
:type "POST"
:data `(("filename" . ,fname)
("content" . ,content))
:headers '(("Accept" . "text/plain"))
:timeout 60
:success (cl-function
(lambda (&key response &allow-other-keys)
(message "%s" (request-response-data response))))))
(defun tailpaste-submit-buffer ()
"Submits the entire current buffer to tailpaste."
(interactive)
(let ((fname (format "%s.%s"
(file-name-base (buffer-file-name))
(file-name-extension (buffer-file-name))))
(content (buffer-string)))
(tailpaste--send-paste fname content)))
(defun tailpaste-submit-region ()
"Submits the highlighted region to tailpaste."
(interactive)
(let ((fname (format "%s.%s"
(file-name-base (buffer-file-name))
(file-name-extension (buffer-file-name))))
(content (buffer-substring-no-properties (region-beginning) (region-end))))
(tailpaste--send-paste fname content)))
(provide 'tailpaste)
;;; tailpaste.el ends here

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/tailscale/paste module github.com/tailscale-dev/infinipaste
go 1.19 go 1.19