mirror of https://codeberg.org/cage/tinmop/
- added bookmarking of gopher addresses.
This commit is contained in:
parent
60f33d81a9
commit
6481a323f7
|
@ -766,6 +766,12 @@
|
|||
|
||||
(define-key "b" #'gemini-history-back *gopher-keymap*)
|
||||
|
||||
(define-key "C-b a" #'bookmark-gopher-page *gopher-keymap*)
|
||||
|
||||
(define-key "C-b s" #'display-bookmark *gopher-keymap*)
|
||||
|
||||
(define-key "C-b d" #'delete-gemini-bookmark *gopher-keymap*)
|
||||
|
||||
;;;; hooks
|
||||
|
||||
;; this module will install an hook to rewrite urls; By default it
|
||||
|
|
|
@ -27,6 +27,16 @@
|
|||
:accessor page-type
|
||||
:documentation "The type of the page , 0,1,2,i etc.")))
|
||||
|
||||
(defun gopher-window-p (w)
|
||||
(typep w 'gopher-window))
|
||||
|
||||
(defun current-gopher-url ()
|
||||
(when (gopher-window-p specials:*gopher-window*)
|
||||
(a:when-let* ((metadata (message-window:metadata specials:*message-window*))
|
||||
(history (gemini-viewer:gemini-metadata-history metadata))
|
||||
(link (a:last-elt history)))
|
||||
link)))
|
||||
|
||||
(defmethod refresh-config :after ((object gopher-window))
|
||||
(refresh-config-colors object swconf:+key-gopher-window+)
|
||||
(let* ((height (win-height *message-window*))
|
||||
|
|
|
@ -75,25 +75,29 @@
|
|||
|
||||
(defun open-message-link (url enqueue)
|
||||
(tui-utils:with-notify-errors
|
||||
(let* ((parsed (iri:iri-parse url))
|
||||
(scheme (uri:scheme parsed))
|
||||
(decoded-path (percent-decode url)))
|
||||
(when (and (not enqueue)
|
||||
(swconf:close-link-window-after-select-p))
|
||||
(ui:close-open-message-link-window))
|
||||
(cond
|
||||
((string= gemini-constants:+gemini-scheme+ scheme)
|
||||
(db:insert-in-history (ui:open-url-prompt) url)
|
||||
(db:gemlog-mark-as-seen url)
|
||||
(gemini-viewer:ensure-just-one-stream-rendering)
|
||||
(gemini-viewer:load-gemini-url url
|
||||
:give-focus-to-message-window t
|
||||
:enqueue enqueue
|
||||
:use-cached-file-if-exists t))
|
||||
((fs:dirp decoded-path)
|
||||
(ui:open-file-explorer decoded-path))
|
||||
(t
|
||||
(os-utils:open-resource-with-external-program decoded-path nil))))))
|
||||
(if (text-utils:string-starts-with-p gopher-parser:+gopher-scheme+ url)
|
||||
(multiple-value-bind (host port type selector)
|
||||
(gopher-parser:parse-iri url)
|
||||
(gopher-window::make-request host port type selector))
|
||||
(let* ((parsed (iri:iri-parse url))
|
||||
(scheme (uri:scheme parsed))
|
||||
(decoded-path (percent-decode url)))
|
||||
(when (and (not enqueue)
|
||||
(swconf:close-link-window-after-select-p))
|
||||
(ui:close-open-message-link-window))
|
||||
(cond
|
||||
((string= gemini-constants:+gemini-scheme+ scheme)
|
||||
(db:insert-in-history (ui:open-url-prompt) url)
|
||||
(db:gemlog-mark-as-seen url)
|
||||
(gemini-viewer:ensure-just-one-stream-rendering)
|
||||
(gemini-viewer:load-gemini-url url
|
||||
:give-focus-to-message-window t
|
||||
:enqueue enqueue
|
||||
:use-cached-file-if-exists t))
|
||||
((fs:dirp decoded-path)
|
||||
(ui:open-file-explorer decoded-path))
|
||||
(t
|
||||
(os-utils:open-resource-with-external-program decoded-path nil)))))))
|
||||
|
||||
(defclass open-links-window ()
|
||||
((links
|
||||
|
|
|
@ -2292,6 +2292,8 @@
|
|||
(:a :alexandria))
|
||||
(:export
|
||||
:gopher-window
|
||||
:gopher-window-p
|
||||
:current-gopher-url
|
||||
:go-to-next-link
|
||||
:go-to-previous-link
|
||||
:open-menu-link
|
||||
|
@ -2908,6 +2910,7 @@
|
|||
:ask-input-on-tofu-error
|
||||
:import-gemini-certificate
|
||||
:bookmark-gemini-page
|
||||
:bookmark-gopher-page
|
||||
:display-bookmark
|
||||
:delete-gemini-bookmark
|
||||
:display-latest-visited-urls
|
||||
|
|
|
@ -1124,6 +1124,7 @@
|
|||
(refresh-gemini-message-window links page-data ir-text nil)
|
||||
(ui:open-gemini-toc)
|
||||
(ui:open-gemini-message-link-window :give-focus nil :enqueue t)
|
||||
(ui:focus-to-message-window)
|
||||
(windows:draw window)))))
|
||||
|
||||
(defclass gemini-request-event (program-event)
|
||||
|
|
|
@ -2577,6 +2577,34 @@ gemini page the program is rendering."
|
|||
:prompt (format nil (_ "Insert certificate file: "))
|
||||
:complete-fn #'complete:directory-complete))))
|
||||
|
||||
(defun bookmark-gopher-page ()
|
||||
(cond
|
||||
((not (gopher-window:gopher-window-p specials:*gopher-window*))
|
||||
(error-message (_ "The window is not displaying a gopher document")))
|
||||
((not (gopher-window:current-gopher-url))
|
||||
(error-message (_ "This page can not be added to bookmarks")))
|
||||
(t
|
||||
(let* ((link (gopher-window:current-gopher-url))
|
||||
(description (_ "No description")))
|
||||
(labels ((on-description-completed (new-description)
|
||||
(if (text-utils:string-empty-p new-description)
|
||||
(error-message (_ "Empty description"))
|
||||
(progn
|
||||
(setf description new-description)
|
||||
(ui:ask-string-input #'on-section-completed
|
||||
:prompt (format nil (_ "Insert bookmark section: "))
|
||||
:complete-fn #'complete:bookmark-section-complete))))
|
||||
(on-section-completed (section)
|
||||
(db-utils:with-ready-database (:connect nil)
|
||||
(db:bookmark-add db:+bookmark-gemini-type-entry+
|
||||
link
|
||||
:section section
|
||||
:description description))
|
||||
(notify (format nil (_ "Added ~s in bookmark") link))))
|
||||
(ui:ask-string-input #'on-description-completed
|
||||
:prompt (format nil (_ "Insert bookmark description: "))
|
||||
:initial-value description))))))
|
||||
|
||||
(defun bookmark-gemini-page ()
|
||||
(cond
|
||||
((not (message-window:gemini-window-p))
|
||||
|
|
Loading…
Reference in New Issue