Handle all image types properly, also handle urls by passing them to xdg-open - holymoly - A tor enabled gopher client written in CHICKEN scheme
(HTM) git clone git://vernunftzentrum.de/holymoly.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit fc19f05807570a187fe76eb6051b721cd2eb95da
(DIR) parent bd2c6f35b61ce2fa3ad044f44f2613cbd4065f7c
(HTM) Author: Christian Kellermann <ckeen@pestilenz.org>
Date: Fri, 3 Aug 2018 10:44:29 +0200
Handle all image types properly, also handle urls by passing them to xdg-open
Diffstat:
holymoly.scm | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
---
(DIR) diff --git a/holymoly.scm b/holymoly.scm
@@ -207,7 +207,8 @@
("+" . redundant-server)
("T" . tn3270-session)
("g" . gif)
- ("I" . image)))
+ ("I" . image)
+ ("h" . url)))
(define (swap pair) (cons (cdr pair) (car pair)))
@@ -239,12 +240,14 @@
(sprintf " > ~a" (entry-title e)))))
(define (xdg-open r)
- (let-values (((fd temp-path) (file-mkstemp "/tmp/mytemporary.XXXXXX")))
- (let ((temp-port (open-output-file* fd)))
- (write-u8vector r temp-port)
- (close-output-port temp-port))
- (process "xdg-open" (list temp-path))
- (previous-page)))
+ (if (string? r)
+ (process "xdg-open" (list (string-join (cdr (string-split r ":")) ":")))
+ (let-values (((fd temp-path) (file-mkstemp "/tmp/mytemporary.XXXXXX")))
+ (let ((temp-port (open-output-file* fd)))
+ (write-u8vector r temp-port)
+ (close-output-port temp-port))
+ (process "xdg-open" (list temp-path))))
+ (previous-page))
(define history '())
@@ -293,6 +296,9 @@
(previous-page)))
(define (select-entry e)
+ (when (equal? (entry-type e) 'url)
+ (xdg-open (entry-selector e))
+ (select-entry (current-page)))
(when (and (equal? (entry-type e) 'index-search)
(= 1) (length (string-split (entry-selector e) "?")))
(let* ((query (get-user-input))
@@ -302,7 +308,7 @@
(entry-selector-set! e (string-append (car (string-split old-selector "?")) "?" (string-intersperse (string-split query) "+"))))))
(unless (equal? e (current-page))
(push! e history))
- (let* ((res (request-resource (entry-host e) (entry-selector e) (entry-port e) (memq (entry-type e) '(dos-archive binary gif))))
+ (let* ((res (request-resource (entry-host e) (entry-selector e) (entry-port e) (memq (entry-type e) '(dos-archive binary gif image))))
(handler (or
(alist-ref (entry-type e) type-handlers)
(lambda (c) (save-selector e c))))