Added support for custom handler of how to build the post data for providers

master
Elis Axelsson 9 years ago
parent 69f9452003
commit 6ea53d0e67
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 17
      webpaste.el

@ -91,6 +91,14 @@ each run.")
(replace-regexp-in-string "\n$" "" data)))))
"Predefined success callback for providers returning a string with URL.")
(defvar webpaste/providers-default-post-field-lambda
(lambda (text post-field post-data)
(cl-pushnew (cons post-field text) post-data)
post-data)
"Predefined lambda for building post fields.")
(cl-defun webpaste-provider (&key uri
@ -99,6 +107,7 @@ each run.")
(post-data '())
(sync nil)
post-field
(post-field-lambda webpaste/providers-default-post-field-lambda)
error-lambda
success-lambda)
"Function to create the lambda function for a provider.
@ -115,6 +124,9 @@ Usage:
:post-field Name of the field to insert the code into.
:sync Set to t to wait until request is done. Defaults to nil. This
should only be used for debugging purposes.
:post-field-lambda Function that builds and returns the post data that should be
sent to the provider. It should accept the parameter TEXT
only which contains the content that should be sent.
:success-lambda Callback sent to `request', look up how to write these in the
documentation for `request'.
:error-lambda Callback sent to `request', look up how to write these in the
@ -126,13 +138,10 @@ Usage:
"Paste TEXT to provider"
(prog1 nil
;; Local variable post-data
(cl-pushnew (cons post-field text) post-data)
;; Do request
(request uri
:type type
:data post-data
:data (funcall post-field-lambda text post-field post-data)
:parser parser
:success success-lambda
:sync sync

Loading…
Cancel
Save