1
0
Fork 0

- added code to perform a search of gemspace, when the software is unable to understand the input typed in the address bar.

This commit is contained in:
cage 2024-05-29 17:10:56 +02:00
parent c84e747868
commit 4de0de1e2c
1 changed files with 17 additions and 2 deletions

View File

@ -968,7 +968,11 @@ local file paths."
((fs:directory-exists-p path)
(gui:choose-directory :initial-dir path :parent main-window :mustexist t))
(t
(gui-goodies:notify-request-error (format nil (_ "No such file or directory: ~a") path)))))
(when (gui:ask-yesno (format nil (_ "No such file or directory: ~s, search genspace instead?")
path)
:title (_ "Error")
:parent main-window)
(open-search-iri path main-window)))))
(defun render-gemtext-string (main-window parsed-lines &key (links-path-prefix ""))
(ev:with-enqueued-process-and-unblock ()
@ -1032,6 +1036,14 @@ local file paths."
(otherwise
(render-line rendered-line))))))))))))
(defun open-search-iri (criteria main-window)
(let ((parsed-iri-search-capsule (iri:iri-parse constants:+gemini-search-engine+)))
(setf (uri:query parsed-iri-search-capsule)
(text-utils:maybe-percent-encode criteria))
(let ((search-iri (with-output-to-string (stream)
(iri:render-iri parsed-iri-search-capsule stream))))
(open-iri search-iri main-window nil))))
(defun open-iri (iri main-window use-cache &key (status +stream-status-streaming+))
(handler-case
(let* ((actual-iri (remove-standard-port iri))
@ -1068,7 +1080,10 @@ local file paths."
(client-os-utils:open-resource-with-external-program main-window actual-iri))))
(esrap:esrap-parse-error (e)
(declare (ignore e))
(gui-goodies:notify-request-error (format nil (_ "Invalid address: ~s") iri)))
(when (gui:ask-yesno (_ "Invalid address, perform a search using your input?")
:title (_ "Invalid address")
:parent main-window)
(open-search-iri iri main-window)))
(error (e)
(gui-goodies:notify-request-error e))))