From 786775f106a9e5278a7ff1bad2fe7d500e3c4e7d Mon Sep 17 00:00:00 2001 From: cage Date: Mon, 8 May 2023 20:34:39 +0200 Subject: [PATCH] - added 'iri:iri='; - jumping to the corresponding feature when typing in the adderss bar a special iri (e.g. 'about:bookmark'). --- src/gui/client/main-window.lisp | 6 ++++- src/iri-parser.lisp | 40 +++++++++++++++++++++++++++++++++ src/package.lisp | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 96465a2..e21a585 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -576,7 +576,11 @@ (handler-case (let ((parsed-iri (iri:iri-parse iri))) (cond - ((gemini-parser:gemini-iri-p iri) + ((iri:iri= iri (internal-iri-bookmark)) + (funcall (menu:show-bookmarks-clsr main-window))) + ((iri:iri= iri (internal-iri-gemlogs)) + (menu:manage-gemlogs)) + ((gemini-parser:gemini-iri-p iri) (start-stream-iri iri main-window use-cache status)) ((or (null (uri:scheme parsed-iri)) (string= (uri:scheme parsed-iri) diff --git a/src/iri-parser.lisp b/src/iri-parser.lisp index b2bbc4c..15a9c54 100644 --- a/src/iri-parser.lisp +++ b/src/iri-parser.lisp @@ -378,3 +378,43 @@ :port (uri:port parsed-iri) :path parent-path)))) new-iri)) + +(defgeneric iri= (a b)) + +(defmethod iri= ((a iri) (b iri)) + (let ((scheme-a (uri:scheme a)) + (user-info-a (uri:user-info a)) + (host-a (uri:host a)) + (port-a (uri:port a)) + (path-a (uri:path a)) + (query-a (uri:query a)) + (fragment-a (uri:fragment a)) + (scheme-b (uri:scheme b)) + (user-info-b (uri:user-info b)) + (host-b (uri:host b)) + (port-b (uri:port b)) + (path-b (uri:path b)) + (query-b (uri:query b)) + (fragment-b (uri:fragment b))) + (and (string= scheme-a scheme-b) + (string= user-info-a user-info-b) + (string= host-a host-b) + (string= port-a port-b) + (string= path-a path-b) + (string= query-a query-b) + (string= fragment-a fragment-b)))) + +(defmethod iri= ((a iri) (b string)) + (when-let ((parsed (iri-parse b :null-on-error t))) + (iri= a parsed))) + +(defmethod iri= ((a string) (b iri)) + (when-let ((parsed (iri-parse a :null-on-error t))) + (iri= b parsed))) + +(defmethod iri= ((a string) (b string)) + (let ((parsed-a (iri-parse a :null-on-error t)) + (parsed-b (iri-parse b :null-on-error t))) + (and parsed-a + parsed-b + (iri= parsed-a parsed-b)))) diff --git a/src/package.lisp b/src/package.lisp index e3f6663..7102898 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -756,6 +756,7 @@ :render-iri :make-iri :iri-parse + :iri= :normalize-path :absolute-url-p :ipv4-address-p