commit d4170d2472d54844ce90cf4e2e68eb816f8d8bab solene rapenne <solene@dataswamp.org> 2017-12-17 02:56:47 +0100 Only generate html if the source is newer
generator.lisp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/generator.lisp b/generator.lisp index d000f7d..5d45cd5 100644 --- 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)