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 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'ennum-html.el') 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 -- cgit v1.2.3