diff options
author | Arun Isaac | 2020-08-01 18:30:59 +0530 |
---|---|---|
committer | Arun Isaac | 2020-08-02 03:18:47 +0530 |
commit | 0b0f36bf5c574a5f5ccad87a869f6899856c062b (patch) | |
tree | 4982241f2e521dbd35f4e966f8ece8103347f2a5 /ennum.el | |
parent | 4e64115254237730767b8094f3c189806316d31b (diff) | |
download | ennum-0b0f36bf5c574a5f5ccad87a869f6899856c062b.tar.gz ennum-0b0f36bf5c574a5f5ccad87a869f6899856c062b.tar.lz ennum-0b0f36bf5c574a5f5ccad87a869f6899856c062b.zip |
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.
Diffstat (limited to 'ennum.el')
-rw-r--r-- | ennum.el | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -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) |