From ddce6f1a1476ae7cce5c4c09065e34d9671162a0 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 26 Aug 2019 00:07:28 +0530 Subject: Optionally, generate index filenames without extensions. * ennu.el (ennu-index-filename): Make extension argument optional. If extension is nil, do not add extension to generated filename. (ennu-publish-index): Use links without extension for pagination. --- ennu.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ennu.el b/ennu.el index 5d37a71..4620ef8 100644 --- a/ennu.el +++ b/ennu.el @@ -75,17 +75,15 @@ last form in BODY." tongue (file-name-extension filename))))) -(defun ennu-index-filename (filename-prefix tongue extension &optional page-number) - (ennu-add-tongue-suffix - (if page-number - (format "%s-%s.%s" - (file-name-nondirectory filename-prefix) - page-number - extension) - (format "%s.%s" (filename-nondirectory filename-prefix) extension)) - tongue)) - (defun ennu-publish-index (filename-prefix tongue title subtitle posts-per-page posts) +(defun ennu-index-filename (filename-prefix tongue &optional extension page-number) + (let ((extension (if extension (concat "." extension) ""))) + (ennu-add-tongue-suffix + (if page-number + (format "%s-%s%s" (file-name-nondirectory filename-prefix) page-number extension) + (concat (file-name-nondirectory filename-prefix) extension)) + tongue))) + (let* ((number-of-pages (ceiling (length posts) posts-per-page)) (page-numbers (number-sequence 1 number-of-pages))) `(,posts @@ -121,10 +119,10 @@ last form in BODY." posts) (unless (= page-number 1) (insert (format "[[./%s][Newer posts]]\n" - (ennu-index-filename filename-prefix tongue "org" (1- page-number))))) + (ennu-index-filename filename-prefix tongue nil (1- page-number))))) (unless (= page-number number-of-pages) (insert (format "[[./%s][Older posts]]\n" - (ennu-index-filename filename-prefix tongue "org" (1+ page-number))))) + (ennu-index-filename filename-prefix tongue nil (1+ page-number))))) (org-export-to-file 'ennu-html output-file))) (seq-partition posts posts-per-page) page-numbers -- cgit v1.2.3