1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-06-05 01:09:17 +02:00

- [GUI] changed test for checking a local file;

- [GUI] checked, when a image is inlined, if it comes from a local path, then try to figure out the format from the file's extension;
- [GUI] [gempub] fixed inlining of cover file.
This commit is contained in:
cage
2024-09-15 18:15:29 +02:00
parent 3ebe35da57
commit 65a368eddb
2 changed files with 40 additions and 29 deletions

View File

@@ -115,6 +115,7 @@
(defun make-gempub-index (gempub-metadata) (defun make-gempub-index (gempub-metadata)
(let ((gempub-content-directory (extract-gempub (row-path gempub-metadata)))) (let ((gempub-content-directory (extract-gempub (row-path gempub-metadata))))
(values
(cond (cond
((and (row-cover gempub-metadata) ((and (row-cover gempub-metadata)
(row-index gempub-metadata)) (row-index gempub-metadata))
@@ -125,7 +126,8 @@
((row-index gempub-metadata) ((row-index gempub-metadata)
(row-index gempub-metadata)) (row-index gempub-metadata))
(t (t
gempub-content-directory)))) gempub-content-directory))
(fs:cat-parent-dir gempub-content-directory "/"))))
(defun open-gempub-clsr (main-window gempub-frame) (defun open-gempub-clsr (main-window gempub-frame)
(lambda (e) (lambda (e)
@@ -137,9 +139,11 @@
(row (cev:enqueue-request-and-wait-results :gempub-file-id->row (row (cev:enqueue-request-and-wait-results :gempub-file-id->row
1 1
ev:+standard-event-priority+ ev:+standard-event-priority+
id)) id)))
(path (make-gempub-index row))) (multiple-value-bind (path book-directory)
(client-main-window::open-iri path main-window nil))))) (make-gempub-index row)
(client-main-window::set-address-bar-text main-window book-directory)
(client-main-window::open-iri path main-window nil))))))
(defun init-window (master main-window query-results) (defun init-window (master main-window query-results)
(client-main-window:hide-autocomplete-candidates main-window) (client-main-window:hide-autocomplete-candidates main-window)

View File

@@ -536,14 +536,22 @@
(defun inline-image (main-window link-value line-index) (defun inline-image (main-window link-value line-index)
(multiple-value-bind (file-path mime-type) (multiple-value-bind (file-path mime-type)
(slurp-iri main-window (remove-standard-port link-value)) (slurp-iri main-window (remove-standard-port link-value))
(let ((image (cond (let* ((local-file (fs:file-exists-p file-path))
((string= mime-type +mime-type-jpg+) (image (cond
((or (string= mime-type +mime-type-jpg+)
(and local-file
(fs:has-extension file-path "jpg")
(fs:has-extension file-path "jpeg")))
(scale-jpeg main-window file-path)) (scale-jpeg main-window file-path))
((member mime-type ((or (member mime-type
'("image/x-tga" "image/x-targa") '("image/x-tga" "image/x-targa")
:test #'string=) :test #'string=)
(and local-file
(fs:has-extension file-path "tga")))
(scale-targa main-window file-path)) (scale-targa main-window file-path))
((string= mime-type +mime-type-png+) ((or (string= mime-type +mime-type-png+)
(and local-file
(fs:has-extension file-path "png")))
(scale-png main-window file-path)) (scale-png main-window file-path))
(t (t
(gui:make-image file-path)))) (gui:make-image file-path))))
@@ -1147,9 +1155,8 @@ local file paths."
:status status) :status status)
(client-stream-frame::refresh-all-streams (client-stream-frame::refresh-all-streams
(client-stream-frame::table stream-frame)))) (client-stream-frame::table stream-frame))))
((or (null (iri:scheme parsed-iri)) ((or (fs:file-exists-p actual-iri)
(string= (iri:scheme parsed-iri) (fs:directory-exists-p actual-iri))
constants:+file-scheme+))
(initialize-ir-lines main-window) (initialize-ir-lines main-window)
(open-local-path (iri:path parsed-iri) main-window)) (open-local-path (iri:path parsed-iri) main-window))
(t (t