diff options
Diffstat (limited to 'ennum.el')
-rw-r--r-- | ennum.el | 40 |
1 files changed, 25 insertions, 15 deletions
@@ -259,22 +259,34 @@ non-nil, include directories in the output." (defun ennum--org-output-filename (filename) (concat (file-name-sans-extension filename) ".html")) +(defun ennum-export-post (post interned-org-file &optional output-html-file body-only) + "Export INTERNED-ORG-FILE of POST to OUTPUT-HTML-FILE using the +ennum-html backend. INTERNED-ORG-FILE must be an org file +interned into the ennum store. + +When optional argument BODY-ONLY is non-nil, only return body +code, without surrounding template. See `org-export-as'. + +When optional argument OUTPUT-HTML-FILE is nil, return exported +result as a string." + (let ((output-file (ennum--org-output-filename (ennum-post-filename post)))) + (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-translations (ennum-post-translations post) + :ennum-video-posters (ennum-post-video-posters 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) + (org-export-as 'ennum-html nil nil body-only ext-plist)))))) + (defun ennum-publish-post (post) (append (list (ennum-exp - (let ((input-org-file (ennum-input (ennum-intern (ennum-post-filename post)))) - (output-file - (ennum--org-output-filename (ennum-post-filename post)))) - (ennum-mkdir-p (file-name-directory output-file)) - (let ((system-time-locale (map-elt (ennum-setting :locale-alist) - (ennum-post-language post) nil 'string=))) - (ennum-with-file-contents input-org-file - ;; TODO: Centralize these with feed generation - (org-export-to-file - 'ennum-html output-file nil nil nil nil - (list :ennum-translations (ennum-post-translations post) - :ennum-video-posters (ennum-post-video-posters post)))))))) + (ennum-export-post post + (ennum-input (ennum-intern (ennum-post-filename post))) + (ennum--org-output-filename (ennum-post-filename post))))) (when (ennum-post-tangle post) (list (ennum-exp @@ -427,9 +439,7 @@ non-nil, include directories in the output." (name ,(ennum-post-author post)) (email ,user-mail-address)))) (content :type "html" :xml:lang ,(ennum-post-language post) - ,(ennum-with-file-contents interned-post-file - (org-export-as 'ennum-html nil nil t - (list :ennum-video-posters (ennum-post-video-posters post))))) + ,(ennum-export-post post interned-post-file nil t)) (link :rel "alternate" :href ,link) ,@(seq-map (lambda (tag) `(category :term ,tag)) (ennum-post-tags post))))) |