aboutsummaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
authorArun Isaac2019-09-02 22:38:58 +0530
committerArun Isaac2019-09-02 22:38:58 +0530
commit7d1caecd898ba44fbe2e287a3d59fd15d7ea9cc7 (patch)
treeebf6a06a187878ba93f19d10bf0365095cb06ec6 /ennu.el
parent1f2531c31f219e5f569f228e9d57c65fd59c9964 (diff)
downloadennum-7d1caecd898ba44fbe2e287a3d59fd15d7ea9cc7.tar.gz
ennum-7d1caecd898ba44fbe2e287a3d59fd15d7ea9cc7.tar.lz
ennum-7d1caecd898ba44fbe2e287a3d59fd15d7ea9cc7.zip
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.
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el35
1 files 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)