diff options
-rw-r--r-- | ennum-html.el | 29 | ||||
-rw-r--r-- | ennum.el | 17 |
2 files changed, 25 insertions, 21 deletions
diff --git a/ennum-html.el b/ennum-html.el index 10a6e65..ee1b3d7 100644 --- a/ennum-html.el +++ b/ennum-html.el @@ -265,8 +265,8 @@ "</article>")) (defun ennum-html-link (link desc info) - ;; We override the html link transcoder to handle image links - ;; differently. We cannot use the `:export' property of + ;; We override the html link transcoder to handle image and video + ;; links differently. We cannot use the `:export' property of ;; `org-link-parameters' since those functions cannot access the ;; `info' communication channel. (let ((path (org-element-property :path link))) @@ -293,6 +293,17 @@ (ennum-setting :images-directory)))) :type "file") desc info)))) + ("video" + (let ((video-directory (ennum-setting :video-directory))) + (message "%s" (plist-get info :ennum-video-posters)) + (xmlgen + `(video :src ,(url-encode-url (expand-file-name* path video-directory)) + :poster ,(url-encode-url + (expand-file-name* (map-elt (plist-get info :ennum-video-posters) + path nil 'string=) + video-directory)) + :preload "none" + :controls "")))) ;; Pass other link types to org-html-link (_ (org-html-link link desc info))))) @@ -341,20 +352,6 @@ :export 'ennum-export-thumbnail :follow 'ennum-follow-image) -(defun ennum-export-video (path desc backend) - (pcase backend - ((or 'ennum-html 'html) - (let ((video-directory (ennum-setting :video-directory))) - (xmlgen - `(video :src ,(url-encode-url (expand-file-name* path video-directory)) - :poster ,(url-encode-url - (expand-file-name* (ennum-video-poster path) video-directory)) - :preload "none" - :controls "")))))) - -(org-link-set-parameters - "video" :export 'ennum-export-video) - (defun ennum-export-static (path desc backend) (pcase backend ((or 'ennum-html 'html) @@ -15,7 +15,7 @@ (cl-defstruct (ennum-post (:constructor ennum-make-post) (:copier nil)) filename slug author date language links tangle - summary tags thumbnail title translation-group) + summary tags thumbnail title translation-group video-posters) (cl-defstruct (ennum-operation (:constructor ennum-make-operation) (:copier nil)) @@ -83,7 +83,12 @@ links)) :title (funcall export (first (plist-get metadata :title))) :translation-group (or (plist-get metadata :translation-group) - (file-name-base filename))))))) + (file-name-base filename)) + :video-posters (ennum--filter-map (lambda (link) + (pcase link + (`("video" . ,path) + `(,path . ,(ennum-video-poster path))))) + links)))))) (defvar ennum-mandatory-metadata (list :title :date)) @@ -119,7 +124,8 @@ last form in BODY." (ennum-with-file-contents (ennum-post-filename post) (org-export-to-file 'ennum-html output-file nil nil nil nil - (list :ennum-translations (seq-remove (apply-partially 'equal post) posts)))))) + (list :ennum-translations (seq-remove (apply-partially 'equal post) posts) + :ennum-video-posters (ennum-post-video-posters post)))))) posts output-files)))) (ennum--filter-map @@ -272,8 +278,9 @@ last form in BODY." (name ,(ennum-post-author post)) (email ,user-mail-address)))) (content :type "html" :xml:lang ,(ennum-post-language post) - ,(ennum-with-file-contents (ennum-post-filename post) - (org-export-as 'ennum-html nil nil t))) + ,(ennum-with-file-contents interned-post-file + (org-export-as 'ennum-html nil nil t + (list :ennum-video-posters (ennum-post-video-posters post))))) (link :rel "alternate" :href ,link) ,@(seq-map (lambda (tag) `(category :term ,tag)) (ennum-post-tags post))))) |