From c9d9559f1a4ec7e1c61cfcca3e1d74cb0efd0e76 Mon Sep 17 00:00:00 2001 From: cage Date: Thu, 17 Dec 2020 13:56:07 +0100 Subject: [PATCH] - changed 'uri' to 'iri' where does makes sense to me. --- src/complete.lisp | 2 +- src/gemini-viewer.lisp | 68 +++++++++++++++++------------------ src/gemini/client.lisp | 10 +++--- src/gemini/gemini-parser.lisp | 22 ++++++------ src/gemini/package.lisp | 4 +-- src/package.lisp | 4 +-- src/program-events.lisp | 22 ++++++------ src/ui-goodies.lisp | 12 +++---- 8 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/complete.lisp b/src/complete.lisp index 9178f90..861e92a 100644 --- a/src/complete.lisp +++ b/src/complete.lisp @@ -152,7 +152,7 @@ list af all possible candidtae for completion." (with-simple-complete conversation-folder db:all-conversation-folders) -(defun make-complete-gemini-uri-fn (prompt) +(defun make-complete-gemini-iri-fn (prompt) (lambda (hint) (when-let ((matched (remove-if-not (starts-with-clsr hint) (funcall #'db:history-prompt->values prompt)))) diff --git a/src/gemini-viewer.lisp b/src/gemini-viewer.lisp index aeb5b41..88df9bf 100644 --- a/src/gemini-viewer.lisp +++ b/src/gemini-viewer.lisp @@ -28,8 +28,8 @@ (pushnew stream-object *gemini-streams-db* :test (lambda (a b) - (string= (download-uri a) - (download-uri b)))) + (string= (download-iri a) + (download-iri b)))) *gemini-streams-db*) (defun remove-db-stream (stream-object) @@ -48,7 +48,7 @@ (find-if predicate *gemini-streams-db*)) (defun find-db-stream-url (url) - (find-db-stream-if (lambda (a) (string= (download-uri a) url)))) + (find-db-stream-if (lambda (a) (string= (download-iri a) url)))) (defun ensure-just-one-stream-rendering () (with-lock (*gemini-db-streams-lock*) @@ -63,8 +63,8 @@ ;; it will force displaying of gemini cached file on the screen (setf (stream-status stream-object) :rendering)) -(defun db-entry-to-foreground (uri) - (when-let* ((stream-object (find-db-stream-url uri))) +(defun db-entry-to-foreground (iri) + (when-let* ((stream-object (find-db-stream-url iri))) (with-accessors ((support-file support-file) (meta meta)) stream-object (if (gemini-client:mime-gemini-p meta) @@ -87,10 +87,10 @@ (stream-status :initform nil :initarg :stream-status) - (download-uri + (download-iri :initform nil - :initarg :download-uri - :accessor download-uri) + :initarg :download-iri + :accessor download-iri) (start-time :initform (db-utils:local-time-obj-now) :initarg :start-time @@ -144,7 +144,7 @@ (print-unreadable-object (object stream :type t :identity t) (format stream "~a ~d ~a ~a" - (download-uri object) + (download-iri object) (octect-count object) (meta object) (stream-status object)))) @@ -160,7 +160,7 @@ (color-re (swconf:color-regexps)) (fitted-line (format nil "~a ~d ~a ~a" - (pad (download-uri object) url-w) + (pad (download-iri object) url-w) (pad (to-s (octect-count object)) octect-count-w) (pad (meta object) meta-w) @@ -213,11 +213,11 @@ (with-accessors ((start-time start-time) (thread thread) (stream-status stream-status) - (download-uri download-uri)) object + (download-iri download-iri)) object (setf thread (bt:make-thread function)) (setf start-time (db-utils:local-time-obj-now)) - (setf download-uri (gemini-parser:make-gemini-uri host path query port)) + (setf download-iri (gemini-parser:make-gemini-iri host path query port)) object)) (defclass gemini-file-stream (gemini-stream) ()) @@ -259,7 +259,7 @@ (incf octect-count data))) (defun make-gemini-download-event (src-data stream-object append-text) - (with-accessors ((download-uri download-uri) + (with-accessors ((download-iri download-iri) (host host) (port port) (path path) @@ -272,7 +272,7 @@ status-code-description meta parsed - download-uri + download-iri src-data links))) (make-instance 'program-events:gemini-got-line-event @@ -291,7 +291,7 @@ (program-events:push-event line-event)))) (lambda () (with-open-support-file (file-stream support-file character) - (let* ((url (gemini-parser:make-gemini-uri host path query port)) + (let* ((url (gemini-parser:make-gemini-iri host path query port)) (url-header (format nil "-> ~a~%" url)) (parsed-url (gemini-parser:parse-gemini-file url-header)) (url-response (gemini-client:make-gemini-file-response nil @@ -323,7 +323,7 @@ (if (not (downloading-allowed-p wrapper-object)) (ui:notify (_ "Gemini document downloading aborted")) (let ((compact-event (make-instance 'program-events:gemini-compact-lines-event - :download-uri (download-uri wrapper-object) + :download-iri (download-iri wrapper-object) :priority program-events:+maximum-event-priority+))) (program-events:push-event compact-event) @@ -373,7 +373,7 @@ (query (uri:query iri)) (port (or (uri:port iri) gemini-client:+gemini-default-port+)) - (actual-iri (gemini-parser:make-gemini-uri host + (actual-iri (gemini-parser:make-gemini-iri host path query port))) @@ -389,19 +389,19 @@ (certificate-key nil) (use-cached-file-if-exists nil) (do-nothing-if-exists-in-db t)) - (let ((parsed-uri (ignore-errors (iri:iri-parse url)))) + (let ((parsed-iri (ignore-errors (iri:iri-parse url)))) (maybe-initialize-metadata specials:*message-window*) (cond - ((null parsed-uri) + ((null parsed-iri) (ui:error-message (format nil (_ "Could not understand the address ~s") url))) (use-cached-file-if-exists (multiple-value-bind (actual-iri host path query port) - (displace-iri parsed-uri) + (displace-iri parsed-iri) (if (find-db-stream-url actual-iri) (gemini-viewer:db-entry-to-foreground actual-iri) - (request (gemini-parser:make-gemini-uri host + (request (gemini-parser:make-gemini-iri host path query port) @@ -411,10 +411,10 @@ :do-nothing-if-exists-in-db do-nothing-if-exists-in-db)))) (t - (multiple-value-bind (actual-uri host path query port) - (displace-iri parsed-uri) + (multiple-value-bind (actual-iri host path query port) + (displace-iri parsed-iri) (when (not (and do-nothing-if-exists-in-db - (find-db-stream-url actual-uri))) + (find-db-stream-url actual-iri))) (when (null enqueue) (ensure-just-one-stream-rendering)) (handler-case @@ -428,12 +428,12 @@ (if enqueue :streaming :running))) - (fetch-cached-certificate (actual-uri) + (fetch-cached-certificate (actual-iri) (let* ((certificate-and-key (or (multiple-value-list - (db:ssl-cert-find actual-uri)) + (db:ssl-cert-find actual-iri)) (multiple-value-list - (gemini-client:make-client-certificate actual-uri)))) + (gemini-client:make-client-certificate actual-iri)))) (certificate (first certificate-and-key)) (key (second certificate-and-key))) (assert certificate) @@ -443,7 +443,7 @@ (flet ((on-input-complete (input) (when (string-not-empty-p input) (db-utils:with-ready-database (:connect nil) - (request (gemini-parser:make-gemini-uri host + (request (gemini-parser:make-gemini-iri host path input port) @@ -462,15 +462,15 @@ :client-certificate certificate :query query :port port) - (add-url-to-history specials:*message-window* actual-uri) + (add-url-to-history specials:*message-window* actual-iri) (cond ((gemini-client:response-redirect-p status) (flet ((on-input-complete (maybe-accepted) (when (ui::boolean-input-accepted-p maybe-accepted) (let ((new-url (gemini-parser:absolutize-link meta - (uri:host parsed-uri) - (uri:port parsed-uri) - (uri:path parsed-uri)))) + (uri:host parsed-iri) + (uri:port parsed-iri) + (uri:path parsed-iri)))) (db-utils:with-ready-database (:connect nil) (request new-url :certificate-key certificate-key @@ -483,8 +483,8 @@ meta)))) ((gemini-client:response-certificate-requested-p status) (multiple-value-bind (cached-certificate cached-key) - (fetch-cached-certificate actual-uri) - (request actual-uri + (fetch-cached-certificate actual-iri) + (request actual-iri :enqueue enqueue :do-nothing-if-exists-in-db do-nothing-if-exists-in-db :certificate-key cached-key diff --git a/src/gemini/client.lisp b/src/gemini/client.lisp index 3d89ebe..9ff151c 100644 --- a/src/gemini/client.lisp +++ b/src/gemini/client.lisp @@ -276,8 +276,8 @@ (defun close-ssl-socket (socket) (usocket:socket-close socket)) -(defun make-client-certificate (uri) - (let* ((cache-id (db:cache-put uri +cache-tls-certificate-type+)) +(defun make-client-certificate (iri) + (let* ((cache-id (db:cache-put iri +cache-tls-certificate-type+)) (cert-dir (os-utils:cached-file-path (text-utils:to-s cache-id)))) (fs:make-directory cert-dir) (multiple-value-bind (certificate key) @@ -289,10 +289,10 @@ (port +gemini-default-port+) (client-certificate nil) (certificate-key nil)) - (let* ((uri (make-gemini-uri host path query port)) + (let* ((iri (make-gemini-iri host path query port)) (ctx (cl+ssl:make-context :verify-mode cl+ssl:+ssl-verify-none+))) (when query - (setf uri (strcat uri "?" (percent-encode query)))) + (setf iri (strcat iri "?" (percent-encode query)))) (cl+ssl:with-global-context (ctx :auto-free-p t) (let ((socket (usocket:socket-connect (idn:unicode->ascii host) port @@ -307,7 +307,7 @@ :unwrap-stream-p t :verify nil :hostname host)) - (request (format nil "~a~a~a" uri #\return #\newline)) + (request (format nil "~a~a~a" iri #\return #\newline)) (cert-hash (crypto-shortcuts:sha512 (x509:dump-certificate ssl-stream)))) (if (not (db:tofu-passes-p host cert-hash)) (error 'gemini-tofu-error :host host) diff --git a/src/gemini/gemini-parser.lisp b/src/gemini/gemini-parser.lisp index daac412..2449f47 100644 --- a/src/gemini/gemini-parser.lisp +++ b/src/gemini/gemini-parser.lisp @@ -179,7 +179,7 @@ (path-last-dir original-path) "/") link-value)))) - (make-gemini-uri original-host + (make-gemini-iri original-host (uri:normalize-path path) nil original-port))) @@ -189,20 +189,20 @@ (t (to-s (uri:normalize-path parsed)))))) -(defun make-gemini-uri (host path &optional (query nil) (port +gemini-default-port+)) +(defun make-gemini-iri (host path &optional (query nil) (port +gemini-default-port+)) (let* ((actual-path (if (string-starts-with-p "/" path) (subseq path 1) path)) (actual-port (if port (to-s port) (to-s +gemini-default-port+))) - (uri (strcat +gemini-scheme+ "://" + (iri (strcat +gemini-scheme+ "://" host ":" actual-port "/" actual-path))) (when query - (setf uri (strcat uri "?" query))) - uri)) + (setf iri (strcat iri "?" query))) + iri)) (defun sexp->links (parsed-gemini original-host original-port original-path) (loop for node in parsed-gemini when (html-utils:tag= :a node) collect @@ -214,10 +214,10 @@ original-path) :name (tag-value node))))) -(defun gemini-link-uri-p (uri) +(defun gemini-link-iri-p (iri) (conditions:with-default-on-error (nil) - (or (text-utils:string-starts-with-p +gemini-scheme+ uri) - (null (uri:scheme (iri:iri-parse uri)))))) + (or (text-utils:string-starts-with-p +gemini-scheme+ iri) + (null (uri:scheme (iri:iri-parse iri)))))) (defclass gemini-page-theme () ((link-prefix-gemini @@ -270,7 +270,7 @@ (trim text) text))) (linkify (link-name link-value) - (if (gemini-link-uri-p link-value) + (if (gemini-link-iri-p link-value) (format nil "~a~a~%" (link-prefix-gemini theme) link-name) (format nil "~a~a~%" (link-prefix-other theme) link-name)))) (with-output-to-string (stream) @@ -378,9 +378,9 @@ +max-meta-length+)) parsed))) -(defun gemini-uri-p (maybe-uri) +(defun gemini-iri-p (maybe-iri) (conditions:with-default-on-error (nil) - (let ((parsed (iri:iri-parse maybe-uri))) + (let ((parsed (iri:iri-parse maybe-iri))) (and parsed (string-equal +gemini-scheme+ (uri:scheme parsed)) diff --git a/src/gemini/package.lisp b/src/gemini/package.lisp index 5dd1b7a..f2e7db7 100644 --- a/src/gemini/package.lisp +++ b/src/gemini/package.lisp @@ -45,7 +45,7 @@ :meta :parse-gemini-file :absolutize-link - :make-gemini-uri + :make-gemini-iri :sexp->links :gemini-page-theme :link-prefix-gemini @@ -57,7 +57,7 @@ :bullet-prefix :sexp->text :parse-gemini-response-header - :gemini-uri-p)) + :gemini-iri-p)) (defpackage :gemini-client (:use diff --git a/src/package.lisp b/src/package.lisp index 8a30395..beb68d2 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1212,7 +1212,7 @@ :followed-user-complete :tags-complete :conversation-folder - :make-complete-gemini-uri-fn + :make-complete-gemini-iri-fn :complete-chat-message :complete-always-empty)) @@ -2111,7 +2111,7 @@ :history-back :view-source :gemini-stream - :download-uri + :download-iri :start-time :download-stream :download-socket diff --git a/src/program-events.lisp b/src/program-events.lisp index 639fa39..fb58a4c 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -1014,13 +1014,13 @@ (windows:draw win)))))) (defclass gemini-compact-lines-event (program-event) - ((download-uri + ((download-iri :initform nil - :initarg :download-uri - :accessor download-uri))) + :initarg :download-iri + :accessor download-iri))) (defmethod process-event ((object gemini-compact-lines-event)) - (with-accessors ((download-uri download-uri)) object + (with-accessors ((download-iri download-iri)) object (let ((all-lines "") (all-links ()) (all-source "") @@ -1034,8 +1034,8 @@ (text-rendering-theme gemini-client:text-rendering-theme)) response (when (and (typep a 'gemini-got-line-event) - (string= download-uri - (gemini-viewer:download-uri wrapper-object)) + (string= download-iri + (gemini-viewer:download-iri wrapper-object)) (gemini-viewer:downloading-allowed-p wrapper-object) (not (skip-rendering-p a))) (let ((rendered-text (gemini-parser:sexp->text parsed-file @@ -1052,8 +1052,8 @@ (remove-event-if (lambda (a) (with-accessors ((wrapper-object wrapper-object)) a (and (typep a 'gemini-got-line-event) - (string= download-uri - (gemini-viewer:download-uri wrapper-object)))))) + (string= download-iri + (gemini-viewer:download-iri wrapper-object)))))) (let* ((win specials:*message-window*)) (setf (windows:keybindings win) keybindings:*gemini-message-keymap*) @@ -1063,13 +1063,13 @@ (defclass gemini-abort-downloading-event (program-event) ()) (defmethod process-event ((object gemini-abort-downloading-event)) - (with-accessors ((uri payload)) object - (when-let ((stream-object (gemini-viewer:find-db-stream-url uri))) + (with-accessors ((iri payload)) object + (when-let ((stream-object (gemini-viewer:find-db-stream-url iri))) (gemini-viewer:abort-downloading stream-object) (gemini-viewer:remove-db-stream stream-object) (remove-event-if (lambda (a) (and (typep a 'gemini-got-line-event) - (string= uri (gemini-viewer:download-uri stream-object))))) + (string= iri (gemini-viewer:download-iri stream-object))))) (line-oriented-window:resync-rows-db specials:*gemini-streams-window*)))) (defclass gemini-abort-all-downloading-event (program-event) ()) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 9357013..1ba161e 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -1693,7 +1693,7 @@ mot recent updated to least recent" (defun open-gemini-address () "Ask for a gemini address and try to load it" (flet ((on-input-complete (url) - (if (gemini-parser:gemini-uri-p url) + (if (gemini-parser:gemini-iri-p url) (let* ((event (make-instance 'gemini-request-event :priority program-events:+maximum-event-priority+ @@ -1704,7 +1704,7 @@ mot recent updated to least recent" (let ((prompt (_ "Open Gemini url: "))) (ask-string-input #'on-input-complete :prompt prompt - :complete-fn (complete:make-complete-gemini-uri-fn prompt))))) + :complete-fn (complete:make-complete-gemini-iri-fn prompt))))) (defun gemini-history-back () "Reopen a previous visited gemini address" @@ -1717,9 +1717,9 @@ mot recent updated to least recent" (defun gemini-abort-download () "Stop a transferring data from a gemini server" (when-let* ((fields (line-oriented-window:selected-row-fields *gemini-streams-window*)) - (uri-to-abort (gemini-viewer:download-uri fields)) + (iri-to-abort (gemini-viewer:download-iri fields)) (event (make-instance 'gemini-abort-downloading-event - :payload uri-to-abort + :payload iri-to-abort :priority program-events:+maximum-event-priority+))) (push-event event))) @@ -1749,5 +1749,5 @@ mot recent updated to least recent" (defun gemini-streams-window-open-stream () "Open the selected stream." (when-let* ((fields (line-oriented-window:selected-row-fields *gemini-streams-window*)) - (uri-to-open (gemini-viewer:download-uri fields))) - (gemini-viewer:db-entry-to-foreground uri-to-open))) + (iri-to-open (gemini-viewer:download-iri fields))) + (gemini-viewer:db-entry-to-foreground iri-to-open)))