mirror of
https://codeberg.org/cage/tinmop/
synced 2024-12-30 00:39:54 +01:00
- [gemini] percent encoded paths when exploring local filesystems.
This commit is contained in:
parent
f1c8ec0ec1
commit
d7f074aa34
@ -71,8 +71,9 @@
|
|||||||
*open-message-link-window*))
|
*open-message-link-window*))
|
||||||
|
|
||||||
(defun open-message-link (url enqueue)
|
(defun open-message-link (url enqueue)
|
||||||
(let* ((parsed (iri:iri-parse url))
|
(let* ((parsed (iri:iri-parse url))
|
||||||
(scheme (uri:scheme parsed)))
|
(scheme (uri:scheme parsed))
|
||||||
|
(decoded-path (percent-decode url)))
|
||||||
(cond
|
(cond
|
||||||
((string= gemini-constants:+gemini-scheme+ scheme)
|
((string= gemini-constants:+gemini-scheme+ scheme)
|
||||||
(let ((program-events:*process-events-immediately* t)
|
(let ((program-events:*process-events-immediately* t)
|
||||||
@ -84,14 +85,14 @@
|
|||||||
(program-events:push-event event)
|
(program-events:push-event event)
|
||||||
(gemini-viewer:request url :enqueue enqueue
|
(gemini-viewer:request url :enqueue enqueue
|
||||||
:use-cached-file-if-exists t)))
|
:use-cached-file-if-exists t)))
|
||||||
((fs:dirp url)
|
((fs:dirp decoded-path)
|
||||||
(let ((program-events:*process-events-immediately* t)
|
(let ((program-events:*process-events-immediately* t)
|
||||||
(event (make-instance 'program-events:gemini-push-behind-downloading-event
|
(event (make-instance 'program-events:gemini-push-behind-downloading-event
|
||||||
:priority program-events:+maximum-event-priority+)))
|
:priority program-events:+maximum-event-priority+)))
|
||||||
(program-events:push-event event)
|
(program-events:push-event event)
|
||||||
(gemini-viewer:load-gemini-url url :give-focus-to-message-window nil)))
|
(gemini-viewer:load-gemini-url decoded-path :give-focus-to-message-window nil)))
|
||||||
(t
|
(t
|
||||||
(os-utils:open-resource-with-external-program url nil)))))
|
(os-utils:open-resource-with-external-program decoded-path nil)))))
|
||||||
|
|
||||||
(defclass open-links-window ()
|
(defclass open-links-window ()
|
||||||
((links
|
((links
|
||||||
|
@ -1005,10 +1005,13 @@
|
|||||||
|
|
||||||
(defmethod process-event ((object gemini-request-event))
|
(defmethod process-event ((object gemini-request-event))
|
||||||
(tui:with-notify-errors
|
(tui:with-notify-errors
|
||||||
(with-accessors ((url url)
|
(with-accessors ((url url) ; if a local file *not* percent encoded
|
||||||
(give-focus-to-message-window-p give-focus-to-message-window-p)
|
(give-focus-to-message-window-p give-focus-to-message-window-p)
|
||||||
(use-cached-file-if-exists use-cached-file-if-exists)) object
|
(use-cached-file-if-exists use-cached-file-if-exists)) object
|
||||||
(let ((window specials:*message-window*))
|
(let ((window specials:*message-window*)
|
||||||
|
(local-path (if (text-utils:percent-encoded-p url)
|
||||||
|
(text-utils:percent-decode url)
|
||||||
|
url)))
|
||||||
(setf (windows:keybindings window)
|
(setf (windows:keybindings window)
|
||||||
keybindings:*gemini-message-keymap*)
|
keybindings:*gemini-message-keymap*)
|
||||||
(when give-focus-to-message-window-p
|
(when give-focus-to-message-window-p
|
||||||
@ -1016,8 +1019,8 @@
|
|||||||
(cond
|
(cond
|
||||||
((gemini-client:absolute-gemini-url-p url)
|
((gemini-client:absolute-gemini-url-p url)
|
||||||
(gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists))
|
(gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists))
|
||||||
((fs:dirp url)
|
((fs:dirp local-path)
|
||||||
(let* ((index-path (uri:normalize-path (fs:prepend-pwd url)))
|
(let* ((index-path (uri:normalize-path (fs:prepend-pwd local-path)))
|
||||||
(all-paths (mapcar #'uri:normalize-path
|
(all-paths (mapcar #'uri:normalize-path
|
||||||
(fs:collect-children index-path)))
|
(fs:collect-children index-path)))
|
||||||
(raw-text (with-output-to-string (stream)
|
(raw-text (with-output-to-string (stream)
|
||||||
@ -1031,10 +1034,11 @@
|
|||||||
(dir-symbol (swconf:directory-symbol))
|
(dir-symbol (swconf:directory-symbol))
|
||||||
(link-label (if dirp
|
(link-label (if dirp
|
||||||
(text-utils:strcat path " " dir-symbol)
|
(text-utils:strcat path " " dir-symbol)
|
||||||
path)))
|
path))
|
||||||
|
(encoded-path (gemini-client::percent-encode-path path)))
|
||||||
(format stream
|
(format stream
|
||||||
"~a~%"
|
"~a~%"
|
||||||
(gemini-parser:make-gemini-link path
|
(gemini-parser:make-gemini-link encoded-path
|
||||||
link-label))))))
|
link-label))))))
|
||||||
(parsed (gemini-parser:parse-gemini-file raw-text))
|
(parsed (gemini-parser:parse-gemini-file raw-text))
|
||||||
(links (gemini-parser:sexp->links parsed
|
(links (gemini-parser:sexp->links parsed
|
||||||
@ -1049,8 +1053,8 @@
|
|||||||
(refresh-gemini-message-window links raw-text text nil)
|
(refresh-gemini-message-window links raw-text text nil)
|
||||||
(windows:draw window)))
|
(windows:draw window)))
|
||||||
(t
|
(t
|
||||||
(let* ((file-string (fs:slurp-file url))
|
(let* ((file-string (fs:slurp-file local-path))
|
||||||
(parent-dir (fs:parent-dir-path url))
|
(parent-dir (fs:parent-dir-path local-path))
|
||||||
(parsed (gemini-parser:parse-gemini-file file-string))
|
(parsed (gemini-parser:parse-gemini-file file-string))
|
||||||
(links (gemini-parser:sexp->links parsed
|
(links (gemini-parser:sexp->links parsed
|
||||||
nil
|
nil
|
||||||
@ -1060,7 +1064,7 @@
|
|||||||
(text (gemini-parser:sexp->text parsed
|
(text (gemini-parser:sexp->text parsed
|
||||||
gemini-client:*gemini-page-theme*)))
|
gemini-client:*gemini-page-theme*)))
|
||||||
(gemini-viewer:maybe-initialize-metadata window)
|
(gemini-viewer:maybe-initialize-metadata window)
|
||||||
(gemini-viewer:add-url-to-history window url)
|
(gemini-viewer:add-url-to-history window local-path)
|
||||||
(refresh-gemini-message-window links file-string text nil)
|
(refresh-gemini-message-window links file-string text nil)
|
||||||
(windows:draw window))))))))
|
(windows:draw window))))))))
|
||||||
|
|
||||||
|
@ -1778,7 +1778,7 @@ open-message-link-window:open-message-link"
|
|||||||
(defun open-gemini-address ()
|
(defun open-gemini-address ()
|
||||||
"Ask for a gemini address and try to load it"
|
"Ask for a gemini address and try to load it"
|
||||||
(flet ((on-input-complete (url)
|
(flet ((on-input-complete (url)
|
||||||
(gemini-viewer:load-gemini-url url
|
(gemini-viewer:load-gemini-url (trim-blanks url)
|
||||||
:use-cached-file-if-exists t
|
:use-cached-file-if-exists t
|
||||||
:priority program-events:+maximum-event-priority+)))
|
:priority program-events:+maximum-event-priority+)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user