From 7d1caecd898ba44fbe2e287a3d59fd15d7ea9cc7 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 2 Sep 2019 22:38:58 +0530 Subject: Implement generic publisher. * ennu.el (ennu-publish-page): Delete function. (ennu-publish-generic): New function. (ennu-setting): Derecognize :pages-directory and :unattached-static-files properties. Recognize :other-files-directory property. (ennu-publish): Invoke ennu-publish-generic, the generic publisher. --- ennu.el | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ennu.el b/ennu.el index 3eadc82..977771c 100644 --- a/ennu.el +++ b/ennu.el @@ -120,16 +120,20 @@ last form in BODY." output-files))) link-publish-operations))) -(defun ennu-publish-page (pages-directory page) +(defun ennu-publish-generic (other-files-directory file) (ennu-make-operation - :inputs (list page) - :outputs (list (ennu--org-output-filename - (string-remove-prefix - (file-name-as-directory pages-directory) - page))) + :inputs (list file) + :outputs + (list (string-remove-prefix + (file-name-as-directory other-files-directory) + (pcase (file-name-extension file) + ("org" (ennu--org-output-filename file)) + (_ file)))) :publish (lambda (output-file) - (ennu-with-file-contents page - (org-export-to-file 'html output-file))))) + (pcase (file-name-extension file) + ("org" (ennu-with-file-contents file + (org-export-to-file 'html output-file))) + (_ (ennu-copy file output-file)))))) (defun ennu-video-poster (video) (pcase (directory-files (ennu-setting :images-directory) nil @@ -280,7 +284,7 @@ last form in BODY." :working-directory) (or (plist-get ennu-blog property) (user-error "Property %s not defined" property))) - ((or :pages-directory :unattached-static-files) + (:other-files-directory (plist-get ennu-blog property)) (_ (error "Unknown property %s" property)))) @@ -449,16 +453,13 @@ as keys. Keys are compared using `equal'." (apply-partially 'ennu-publish-image (list (ennu-setting :thumbnail-image-width))) (seq-map (lambda (image) (ennu--expand-relative image (ennu-setting :images-directory))) - (seq-uniq (seq-filter 'identity (seq-map 'ennu-post-thumbnail posts))))))) - ;; Publish pages - (when-let ((pages-directory (ennu-setting :pages-directory))) - (seq-map (apply-partially 'ennu-publish-page pages-directory) + (seq-uniq (ennu--filter-map 'ennu-post-thumbnail posts)))))) + ;; Publish other files + (when-let ((other-files-directory (ennu-setting :other-files-directory))) + (seq-map (apply-partially 'ennu-publish-generic other-files-directory) (seq-map (apply-partially 'string-remove-prefix (file-name-as-directory (expand-file-name default-directory))) - (directory-files-recursively pages-directory "\\.org$")))) - ;; Publish unattached static files - (seq-map 'ennu-publish-static-file - (ennu-setting :unattached-static-files)))) + (directory-files-recursively other-files-directory ".")))))) ;; Replace old output directory (let ((output (ennu-setting :output-directory))) (delete-directory output t) -- cgit v1.2.3