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