Introduction
Introduction Statistics Contact Development Disclaimer Help
comments - cl-yag - Common Lisp Yet Another website Generator
git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws…
Log
Files
Refs
Tags
README
LICENSE
---
commit e0a4614444c18e9840e4fa30d832da9fafedfa5e
parent 91e116792c8d8cd9319a4269a6465834b4116cf2
Author: Solene Rapenne <[email protected]>
Date: Sat, 30 Apr 2016 18:21:48 +0200
comments
Diffstat:
M generator.lisp | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/generator.lisp b/generator.lisp
@@ -1,8 +1,7 @@
(load "data/articles.lisp")
+;; common-lisp don't have a replace string function natively
(defun replace-all (string part replacement &key (test #'char=))
- "Returns a new string in which all the occurences of the part
-is replaced with replacement."
(with-output-to-string (out)
(loop with part-length = (length part)
for old-pos = 0 then (+ pos part-length)
@@ -14,14 +13,14 @@ is replaced with replacement."
:end (or pos (length string)))
when pos do (write-string replacement out)
while pos)))
-; load a file as a string
+;; load a file and return it as a string
(defun slurp-file(path)
(with-open-file (stream path)
(let ((data (make-string (file-length stream))))
(read-sequence data stream)
data)))
-; save a string in a file
+;; save a string in a file
(defun save-file(path data)
(with-open-file (stream (concatenate 'string "output/" path) :direction :out…
(format stream data)))
@@ -39,6 +38,7 @@ is replaced with replacement."
output)))
;; generates the html of one only article
+;; this is called in a loop to produce the homepage
(defun create-article(article &optional &key (tiny t))
(prepare "template/article.tpl"
(template "%%Author%%" (if (member :author article) (getf article :…
@@ -48,21 +48,25 @@ is replaced with replacement."
(template "%%Text%%" (if (and tiny (member :tiny article))
(getf article :tiny) (slurp-file (format n…
-;; Layout generation
+;; return a html string
+;; produce the code of a whole page with title+layout with the parameter as th…
(defun generate-layout(body)
(let ((output (slurp-file "template/layout.tpl")))
(template "%%Title%%" (getf *config* :title))
(template "%%Body%%" body)
output))
-
-; Homepage generation
+
+
+;; Homepage generation
+;; generate each article and concatenate the whole
(defun generate-mainpage()
(format nil "~{~d~}"
(loop for article in *articles* collect
(create-article article :tiny t))))
-; ENGINE START !
+;; ENGINE START !
+;; This is function called when running the tool
(defun generate-site()
; produce index.html
@@ -75,6 +79,7 @@ is replaced with replacement."
(create-article article :tiny nil)))
;;(generate-file-rss)
+ ;;not done yet
)
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.