Next: Use new request-data-based handlers for request-resource-hook.
parent
10752ba224
commit
4e64e16486
|
@ -60,29 +60,33 @@ Videos are downloaded with `+youtube-dl-command+'."
|
||||||
(uiop:launch-program (list +youtube-dl-command+ url "-o" "/tmp/videos/%(title)s.%(ext)s"))))
|
(uiop:launch-program (list +youtube-dl-command+ url "-o" "/tmp/videos/%(title)s.%(ext)s"))))
|
||||||
url)
|
url)
|
||||||
|
|
||||||
(defun old-reddit-handler (url)
|
(defun old-reddit-handler (request-data)
|
||||||
(let* ((uri (quri:uri url)))
|
(let* ((url (url request-data))
|
||||||
(if (search "reddit.com" (quri:uri-host uri))
|
(uri (quri:uri url)))
|
||||||
(progn
|
(setf (url request-data)
|
||||||
(setf (quri:uri-host uri) "old.reddit.com")
|
(if (search "reddit.com" (quri:uri-host uri))
|
||||||
(let ((new-url (quri:render-uri uri)))
|
(progn
|
||||||
(log:info "Switching to old Reddit: ~a" new-url)
|
(setf (quri:uri-host uri) "old.reddit.com")
|
||||||
new-url))
|
(let ((new-url (quri:render-uri uri)))
|
||||||
url)))
|
(log:info "Switching to old Reddit: ~a" new-url)
|
||||||
|
new-url))
|
||||||
|
url)))
|
||||||
|
request-data)
|
||||||
|
|
||||||
(defvar *my-unproxied-domains*
|
(defvar *my-unproxied-domains*
|
||||||
'("jit.si"
|
'("jit.si"
|
||||||
"steampowered.com"))
|
"steampowered.com"))
|
||||||
|
|
||||||
(defun auto-proxy-handler (url)
|
(defun auto-proxy-handler (request-data)
|
||||||
(let* ((uri (quri:uri url))
|
(let* ((url (url request-data))
|
||||||
|
(uri (quri:uri url))
|
||||||
(domain (and uri (quri:uri-domain uri))))
|
(domain (and uri (quri:uri-domain uri))))
|
||||||
;; TODO: Turn on/off proxy, not mode.
|
;; TODO: Turn on/off proxy, not mode.
|
||||||
(when domain
|
(when domain
|
||||||
(next/proxy-mode:proxy-mode
|
(next/proxy-mode:proxy-mode
|
||||||
:activate
|
:activate
|
||||||
(not (member-string domain *my-unproxied-domains*)))))
|
(not (member-string domain *my-unproxied-domains*)))))
|
||||||
url)
|
request-data)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
@ -104,12 +108,14 @@ Videos are downloaded with `+youtube-dl-command+'."
|
||||||
'(my-mode vi-normal-mode
|
'(my-mode vi-normal-mode
|
||||||
;; my-blocker-mode
|
;; my-blocker-mode
|
||||||
blocker-mode
|
blocker-mode
|
||||||
proxy-mode)
|
;; proxy-mode
|
||||||
|
)
|
||||||
%slot-default))
|
%slot-default))
|
||||||
(load-hook (hooks:make-hook-string->string
|
;; (request-resource-hook
|
||||||
:handlers (list #'old-reddit-handler
|
;; (reduce #'hooks:add-hook
|
||||||
#'auto-proxy-handler)
|
;; (mapcar #'make-handler-resource (list #'old-reddit-handler #'auto-proxy-handler))
|
||||||
:combination #'hooks:combine-composed-hook))))
|
;; :initial-value %slot-default))
|
||||||
|
))
|
||||||
|
|
||||||
(defmacro with-maybe-gpg-file ((stream filespec) &body body)
|
(defmacro with-maybe-gpg-file ((stream filespec) &body body)
|
||||||
"Evaluate BODY with STREAM bound to FILESPEC.
|
"Evaluate BODY with STREAM bound to FILESPEC.
|
||||||
|
|
Loading…
Reference in New Issue