[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste dacb4fb 289/298: Add support for bpa.st pastebin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste dacb4fb 289/298: Add support for bpa.st pastebin |
Date: |
Thu, 9 Dec 2021 19:00:31 -0500 (EST) |
branch: elpa/webpaste
commit dacb4fbcaa1be8dee117bf7ac1695565384c011b
Author: Dale Sedivec <dale@codefu.org>
Commit: Dale Sedivec <dale@codefu.org>
Add support for bpa.st pastebin
bpa.st runs software called pinnwand:
https://pinnwand.readthedocs.io/en/latest/index.html
This uses pinnwand's v1 API.
---
README.org | 1 +
tests/integration/test-webpaste-providers.el | 13 ++++++++++++-
webpaste.el | 25 ++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index 7414417..c7e5240 100644
--- a/README.org
+++ b/README.org
@@ -201,5 +201,6 @@ webpaste first and then just read the documentation by
running this:
- [ ] paste.debian.net
- [ ] bpaste.net
- [ ] eval.in
+ - [X] bpa.st
- [ ] ptpb.pw (RIP due to
[[https://github.com/ptpb/pb/issues/245][ptpb/pb#245]] &
[[https://github.com/ptpb/pb/issues/240][ptpb/pb#240]])
- [ ] sprunge.us (removed due to
[[https://github.com/rupa/sprunge/issues/45][sprunge#45]] that yields 500s)
diff --git a/tests/integration/test-webpaste-providers.el
b/tests/integration/test-webpaste-providers.el
index 5103582..4ee6814 100644
--- a/tests/integration/test-webpaste-providers.el
+++ b/tests/integration/test-webpaste-providers.el
@@ -80,7 +80,18 @@
(funcall (webpaste--get-provider-by-name "paste.pound-python.org")
paste-message :sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
- (expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)))
+ (expect (spy-calls-count 'webpaste--paste-text) :to-equal 0))
+
+
+ (it
+ "can paste with bpa.st [ci]"
+
+ (spy-on 'file-name-nondirectory :and-return-value "file.txt")
+
+ (funcall (webpaste--get-provider-by-name "bpa.st") paste-message :sync t)
+
+ (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
+ (expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)))
;;; test-webpaste-providers.el ends here
diff --git a/webpaste.el b/webpaste.el
index da89aa0..204dc26 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -155,7 +155,14 @@ This uses `browse-url-generic' to open URLs."
:post-field "code"
:post-lang-field-name "language"
:lang-overrides ((emacs-lisp-mode . "clojure"))
- :success-lambda webpaste--providers-success-response-url))
+ :success-lambda webpaste--providers-success-response-url)
+
+ ("bpa.st"
+ :uri "https://bpa.st/api/v1/paste";
+ :post-data (("expiry" . "1day"))
+ :post-field-lambda (lambda () #'webpaste--providers-pinnwand-request)
+ :lang-overrides ((emacs-lisp-mode . "emacs"))
+ :success-lambda (lambda () #'webpaste--providers-pinnwand-success)))
"Define all webpaste.el providers.
Consists of provider name and arguments to be sent to `webpaste--provider' when
@@ -300,6 +307,22 @@ This is the default failover hook that we use for most
providers."
;; Otherwise we return the formatted post data
post-data))))
+(cl-defun webpaste--providers-pinnwand-request (&key text post-data
provider-uri
+ &allow-other-keys)
+ "Build request for pinnwand pastebins."
+ (let* ((lexer (or (webpaste--get-buffer-language provider-uri) "text"))
+ (file `(("lexer" . ,lexer) ("content" . ,text)))
+ (file-name (buffer-file-name)))
+ (when file-name
+ (push (cons "name" (file-name-nondirectory file-name)) file))
+ (json-encode `((expiry . ,(or (cdr (assoc "expiry" post-data)) "1day"))
+ (files . ,(vector file))))))
+
+(cl-defun webpaste--providers-pinnwand-success (&key data &allow-other-keys)
+ "Parse JSON response from pinnwand pastebins in DATA."
+ (webpaste--return-url (cdr (assq 'link (json-read-from-string data)))))
+
+
(cl-defun webpaste--get-lang-alist-with-overrides (overrides)
- [nongnu] elpa/webpaste 356e54f 242/298: Tests: Add unit test for webpaste--get-shebang-lang-mode, (continued)
- [nongnu] elpa/webpaste 356e54f 242/298: Tests: Add unit test for webpaste--get-shebang-lang-mode, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b8e9245 230/298: Add helper function to find buffers language for provider, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste d6a8771 250/298: Merge branch 'vapniks-patch-1', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8f9322f 265/298: Merge branch 'tastytea-dpaste.de-new-location', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 2d0f810 268/298: Merge branch 'condy0919-master', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 141376a 264/298: Change dpaste.de to dpaste.org., ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 1a6c0e9 263/298: Bump version number in file, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7a30602 274/298: Bump version number in file, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 84b5c80 279/298: readme: Add readme entry for max retries, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 533bb40 290/298: Apply suggestions from code review, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste dacb4fb 289/298: Add support for bpa.st pastebin,
ELPA Syncer <=
- [nongnu] elpa/webpaste 9ffa782 286/298: readme: Useful links in badges, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste a60d262 285/298: readme: Add status badges, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 65f664d 298/298: elpaignore: Add .elpaignore to ignore files in elpa builds, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 76d740e 283/298: travis: Drop travis, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 935eb5f 195/298: Remove :tangle yes from README, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 5c63d75 196/298: Added unit test for running hooks on return, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6114da7 208/298: Refactor how integration tests are triggered, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 9d026d6 212/298: Remove emacs-24.3 from build target, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste cf2ea41 218/298: Update heading levels and add a TOC, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7c3bc88 215/298: Remove unused local variable, ELPA Syncer, 2021/12/09