From 0b0f36bf5c574a5f5ccad87a869f6899856c062b Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 1 Aug 2020 18:30:59 +0530 Subject: Embed video poster in link object. * ennum.el (ennum-post): Remove video-posters slot. (ennum-video-link): New type. (ennum--read-post): Create video link when applicable. Do not set video-posters in post object. (ennum-publish-post, ennum-publish-link): Use ennum-video-link-poster. --- ennum.el | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'ennum.el') 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) -- cgit v1.2.3