Introduction
Introduction Statistics Contact Development Disclaimer Help
Merge branch 'cl-yag' from Solene's master - cl-yag - Common Lisp Yet Another w…
git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws…
Log
Files
Refs
Tags
README
LICENSE
---
commit 2a146ce064617e43c80f9c41ceef007843bea20d
parent 5024296da286dd15e183886cd4110e05a6049078
Author: lambda <[email protected]>
Date: Wed, 29 Nov 2017 11:16:10 +0100
Merge branch 'cl-yag' from Solene's master
Diffstat:
M Makefile | 10 +---------
M README.md | 2 +-
M data/README.md | 2 +-
M data/articles.lisp | 4 ++--
M generator.lisp | 97 ++++++++++++++++-------------…
5 files changed, 54 insertions(+), 61 deletions(-)
---
diff --git a/Makefile b/Makefile
@@ -5,18 +5,10 @@ HTMLDIR= temp/data
ARTICLES!= ls data/*.md
HTML= $(ARTICLES:.md=.html)
-.if "${LISP}" == "sbcl"
-PARAM=--dynamic-space-size 90 --script
-.elif "${LISP}" == "clisp"
-PARAM=
-.elif "${LISP}" == "ecl"
-PARAM=-shell
-.endif
-
all: clean dirs html
html: $(HTML) css
- $(LISP) $(PARAM) generator.lisp
+ $(LISP) --load generator.lisp
rm -fr "temp"
dirs:
diff --git a/README.md b/README.md
@@ -3,7 +3,7 @@
## Introduction
-cl-yag is a very lightweight, static-site generator that produces **gopher** s…
+cl-yag is a very lightweight, static site generator that produces **gopher** s…
The name 'cl-yag' stands for 'Common Lisp - Yet Another website Generator'.
It runs without Quicklisp.
diff --git a/data/README.md b/data/README.md
@@ -3,7 +3,7 @@
## Introduction
-cl-yag is a very lightweight, static-site generator that produces **gopher** s…
+cl-yag is a very lightweight, static site generator that produces **gopher** s…
The name 'cl-yag' stands for 'Common Lisp - Yet Another website Generator'.
It runs without Quicklisp.
diff --git a/data/articles.lisp b/data/articles.lisp
@@ -34,10 +34,10 @@
(defvar *articles*
(list
;; README
- (list :id "README" :date "23 November 2016" :tag "cl-yag README"
+ (list :id "README" :date "23 November 2017" :tag "cl-yag README"
:title "README" :author "lambda" :short "cl-yag's README got rewo…
;; 1
- (list :id "1" :date "29 April 2016":tag "pony code"
+ (list :id "1" :date "29 April 2016" :tag "pony code"
:title "My first message" :short "This is my first message" :author "…
))
diff --git a/generator.lisp b/generator.lisp
@@ -15,31 +15,32 @@
while pos)))
;; common-lisp don't have a split string function natively
-;; thanks https://gist.github.com/siguremon/1174988
-(defun split-str-1 (string &optional (separator " ") (r nil))
- (let ((n (position separator string
- :from-end t
- :test #'(lambda (x y)
- (find y x :test #'string=)))))
- (if n
- (split-str-1 (subseq string 0 n) separator (cons (subseq string (1+ n)…
- (cons string r))))
-(defun split-str (string &optional (separator " "))
- (split-str-1 string separator))
-
-;; we have to remove the quotes
-;; when using collect in a loop
-(defun strip-quotes(input)
- (format nil "~{~d~%~}" input))
+(defun split-str(text &optional (separator #\Space))
+ "this function split a string with separator and return a list"
+ (let ((text (concatenate 'string text (string separator))))
+ (loop for char across text
+ counting char into count
+ when (char= char separator)
+ collect
+ ;; we look at the position of the left separator from right to left
+ (let ((left-separator-position (position separator text :from-end t …
+ (subseq text
+ ;; if we can't find a separator at the left of the current…
+ ;; the string
+ (if left-separator-position (+ 1 left-separator-position) …
+ (- count 1))))))
;; load a file as a string
;; we escape ~ to avoid failures with format
(defun load-file(path)
(if (probe-file path)
(replace-all
- (strip-quotes
- (with-open-file (stream path)
- (loop for line = (read-line stream nil) while line col…
+ (apply #'concatenate 'string
+ (with-open-file (stream path)
+ (loop for line = (read-line stream nil)
+ while line
+ collect
+ (format nil "~a~%" line))))
"~" "~~")
(progn
(format t "ERROR : file ~a not found. Aborting~%" path)
@@ -82,18 +83,18 @@
;; generates the html of the list of tags for an article
(defun get-tag-list-article(&optional article)
- (strip-quotes
- (mapcar #'(lambda (item)
- (prepare "templates/one-tag.tpl" (template "%%Name%%" item)))
- (split-str (getf article :tag)))))
+ (apply #'concatenate 'string
+ (mapcar #'(lambda (item)
+ (prepare "templates/one-tag.tpl" (template "%%Name%%" ite…
+ (split-str (getf article :tag)))))
;; generates the html of the whole list of tags
(defun get-tag-list()
- (strip-quotes
- (mapcar #'(lambda (item)
- (prepare "templates/one-tag.tpl"
- (template "%%Name%%" (getf item :name))))
- (articles-by-tag))))
+ (apply #'concatenate 'string
+ (mapcar #'(lambda (item)
+ (prepare "templates/one-tag.tpl"
+ (template "%%Name%%" (getf item :name))))
+ (articles-by-tag))))
;; generates the html of one only article
@@ -123,31 +124,31 @@
;; html generation of index homepage
(defun generate-semi-mainpage(&key (tiny t) (no-text nil))
- (strip-quotes
- (loop for article in *articles* collect
- (create-article article :tiny tiny :no-text no-text))))
+ (apply #'concatenate 'string
+ (loop for article in *articles* collect
+ (create-article article :tiny tiny :no-text no-text))))
;; html generation of a tag homepage
(defun generate-tag-mainpage(articles-in-tag)
- (strip-quotes
- (loop for article in *articles*
- when (member (getf article :id) articles-in-tag :test #'equal)
- collect (create-article article :tiny t))))
+ (apply #'concatenate 'string
+ (loop for article in *articles*
+ when (member (getf article :id) articles-in-tag :test #'equal)
+ collect (create-article article :tiny t))))
;; xml generation of the items for the rss
(defun generate-rss-item()
- (strip-quotes
- (loop for article in *articles*
- for i from 1 to (if (> (length *articles*) (getf *config* :rss-item-n…
- collect
- (prepare "templates/rss-item.tpl"
- (template "%%Title%%" (getf article :title))
- (template "%%Description%%" (load-file (format nil "temp/dat…
- (template "%%Url%%"
- (format nil "~darticle-~d.html"
- (getf *config* :url)
- (getf article :id)))))))
-
+ (apply #'concatenate 'string
+ (loop for article in *articles*
+ for i from 1 to (if (> (length *articles*) (getf *config* :rss-ite…
+ collect
+ (prepare "templates/rss-item.tpl"
+ (template "%%Title%%" (getf article :title))
+ (template "%%Description%%" (load-file (format nil "tem…
+ (template "%%Url%%"
+ (format nil "~darticle-~d.html"
+ (getf *config* :url)
+ (getf article :id)))))))
+
;; Generate the rss xml data
(defun generate-rss()
(prepare "templates/rss.tpl"
@@ -225,4 +226,4 @@
(create-gopher-hole)))
(generate-site)
-
+(quit)
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.