git/cl-yag/commit/a8dfa314e9911295a3c52318d4702e4761093e2f.html (4729 bytes)
1 <!DOCTYPE html> 2 <html lang="en"><head><meta charset="UTF-8" /> 3 <meta name="viewport" content="width=device-width, initial-scale=1" /> 4 <title>cl-yag a8dfa314 - Recently Written</title> 5 <link rel="stylesheet" href="../../stagit.css" /> 6 </head><body> 7 <div id="top"><a href="../../../index.html">Recently Written</a> · <a href="../../index.html">git</a></div> 8 <h1>cl-yag</h1><span class="desc">Mirror and rewrite of Solène Rapenne's cl-yag SSG of renown</span><p class="url">git clone https://github.com/equwal/cl-yag</p><p><a href="../../cl-yag/index.html">Log</a> | <a href="../../cl-yag/files.html">Files</a> | <a href="../../cl-yag/refs.html">Refs</a></p><hr/> 9 <div id="content"> 10 <pre>commit a8dfa314e9911295a3c52318d4702e4761093e2f 11 Solene Rapenne <solene@perso.pw> 12 2019-08-27 09:10:20 +0200 13 14 Add support for differents converters 15 16 </pre><pre> generator.lisp | 45 ++++++++++++++++++++++++--------------------- 17 1 file changed, 24 insertions(+), 21 deletions(-) 18 </pre><pre>diff --git a/generator.lisp b/generator.lisp 19 index ca01c36..eb483aa 100644 20 --- a/generator.lisp 21 +++ b/generator.lisp 22 <span class="h">@@ -129,24 +129,27 @@</span> 23 24 ;; generate the html file from the source file 25 ;; using the converter associated with the post 26 <span class="d">-(defun use-converter-to-html(article)</span> 27 <span class="d">- (with-converter</span> 28 <span class="d">- (let ((output (converter-command converter-object)))</span> 29 <span class="d">- (let* ((src-file (format nil "~a~a" (article-id article) (converter-extension converter-object)))</span> 30 <span class="d">- (dst-file (format nil "temp/data/~a.html" (article-id article) ))</span> 31 <span class="d">- (full-src-file (format nil "data/~a" src-file)))</span> 32 <span class="d">- ;; skip generating if the destination exists</span> 33 <span class="d">- ;; and is more recent than source</span> 34 <span class="d">- (unless (and</span> 35 <span class="d">- (probe-file dst-file)</span> 36 <span class="d">- (>=</span> 37 <span class="d">- (file-write-date dst-file)</span> 38 <span class="d">- (file-write-date full-src-file)))</span> 39 <span class="d">- (ensure-directories-exist "temp/data/")</span> 40 <span class="d">- (template "%IN" src-file)</span> 41 <span class="d">- (template "%OUT" dst-file)</span> 42 <span class="d">- (format t "~a~%" output)</span> 43 <span class="d">- (uiop:run-program output))))))</span> 44 <span class="a">+(defun use-converter-to-html(filename &optional (converter-name nil))</span> 45 <span class="a">+ (let* ((converter-object (getf *converters*</span> 46 <span class="a">+ (or converter-name</span> 47 <span class="a">+ converter-name</span> 48 <span class="a">+ (getf *config* :default-converter))))</span> 49 <span class="a">+ (output (converter-command converter-object))</span> 50 <span class="a">+ (src-file (format nil "~a~a" filename (converter-extension converter-object)))</span> 51 <span class="a">+ (dst-file (format nil "temp/data/~a.html" filename ))</span> 52 <span class="a">+ (full-src-file (format nil "data/~a" src-file)))</span> 53 <span class="a">+ ;; skip generating if the destination exists</span> 54 <span class="a">+ ;; and is more recent than source</span> 55 <span class="a">+ (unless (and</span> 56 <span class="a">+ (probe-file dst-file)</span> 57 <span class="a">+ (>=</span> 58 <span class="a">+ (file-write-date dst-file)</span> 59 <span class="a">+ (file-write-date full-src-file)))</span> 60 <span class="a">+ (ensure-directories-exist "temp/data/")</span> 61 <span class="a">+ (template "%IN" src-file)</span> 62 <span class="a">+ (template "%OUT" dst-file)</span> 63 <span class="a">+ (format t "~a~%" output)</span> 64 <span class="a">+ (uiop:run-program output))))</span> 65 66 ;; format the date 67 (defun date-format(format date) 68 <span class="h">@@ -307,9 +310,9 @@</span> 69 70 ;; produce each article file 71 (loop for article in *articles* 72 <span class="d">- do</span> 73 <span class="d">- ;; use the article's converter to get html code of it</span> 74 <span class="d">- (use-converter-to-html article)</span> 75 <span class="a">+ do</span> 76 <span class="a">+ ;; use the article's converter to get html code of it</span> 77 <span class="a">+ (use-converter-to-html (article-id article) (article-converter article))</span> 78 79 (generate (format nil "output/html/~d-~d.html" 80 (date-format "%Year-%MonthNumber-%DayNumber"</pre> 81 </div></body></html>