diff options
author | bru <bru@texto-plano.xyz> | 2023-07-09 04:29:10 -0300 |
---|---|---|
committer | bru <bru@texto-plano.xyz> | 2023-07-09 04:29:10 -0300 |
commit | a94e0926b73a896848f7826b74d895bd87193ea6 (patch) | |
tree | 95b19ff2d7885424a5586a636cd92ac818bb7dd8 | |
parent | 8325b71ab5f3cfdd72b7dd9380689181c1f3012e (diff) | |
download | bbj-a94e0926b73a896848f7826b74d895bd87193ea6.tar.gz |
Ahora se puede publicar/editar contenido en UTF-8 :^)
-rw-r--r-- | clients/emacs/bbj.el | 115 |
1 files changed, 114 insertions, 1 deletions
diff --git a/clients/emacs/bbj.el b/clients/emacs/bbj.el index b240405..14a2a46 100644 --- a/clients/emacs/bbj.el +++ b/clients/emacs/bbj.el @@ -105,6 +105,117 @@ obnoxious things for the sake of education ;)") "Remove leading and trailing whitespace from STRING." (string-trim-left (string-trim-right string)))) +;; Más de 12 horas buscando una forma de rodear esta función, +;; cuando lo único que tenía que hacer era redifinirla +;; para mi propio favor. +;; Lección aprendida. Aguante Emacs Lisp. +(defun url-http-create-request () + (let* ((extra-headers) + (request nil) + (no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers))) + (using-proxy url-http-proxy) + (proxy-auth (if (or (cdr-safe (assoc "Proxy-Authorization" + url-http-extra-headers)) + (not using-proxy)) + nil + (let ((url-basic-auth-storage + 'url-http-proxy-basic-auth-storage)) + (url-get-authentication url-http-proxy nil 'any nil)))) + (real-fname (url-filename url-http-target-url)) + (host (url-host url-http-target-url)) + (auth (if (cdr-safe (assoc "Authorization" url-http-extra-headers)) + nil + (url-get-authentication (or + (and (boundp 'proxy-info) + proxy-info) + url-http-target-url) nil 'any nil))) + (ref-url (url-http--encode-string url-http-referer))) + (if (equal "" real-fname) + (setq real-fname "/")) + (setq no-cache (and no-cache (string-match "no-cache" no-cache))) + (if auth + (setq auth (concat "Authorization: " auth "\r\n"))) + (if proxy-auth + (setq proxy-auth (concat "Proxy-Authorization: " proxy-auth "\r\n"))) + (if (and ref-url (stringp ref-url) (or (string= ref-url "file:nil") + (string= ref-url ""))) + (setq ref-url nil)) + (setq extra-headers (mapconcat + (lambda (x) + (concat (car x) ": " (cdr x))) + url-http-extra-headers "\r\n")) + (if (not (equal extra-headers "")) + (setq extra-headers (concat extra-headers "\r\n"))) + (setq request + (concat + (or url-http-method "GET") " " + (url-http--encode-string + (if (and using-proxy + (not (equal "https" (url-type url-http-target-url)))) + (url-recreate-url url-http-target-url) real-fname)) + " HTTP/" url-http-version "\r\n" + "MIME-Version: 1.0\r\n" + "Connection: " (if (or using-proxy + (not url-http-attempt-keepalives)) + "close" "keep-alive") "\r\n" + (if url-extensions-header + (format + "Extension: %s\r\n" url-extensions-header)) + (if (/= (url-port url-http-target-url) + (url-scheme-get-property + (url-type url-http-target-url) 'default-port)) + (format + "Host: %s:%d\r\n" (url-http--encode-string + (puny-encode-domain host)) + (url-port url-http-target-url)) + (format "Host: %s\r\n" + (url-http--encode-string (puny-encode-domain host)))) + (if url-personal-mail-address + (concat + "From: " url-personal-mail-address "\r\n")) + (if (or url-mime-encoding-string + (and (eq 'system-type 'windows-nt) + (fboundp 'zlib-available-p) + (zlib-available-p) + (setq url-mime-encoding-string "gzip"))) + (concat + "Accept-encoding: " url-mime-encoding-string "\r\n")) + (if url-mime-charset-string + (concat + "Accept-charset: " + (url-http--encode-string url-mime-charset-string) + "\r\n")) + (if url-mime-language-string + (concat + "Accept-language: " url-mime-language-string "\r\n")) + "Accept: " (or url-mime-accept-string "*/*") "\r\n" + (url-http-user-agent-string) + proxy-auth + auth + (when (url-use-cookies url-http-target-url) + (url-http--encode-string + (url-cookie-generate-header-lines + host real-fname + (equal "https" (url-type url-http-target-url))))) + (if (and (not no-cache) + (member url-http-method '("GET" nil))) + (let ((tm (url-is-cached url-http-target-url))) + (if tm + (concat "If-modified-since: " + (url-get-normalized-date tm) "\r\n")))) + (if ref-url (concat + "Referer: " ref-url "\r\n")) + extra-headers + (if url-http-data + (concat + "Content-length: " (number-to-string + (string-bytes url-http-data)) ;; 1er cambio importante + "\r\n")) + "\r\n" + url-http-data)) + ;; 2do cambio importante: no hay excepción + (url-http-debug "Request is: \n%s" request) + request)) (cl-defun bbj-request (endpoint &rest params &aux alist) "Send an http request to the BBJ api. PARAMS can be pairs, where the @@ -699,7 +810,7 @@ Eso es todo por ahora. 'post_id ,post-id 'thread_id ,thread-id 'body message))) - (message "post edited") + (message "post editado") (bbj-enter-thread ,thread-id) (bbj-seek-post ,post-id))))) @@ -767,3 +878,5 @@ Eso es todo por ahora. (bbj-postprocess)) (switch-to-buffer buffer) (setq buffer-read-only t))) + +(provide 'bbj) |