1
0
Fork 0

- [GUI] fixed test for checking if a stream is exhausted;

- [RPC] force a maximum width for the TOC entry.
This commit is contained in:
cage 2023-03-17 12:27:46 +01:00
parent 1d09d25082
commit 82de38f891
2 changed files with 22 additions and 20 deletions

View File

@ -118,14 +118,12 @@
(aborting-function (constantly nil)))
(enqueue-request-notify-error :gemini-request 1 iri use-cache)
(labels ((stream-exausted-p ()
(let ((status-completed (enqueue-request-notify-error :gemini-stream-completed-p
(let ((status-completed (cev:enqueue-request-and-wait-results :gemini-stream-completed-p
1
ev:+maximum-event-priority+
iri)))
status-completed))
(loop-fetch (&optional (last-lines-fetched-count 0))
(when (not (or (funcall aborting-function)
(stream-exausted-p)))
(ev:with-enqueued-process-and-unblock ()
(with-notify-errors
(let* ((last-lines-fetched (comm:make-request :gemini-stream-parsed-line-slice
@ -136,6 +134,9 @@
(next-start-fetching (length last-lines-fetched)))
(when last-lines-fetched
(funcall process-function stream-wrapper last-lines-fetched))
(when (not (or (funcall aborting-function)
(and (stream-exausted-p)
next-start-fetching)))
(loop-fetch (+ last-lines-fetched-count
next-start-fetching))))))))
(loop-fetch)))

View File

@ -408,7 +408,7 @@
(let ((status (gemini-stream-status iri)))
(eq status :completed)))
(defun build-gemini-toc (iri)
(defun build-gemini-toc (iri width)
(a:when-let* ((ordered-headers-tag '(:h1 :h2 :h3))
(stream-wrapper (gw:find-db-stream-url iri))
(parsed-lines (gw:parsed-lines stream-wrapper))
@ -464,7 +464,7 @@
for text in toc-entries-text
collect
(list :header-group-id (getf toc-entry :group-id)
:text text))
:text (ellipsize text width)))
toc)))))
(defclass gemini-toc (box) ())
@ -478,8 +478,9 @@
(loop for element in list do
(json:encode-array-element element))))))
(defun gemini-table-of-contents (iri)
(make-instance 'gemini-toc :contents (build-gemini-toc iri)))
(defun gemini-table-of-contents (iri width)
(make-instance 'gemini-toc
:contents (build-gemini-toc iri width)))
(defmethod yason:encode ((object gemini-toc) &optional (stream *standard-output*))
(encode-flat-array-of-plists (unbox object) stream))