From 202a7ca2b2f33ee95b0ecf2bd6d01859f6930580 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 2 Sep 2019 01:27:32 +0530 Subject: Publish posts and their translations together. * ennu.el (ennu-publish-post): Publish posts and their translations together in a single operation. (ennu-publish): Invoke ennu-publish-post with all posts of a single translation group. --- ennu.el | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ennu.el b/ennu.el index 5a72979..ccbe8ae 100644 --- a/ennu.el +++ b/ennu.el @@ -87,7 +87,7 @@ last form in BODY." (defun ennu--org-output-filename (filename) (concat (file-name-sans-extension filename) ".html")) -(defun ennu-publish-post (post) +(defun ennu-publish-post (posts) ;; TODO: Tangle post ;; (when-let (tangle-dir (or (plist-get posts-plist :valai-tangle-directory) ;; valai-tangle-directory)) @@ -100,12 +100,20 @@ last form in BODY." ;; (expand-file-name (file-name-nondirectory tangled-file) ;; tangle-dir) ;; t))) - (ennu-make-operation - :inputs (list (ennu-post-filename post)) - :outputs (list (ennu--org-output-filename (ennu-post-filename post))) - :publish (lambda (output-file) - (ennu-with-file-contents (ennu-post-filename post) - (org-export-to-file 'ennu-html output-file))))) + (let ((input-post-files (seq-map 'ennu-post-filename posts))) + (ennu-make-operation + :inputs input-post-files + :outputs (seq-map 'ennu--org-output-filename input-post-files) + :publish + (lambda (&rest output-files) + (seq-mapn + (lambda (post output-file) + (ennu-with-file-contents (ennu-post-filename post) + (org-export-to-file + 'ennu-html output-file nil nil nil nil + (list :translations (seq-remove (apply-partially 'equal post) posts))))) + posts + output-files))))) (defun ennu-publish-page (pages-directory page) (ennu-make-operation @@ -409,7 +417,9 @@ as keys. Keys are compared using `equal'." (let ((posts (ennu-posts (ennu-setting :posts-directory)))) (append ;; Publish posts - (seq-map 'ennu-publish-post posts) + (seq-map (pcase-lambda (`(,translation-group . ,posts)) + (ennu-publish-post posts)) + (seq-group-by 'ennu-post-translation-group posts)) ;; Publish feed (list (ennu-publish-feed (ennu-setting :atom-feed-file) blog-title -- cgit v1.2.3