aboutsummaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
authorArun Isaac2020-03-13 21:34:59 +0530
committerArun Isaac2020-03-13 21:34:59 +0530
commit541c50ac77de673c8039c83dde409e4524787faf (patch)
tree2fce76b845bafb22be6d4df6e04ec5ad1362a762 /ennu.el
parentc761096d9de1faff4c0c4264b7cad2085552e73a (diff)
downloadennum-541c50ac77de673c8039c83dde409e4524787faf.tar.gz
ennum-541c50ac77de673c8039c83dde409e4524787faf.tar.lz
ennum-541c50ac77de673c8039c83dde409e4524787faf.zip
Use appropriate time locale when exporting pages.
We set the appropriate time locale so that dates are exported in the correct language. * ennu.el (ennu-publish-post, ennu-publish-index): Set time locale according to language of the page. (ennu-setting): Introduce :locale-alist mapping languages to their locales. Use C locale for English pages as the default :locale-alist.
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el90
1 files changed, 46 insertions, 44 deletions
diff --git a/ennu.el b/ennu.el
index 8481ebd..613f61a 100644
--- a/ennu.el
+++ b/ennu.el
@@ -112,10 +112,12 @@ last form in BODY."
(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)))))
+ (let ((system-time-locale (map-elt (ennu-setting :locale-alist)
+ (ennu-post-language post) nil 'string=)))
+ (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))))
(ennu--filter-map
@@ -183,44 +185,43 @@ last form in BODY."
page-numbers))
:publish
(lambda (home-page &rest output-files)
- (seq-mapn
- (lambda (posts page-number output-file)
- (with-temp-buffer
- (insert (format "#+TITLE: %s\n" title))
- (insert (format "#+LANGUAGE: %s\n" tongue))
- (insert "#+OPTIONS: num:nil toc:nil\n\n")
- (seq-do (lambda (post)
- (insert (format "* [[post:%s]]\n" (ennu-post-slug post)))
- (insert (format-time-string
- "/%b %e, %Y/\n\n"
- (ennu-post-date post)))
- (when-let ((thumbnail (ennu-post-thumbnail post)))
- (insert (format "[[thumbnail:%s]]\n\n" thumbnail)))
- (when-let ((summary (ennu-post-summary post)))
- (insert summary)
- (insert "\n\n"))
- (when-let ((tags (ennu-post-tags post)))
- (insert "Tags: ")
- (insert
- (string-join
- (seq-map (lambda (tag)
- (format "[[tag:%s][%s]]" (ennu-add-tongue-suffix tag tongue) tag))
- tags)
- ", "))
- (insert "\n\n")))
- posts)
- (unless (= page-number 1)
- (insert (format "[[./%s][Newer posts]]\n"
- (ennu-index-filename (file-name-nondirectory filename-prefix)
- tongue nil (1- page-number)))))
- (unless (= page-number number-of-pages)
- (insert (format "[[./%s][Older posts]]\n"
- (ennu-index-filename (file-name-nondirectory filename-prefix)
- tongue nil (1+ page-number)))))
- (org-export-to-file 'html output-file)))
- (seq-partition posts posts-per-page)
- page-numbers
- output-files)
+ (let ((system-time-locale (map-elt (ennu-setting :locale-alist) tongue nil 'string=)))
+ (seq-mapn
+ (lambda (posts page-number output-file)
+ (with-temp-buffer
+ (insert (format "#+TITLE: %s\n" title))
+ (insert (format "#+LANGUAGE: %s\n" tongue))
+ (insert "#+OPTIONS: num:nil toc:nil\n\n")
+ (seq-do (lambda (post)
+ (insert (format "* [[post:%s]]\n" (ennu-post-slug post)))
+ (insert (format-time-string "/%b %e, %Y/\n\n" (ennu-post-date post)))
+ (when-let ((thumbnail (ennu-post-thumbnail post)))
+ (insert (format "[[thumbnail:%s]]\n\n" thumbnail)))
+ (when-let ((summary (ennu-post-summary post)))
+ (insert summary)
+ (insert "\n\n"))
+ (when-let ((tags (ennu-post-tags post)))
+ (insert "Tags: ")
+ (insert
+ (string-join
+ (seq-map (lambda (tag)
+ (format "[[tag:%s][%s]]" (ennu-add-tongue-suffix tag tongue) tag))
+ tags)
+ ", "))
+ (insert "\n\n")))
+ posts)
+ (unless (= page-number 1)
+ (insert (format "[[./%s][Newer posts]]\n"
+ (ennu-index-filename (file-name-nondirectory filename-prefix)
+ tongue nil (1- page-number)))))
+ (unless (= page-number number-of-pages)
+ (insert (format "[[./%s][Older posts]]\n"
+ (ennu-index-filename (file-name-nondirectory filename-prefix)
+ tongue nil (1+ page-number)))))
+ (org-export-to-file 'html output-file)))
+ (seq-partition posts posts-per-page)
+ page-numbers
+ output-files))
(copy-file (first output-files) home-page)))))
(defun ennu--absolute-uri (path)
@@ -279,8 +280,8 @@ last form in BODY."
((or :atom-feed-number-of-posts :atom-feed-file
:blog-scheme :default-image-width
:image-link-width :index-posts-per-page
- :other-files-directory :tag-directory
- :thumbnail-image-width)
+ :locale-alist :other-files-directory
+ :tag-directory :thumbnail-image-width)
(plist-get (org-combine-plists
(list :atom-feed-number-of-posts 12
:atom-feed-file "blog.atom"
@@ -288,6 +289,7 @@ last form in BODY."
:default-image-width 640
:image-link-width 1024
:index-posts-per-page 12
+ :locale-alist '(("en" . "C"))
:tag-directory "tag"
:thumbnail-image-width 320)
ennu-blog)