mirror of
https://codeberg.org/cage/tinmop/
synced 2025-03-02 09:57:48 +01:00
- refactored some functions related to gemini streams.
This commit is contained in:
parent
a7e8e6f0e7
commit
5b52ac26ef
@ -372,6 +372,15 @@
|
||||
(text-utils:percent-decode fragment)
|
||||
fragment)))
|
||||
|
||||
(defun array->string (array remove-bom)
|
||||
(let ((res (text-utils:to-s array :errorp nil)))
|
||||
(if (and (string-not-empty-p res)
|
||||
remove-bom
|
||||
(char= (first-elt res)
|
||||
#\ZERO_WIDTH_NO-BREAK_SPACE))
|
||||
(subseq res 1)
|
||||
res)))
|
||||
|
||||
(defun request-stream-gemini-document-thread (wrapper-object scheme host
|
||||
port path query fragment favicon
|
||||
gemini-format-p
|
||||
@ -417,14 +426,6 @@
|
||||
t)))
|
||||
(maybe-render-line preformat-wrapper-event)
|
||||
(write-sequence preformat-line file-stream)))))
|
||||
(array->string (array remove-bom)
|
||||
(let ((res (text-utils:to-s array :errorp nil)))
|
||||
(if (and (string-not-empty-p res)
|
||||
remove-bom
|
||||
(char= (first-elt res)
|
||||
#\ZERO_WIDTH_NO-BREAK_SPACE))
|
||||
(subseq res 1)
|
||||
res)))
|
||||
(maybe-notify (message)
|
||||
(when notify
|
||||
(ui:notify message))))
|
||||
|
@ -101,23 +101,11 @@
|
||||
(octet-count gw:octet-count)
|
||||
(support-file gw:support-file)) wrapper-object
|
||||
(labels ((maybe-render-preformat-wrapper (file-stream wrapper-object)
|
||||
(when (and (os-utils:open-resource-with-tinmop-p
|
||||
(gw:download-iri wrapper-object))
|
||||
(when (and (os-utils:open-resource-with-tinmop-p (gw:download-iri wrapper-object))
|
||||
(not gemini-format-p))
|
||||
(let* ((preformat-line (format nil "~a~%" gemini-parser:+preformatted-prefix+))
|
||||
(parsed-line (gemini-parser:parse-gemini-file preformat-line)))
|
||||
(setf (gw:parsed-lines wrapper-object)
|
||||
(append (gw:parsed-lines wrapper-object)
|
||||
parsed-line))
|
||||
(write-sequence preformat-line file-stream))))
|
||||
(array->string (array remove-bom)
|
||||
(let ((res (text-utils:to-s array :errorp nil)))
|
||||
(if (and (string-not-empty-p res)
|
||||
remove-bom
|
||||
(char= (a:first-elt res)
|
||||
#\ZERO_WIDTH_NO-BREAK_SPACE))
|
||||
(subseq res 1)
|
||||
res)))
|
||||
(write-out-stream file-stream
|
||||
wrapper-object
|
||||
(format nil "~a~%" gemini-parser:+preformatted-prefix+))))
|
||||
(write-out-stream (file-stream wrapper-object line)
|
||||
(let ((parsed-line (gemini-parser:parse-gemini-file line)))
|
||||
(write-sequence line file-stream)
|
||||
@ -139,10 +127,7 @@
|
||||
:port port
|
||||
:fragment fragment))
|
||||
(url-header (format nil "~a ~a~2%" favicon url)))
|
||||
(write-sequence url-header file-stream)
|
||||
(gw::increment-bytes-count wrapper-object url-header :convert-to-octets t)
|
||||
(setf (gw:parsed-lines wrapper-object)
|
||||
(gemini-parser:parse-gemini-file url-header))
|
||||
(write-out-stream file-stream wrapper-object url-header)
|
||||
(maybe-render-preformat-wrapper file-stream wrapper-object)
|
||||
(handler-case
|
||||
(loop
|
||||
@ -154,8 +139,8 @@
|
||||
line-as-array)
|
||||
(if (gw:downloading-allowed-p wrapper-object)
|
||||
(let* ((line (if (= ct 0)
|
||||
(array->string line-as-array t)
|
||||
(array->string line-as-array nil))))
|
||||
(gw::array->string line-as-array t)
|
||||
(gw::array->string line-as-array nil))))
|
||||
(gemini-client:debug-gemini "[stream] gemini file stream got data line : ~a"
|
||||
line)
|
||||
(write-out-stream file-stream wrapper-object line))
|
||||
|
Loading…
x
Reference in New Issue
Block a user