aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ennum.el40
1 files changed, 24 insertions, 16 deletions
diff --git a/ennum.el b/ennum.el
index 14b0533..b92ec2c 100644
--- a/ennum.el
+++ b/ennum.el
@@ -133,13 +133,17 @@ respectively by - and _, and the pad character = is optional."
(cl-defstruct (ennum-post (:constructor ennum-make-post)
(:copier ennum-copy-post))
filename slug author date language links tangle
- summary tags thumbnail title translation-group translations
- video-posters)
+ summary tags thumbnail title translation-group translations)
(cl-defstruct (ennum-link (:constructor ennum-make-link)
(:copier nil))
type path)
+(cl-defstruct (ennum-video-link (:constructor ennum-make-video-link)
+ (:copier nil)
+ (:include ennum-link (type 'video)))
+ poster)
+
(defun ennum-posts (posts-directory)
(sort (seq-mapcat
;; Set translations slot of post objects.
@@ -192,11 +196,16 @@ respectively by - and _, and the pad character = is optional."
(lambda (link)
(pcase link
(`(link ,properties . ,_)
- (let ((link-type (org-element-property :type link)))
- (when (member link-type (list "image" "static" "video"))
- (ennum-make-link
- :type (intern link-type)
- :path (org-element-property :path link))))))))))
+ (let ((link-type (org-element-property :type link))
+ (path (org-element-property :path link)))
+ (pcase link-type
+ ("video"
+ (ennum-make-video-link
+ :path path
+ :poster (ennum-video-poster path)))
+ (_ (ennum-make-link
+ :type (intern link-type)
+ :path path))))))))))
(ennum-make-post
:filename filename
:slug (file-name-base filename)
@@ -227,13 +236,7 @@ respectively by - and _, and the pad character = is optional."
links))
:title (funcall export (first (plist-get metadata :title)))
:translation-group (or (plist-get metadata :translation-group)
- (file-name-base filename))
- :video-posters (ennum--filter-map (lambda (link)
- (pcase (ennum-link-type link)
- ('video
- (let ((path (ennum-link-path link)))
- `(,path . ,(ennum-video-poster path))))))
- links))))))
+ (file-name-base filename)))))))
(defvar ennum-mandatory-metadata
(list :title :date))
@@ -282,7 +285,12 @@ result as a string."
(let ((system-time-locale (map-elt (ennum-setting :locale-alist)
(ennum-post-language post) nil 'string=))
(ext-plist (list :ennum-translations (ennum-post-translations post)
- :ennum-video-posters (ennum-post-video-posters post))))
+ :ennum-video-posters
+ (ennum--filter-map (lambda (link)
+ (when (eq (ennum-link-type link) 'video)
+ (cons (ennum-link-path link)
+ (ennum-video-link-poster link))))
+ (ennum-post-links post)))))
(ennum-with-file-contents interned-org-file
(if output-html-file
(org-export-to-file 'ennum-html output-file nil nil nil body-only ext-plist)
@@ -548,7 +556,7 @@ if DESTINATION already exists."
(list
(ennum--expand-relative (ennum-link-path link)
(ennum-setting :video-directory))
- (ennum--expand-relative (ennum-video-poster (ennum-link-path link))
+ (ennum--expand-relative (ennum-video-link-poster link)
(ennum-setting :images-directory)))))))
(defmacro ennum-with-current-directory (directory &rest body)