From 172a5413ba2e786b3b7d8e8d1793e6ff05eb96df Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 2 Aug 2020 01:15:38 +0530 Subject: Pass post object in info. * ennum-html.el (ennum-html-inner-template): Use translations from post object. (ennum-html-find-link): New function. (ennum-html-link): Use post titles and video posters from post object. * ennum.el (ennum-export-post): Pass post object as :ennum-posts in info. --- ennum-html.el | 21 +++++++++++++++------ ennum.el | 17 +---------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/ennum-html.el b/ennum-html.el index 65c0455..ac3f0c3 100644 --- a/ennum-html.el +++ b/ennum-html.el @@ -230,7 +230,7 @@ :datetime ,(org-export-get-date info "%Y-%m-%d 12:00:00") ,(org-export-get-date info "%B %d, %Y")))))))) ;; Interlanguage language links - (when-let (translations (plist-get info :ennum-translations)) + (when-let (translations (ennum-post-translations (plist-get info :ennum-post))) (format "
In other languages: %s
" (mapconcat (pcase-lambda (`(,lang . ,slug)) @@ -264,6 +264,14 @@ (org-html-footnote-section info) "")) +(defun ennum-html-find-link (type path info) + "Find link of TYPE and PATH in post object stored in +:ennum-posts of property list INFO." + (seq-find (lambda (link) + (and (eq (ennum-link-type link) type) + (string= (ennum-link-path link) path))) + (ennum-post-links (plist-get info :ennum-post)))) + (defun ennum-html-link (link desc info) ;; We override the html link transcoder to handle image, post and ;; video links differently. We cannot use the `:export' property of @@ -296,8 +304,8 @@ ("post" (ennum-html-export-post path - (or desc (map-elt (plist-get info :ennum-post-titles) - path nil 'string=)) + (or desc (ennum-post-link-target-title + (ennum-html-find-link 'post path info))) (org-export-backend-name (plist-get info :back-end)))) ("video" (let ((video-directory (ennum-setting :video-directory))) @@ -305,9 +313,10 @@ (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)) + (expand-file-name* + (ennum-video-link-poster + (ennum-html-find-link 'video path info)) + video-directory)) :preload "none" :controls "")))) ;; Pass other link types to org-html-link diff --git a/ennum.el b/ennum.el index 955a0bf..855aade 100644 --- a/ennum.el +++ b/ennum.el @@ -326,22 +326,7 @@ result as a string." (ennum-mkdir-p (file-name-directory output-file)) (let ((system-time-locale (map-elt (ennum-setting :locale-alist) (ennum-post-language post) nil 'string=)) - (ext-plist (list :ennum-post-titles - (ennum--filter-map - (lambda (link) - (when (and (ennum-post-link-p link) - (not (eq (ennum-post-link-target-title link) - 'not-required))) - (cons (ennum-post-link-path link) - (ennum-post-link-target-title link)))) - (ennum-post-links post)) - :ennum-translations (ennum-post-translations 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))))) + (ext-plist (list :ennum-post 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) -- cgit v1.2.3