Only generate html if the source is newer - cl-yag - Common Lisp Yet Another website Generator
HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit d4170d2472d54844ce90cf4e2e68eb816f8d8bab
DIR parent 4fd8a06766051afce42b6eeec8f182ccb36b87f3
HTML Author: solene rapenne <solene@dataswamp.org>
Date: Sun, 17 Dec 2017 02:56:47 +0100
Only generate html if the source is newer
Diffstat:
M generator.lisp | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
---
DIR diff --git a/generator.lisp b/generator.lisp
@@ -132,13 +132,26 @@
(let ((converter-object (getf *converters* converter-name)))
,@code))))
+;; generate the html file from the source file
+;; using the converter associated with the post
(defun use-converter-to-html(article)
(with-converter
(let ((output (converter-command converter-object)))
- (ensure-directories-exist "temp/data/")
- (template "%IN" (concatenate 'string (article-id article) (converter-extension converter-object)))
- (template "%OUT" (concatenate 'string "temp/data/" (article-id article) ".html"))
- (uiop:run-program output))))
+ (let* ((src-file (format nil "~a~a" (article-id article) (converter-extension converter-object)))
+ (dst-file (format nil "temp/data/~a.html" (article-id article) ))
+ (full-src-file (format nil "data/~a" src-file)))
+ ;; skip generating if the destination exists
+ ;; and is more recent than source
+ (unless (and
+ (probe-file dst-file)
+ (>=
+ (file-write-date dst-file)
+ (file-write-date full-src-file)))
+ (ensure-directories-exist "temp/data/")
+ (template "%IN" src-file)
+ (template "%OUT" dst-file)
+ (format t "~a~%" output)
+ (uiop:run-program output))))))
;; format the date
(defun date-format(format date)
@@ -342,5 +355,4 @@
(generate-site)
-
(quit)