Nyxt: Replace old handlers with url-dispatching-handlers.
parent
450daff855
commit
39a902d385
|
@ -49,36 +49,34 @@
|
|||
(defvar +youtube-dl-command+ "youtube-dl"
|
||||
"Path to the 'youtube-dl' program.")
|
||||
|
||||
(defun auto-yt-dl-handler (url)
|
||||
"Download a Youtube URL asynchronously to /tmp/videos/.
|
||||
Videos are downloaded with `+youtube-dl-command+'."
|
||||
(let ((uri (quri:uri url)))
|
||||
(when (and uri
|
||||
(member-string (quri:uri-domain uri) '("youtube.com" "youtu.be"))
|
||||
(string= (quri:uri-path uri) "/watch"))
|
||||
(log:info "Youtube: downloading ~a" url)
|
||||
(uiop:launch-program (list +youtube-dl-command+ url "-o" "/tmp/videos/%(title)s.%(ext)s"))))
|
||||
url)
|
||||
;; (defun auto-yt-dl-handler (url)
|
||||
;; "Download a Youtube URL asynchronously to /tmp/videos/.
|
||||
;; Videos are downloaded with `+youtube-dl-command+'."
|
||||
;; (let ((uri (quri:uri url)))
|
||||
;; (when (and uri
|
||||
;; (member-string (quri:uri-domain uri) '("youtube.com" "youtu.be"))
|
||||
;; (string= (quri:uri-path uri) "/watch"))
|
||||
;; (log:info "Youtube: downloading ~a" url)
|
||||
;; (uiop:launch-program (list +youtube-dl-command+ url "-o" "/tmp/videos/%(title)s.%(ext)s"))))
|
||||
;; url)
|
||||
|
||||
(defun old-reddit-handler (request-data)
|
||||
(let ((uri (url request-data)))
|
||||
(setf (url request-data)
|
||||
(if (search "reddit.com" (quri:uri-host uri))
|
||||
(progn
|
||||
(setf (quri:uri-host uri) "old.reddit.com")
|
||||
(log:info "Switching to old Reddit: ~s" (object-display uri))
|
||||
uri)
|
||||
uri)))
|
||||
request-data)
|
||||
(defparameter old-reddit-handler
|
||||
(url-dispatching-handler
|
||||
'old-reddit-dispatcher
|
||||
(match-host "www.reddit.com")
|
||||
(lambda (url)
|
||||
(quri:copy-uri url :host "old.reddit.com"))))
|
||||
|
||||
(defun magnet-handler (request-data)
|
||||
(let ((uri (url request-data)))
|
||||
(if (string= (quri:uri-scheme uri) "magnet")
|
||||
(progn
|
||||
(echo "Opened magnet link in Transmission.")
|
||||
(uiop:launch-program (list "transmission-remote" "--add" (object-string uri)))
|
||||
nil)
|
||||
request-data)))
|
||||
(defparameter magnet-handler
|
||||
(url-dispatching-handler
|
||||
'transmission-magnet-links
|
||||
(match-scheme "magnet")
|
||||
(lambda (url)
|
||||
(uiop:launch-program
|
||||
(list "transmission-remote" "--add"
|
||||
(object-string url)))
|
||||
(echo "Magnet link opened in Transmission.")
|
||||
nil)))
|
||||
|
||||
(defvar *my-unproxied-domains*
|
||||
'("jit.si"
|
||||
|
@ -105,24 +103,22 @@ Videos are downloaded with `+youtube-dl-command+'."
|
|||
(define-configuration nyxt/blocker-mode:blocker-mode
|
||||
((nyxt/blocker-mode:hostlists (append (list *my-blocked-hosts*) %slot-default))))
|
||||
|
||||
;; (define-mode my-blocker-mode (nyxt/blocker-mode:blocker-mode)
|
||||
;; "Blocker mode with custom hosts from `*my-blocked-hosts*'."
|
||||
;; ((nyxt/blocker-mode:hostlists :initform (list *my-blocked-hosts* nyxt/blocker-mode:*default-hostlist*))))
|
||||
(define-mode my-blocker-mode (nyxt/blocker-mode:blocker-mode)
|
||||
"Blocker mode with custom hosts from `*my-blocked-hosts*'."
|
||||
((nyxt/blocker-mode:hostlists :initform (list *my-blocked-hosts* nyxt/blocker-mode:*default-hostlist*))))
|
||||
|
||||
(define-configuration buffer
|
||||
((default-modes (append
|
||||
'(my-mode vi-normal-mode
|
||||
;; my-blocker-mode
|
||||
blocker-mode
|
||||
'(my-mode
|
||||
;; proxy-mode
|
||||
)
|
||||
;; blocker-mode
|
||||
my-blocker-mode
|
||||
vi-normal-mode)
|
||||
%slot-default))
|
||||
(request-resource-hook
|
||||
(reduce #'hooks:add-hook
|
||||
(mapcar #'make-handler-resource (list
|
||||
;; #'auto-proxy-handler
|
||||
#'magnet-handler
|
||||
#'old-reddit-handler))
|
||||
(list magnet-handler
|
||||
old-reddit-handler)
|
||||
:initial-value %slot-default))))
|
||||
|
||||
(defun format-c->lisp (s)
|
||||
|
|
Loading…
Reference in New Issue