icomments - cl-yag - Common Lisp Yet Another website Generator Err bitreich.org 70
hgit clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/ URL:git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/ bitreich.org 70
1Log /scm/cl-yag/log.gph bitreich.org 70
1Files /scm/cl-yag/files.gph bitreich.org 70
1Refs /scm/cl-yag/refs.gph bitreich.org 70
1Tags /scm/cl-yag/tag bitreich.org 70
1README /scm/cl-yag/file/README.md.gph bitreich.org 70
1LICENSE /scm/cl-yag/file/LICENSE.gph bitreich.org 70
i--- Err bitreich.org 70
1commit e0a4614444c18e9840e4fa30d832da9fafedfa5e /scm/cl-yag/commit/e0a4614444c18e9840e4fa30d832da9fafedfa5e.gph bitreich.org 70
1parent 91e116792c8d8cd9319a4269a6465834b4116cf2 /scm/cl-yag/commit/91e116792c8d8cd9319a4269a6465834b4116cf2.gph bitreich.org 70
hAuthor: Solene Rapenne <solene@dataswamp.org> URL:mailto:solene@dataswamp.org bitreich.org 70
iDate: Sat, 30 Apr 2016 18:21:48 +0200 Err bitreich.org 70
i Err bitreich.org 70
icomments Err bitreich.org 70
i Err bitreich.org 70
iDiffstat: Err bitreich.org 70
i M generator.lisp | 21 +++++++++++++-------- Err bitreich.org 70
i Err bitreich.org 70
i1 file changed, 13 insertions(+), 8 deletions(-) Err bitreich.org 70
i--- Err bitreich.org 70
1diff --git a/generator.lisp b/generator.lisp /scm/cl-yag/file/generator.lisp.gph bitreich.org 70
i@@ -1,8 +1,7 @@ Err bitreich.org 70
i (load "data/articles.lisp") Err bitreich.org 70
i Err bitreich.org 70
i+;; common-lisp don't have a replace string function natively Err bitreich.org 70
i (defun replace-all (string part replacement &key (test #'char=)) Err bitreich.org 70
i- "Returns a new string in which all the occurences of the part Err bitreich.org 70
i-is replaced with replacement." Err bitreich.org 70
i (with-output-to-string (out) Err bitreich.org 70
i (loop with part-length = (length part) Err bitreich.org 70
i for old-pos = 0 then (+ pos part-length) Err bitreich.org 70
i@@ -14,14 +13,14 @@ is replaced with replacement." Err bitreich.org 70
i :end (or pos (length string))) Err bitreich.org 70
i when pos do (write-string replacement out) Err bitreich.org 70
i while pos))) Err bitreich.org 70
i-; load a file as a string Err bitreich.org 70
i+;; load a file and return it as a string Err bitreich.org 70
i (defun slurp-file(path) Err bitreich.org 70
i (with-open-file (stream path) Err bitreich.org 70
i (let ((data (make-string (file-length stream)))) Err bitreich.org 70
i (read-sequence data stream) Err bitreich.org 70
i data))) Err bitreich.org 70
i Err bitreich.org 70
i-; save a string in a file Err bitreich.org 70
i+;; save a string in a file Err bitreich.org 70
i (defun save-file(path data) Err bitreich.org 70
i (with-open-file (stream (concatenate 'string "output/" path) :direction :output :if-exists :supersede) Err bitreich.org 70
i (format stream data))) Err bitreich.org 70
i@@ -39,6 +38,7 @@ is replaced with replacement." Err bitreich.org 70
i output))) Err bitreich.org 70
i Err bitreich.org 70
i ;; generates the html of one only article Err bitreich.org 70
i+;; this is called in a loop to produce the homepage Err bitreich.org 70
i (defun create-article(article &optional &key (tiny t)) Err bitreich.org 70
i (prepare "template/article.tpl" Err bitreich.org 70
i (template "%%Author%%" (if (member :author article) (getf article :author) (getf *config* :webmaster))) Err bitreich.org 70
i@@ -48,21 +48,25 @@ is replaced with replacement." Err bitreich.org 70
i (template "%%Text%%" (if (and tiny (member :tiny article)) Err bitreich.org 70
i (getf article :tiny) (slurp-file (format nil "data/~d.txt" (getf article :id))))))) Err bitreich.org 70
i Err bitreich.org 70
i-;; Layout generation Err bitreich.org 70
i+;; return a html string Err bitreich.org 70
i+;; produce the code of a whole page with title+layout with the parameter as the content Err bitreich.org 70
i (defun generate-layout(body) Err bitreich.org 70
i (let ((output (slurp-file "template/layout.tpl"))) Err bitreich.org 70
i (template "%%Title%%" (getf *config* :title)) Err bitreich.org 70
i (template "%%Body%%" body) Err bitreich.org 70
i output)) Err bitreich.org 70
i- Err bitreich.org 70
i-; Homepage generation Err bitreich.org 70
i+ Err bitreich.org 70
i+ Err bitreich.org 70
i+;; Homepage generation Err bitreich.org 70
i+;; generate each article and concatenate the whole Err bitreich.org 70
i (defun generate-mainpage() Err bitreich.org 70
i (format nil "~{~d~}" Err bitreich.org 70
i (loop for article in *articles* collect Err bitreich.org 70
i (create-article article :tiny t)))) Err bitreich.org 70
i Err bitreich.org 70
i Err bitreich.org 70
i-; ENGINE START ! Err bitreich.org 70
i+;; ENGINE START ! Err bitreich.org 70
i+;; This is function called when running the tool Err bitreich.org 70
i (defun generate-site() Err bitreich.org 70
i Err bitreich.org 70
i ; produce index.html Err bitreich.org 70
i@@ -75,6 +79,7 @@ is replaced with replacement." Err bitreich.org 70
i (create-article article :tiny nil))) Err bitreich.org 70
i Err bitreich.org 70
i ;;(generate-file-rss) Err bitreich.org 70
i+ ;;not done yet Err bitreich.org 70
i ) Err bitreich.org 70
i Err bitreich.org 70
i Err bitreich.org 70
.
Response:
text/plain