diff options
author | Thanos Apollo <[email protected]> | 2024-02-07 18:02:29 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-02-07 18:02:29 +0200 |
commit | 8ecf80c4f105f3b48f627e21d12108640a97a0d4 (patch) | |
tree | 34001cbe7568c46453ff8cb4166ae8d569c02b7b | |
parent | 7c34a8c32a83bc094b824f5ec3f0a9bc6aa87385 (diff) |
nyxt: Add old-reddit handler & fix typos
-rw-r--r-- | .config/nyxt/config.lisp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/.config/nyxt/config.lisp b/.config/nyxt/config.lisp index 6540815..eb70295 100644 --- a/.config/nyxt/config.lisp +++ b/.config/nyxt/config.lisp @@ -17,7 +17,7 @@ Extension files (like dark-reader.lisp) are to append to this list. Why the variable? Because it's too much hassle copying it everywhere.") (define-nyxt-user-system-and-load nyxt-user/basic-config - :components ("keys" "colors" "commands")) + :components ("keys" "style" "commands")) (define-configuration (:modable-buffer :prompt-buffer :editor-buffer) "Set up Emacs keybindings everywhere possible." @@ -52,3 +52,54 @@ Upstream Nyxt doesn't have it because it may break some websites.") (preferred-user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" :doc "Mimic Chrome on MacOS."))) + + +(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 old-reddit-handler (request-data) + (let ((url (url request-data))) + (setf (url request-data) + (if (search "reddit.com" (quri.uri:uri-host url)) + (progn + (setf (quri.uri:uri-host url) "old.reddit.com") + (log:info "Switching to old Reddit: ~s" + (render-url url)) + url) + url))) + request-data) + +(url-dispatching-handler 'old-reddit-handler ) + + +(define-configuration web-buffer + (request-resource-hook + (hooks:add-hook %slot-value% + (url-dispatching-handler + 'doi-link-dispatcher + (match-scheme "doi") + (lambda (url) + (quri:uri (format nil "https://www.reddit.com/~a" + (quri:uri-path url)))))))) + +(defmethod customize-instance ((buffer web-buffer)) + (hooks:add-hook + (request-resource-hook buffer) + (url-dispatching-handler + 'transmission-magnet-links + (match-scheme "magnet") + "transmission-remote --add ~a")) + (hooks:add-hook + (request-resource-hook buffer) + (url-dispatching-handler + 'emacs-file + (match-scheme "file") + (lambda (url) + (uiop:launch-program + `("emacs" ,(quri:uri-path url))) + nil)))) |