Recently Written · git

cl-yag

Mirror and rewrite of Solène Rapenne's cl-yag SSG of renown

git clone https://github.com/equwal/cl-yag

Log | Files | Refs


commit 76baf068a53ee155aa4850c0beac0ecfeb51b59d
solene rapenne <solene@dataswamp.org>
2016-06-08 12:25:02 +0200

adding a way to choose the number of rss items

 README.md          | 10 ++++++++++
 data/articles.lisp |  1 +
 generator.lisp     |  4 +++-
 3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 73f43a7..ab9e31a 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,16 @@ Here are the files and folder of cl-yag :
 
 # Usage
 
+## Configuration
+
+In data/articles.lisp there is a ***config*** variable with the following fields :
+
++ **:webmaster** : The name of the default author, this is the name used when **:author** is omitted
++ **:title** : The title of the webpage
++ **:description** : This text is used in the *description* field of the Atom RSS
++ **:url** : This is the full url of the blog with the final slash. If the url contains a ~ it should be doubled (e.g. : https://mydomain/~~user/ is a valid url)
++ **:rss-item-number** : This is the number of RSS items you want to published when you generate the files, it will publish the last N articles
+
 ## How to add an article
  
 Edit data/articles.lisp and add a new line inside the *articles* variable like this (you can do it in one line, as you prefer)
diff --git a/data/articles.lisp b/data/articles.lisp
index d9ae3a3..7b6f9c1 100644
--- a/data/articles.lisp
+++ b/data/articles.lisp
@@ -10,6 +10,7 @@
    :title "Your blog title here"
    :description "Yet another website on the net"
    :url "https://my.website/~~user/" ;; the trailing slash is mandatory, rss links will fails without it
+   :rss-item-number 10 ;; we want 10 items in our RSS feed
    ))
 
 ;; describes articles (ordered on the website as they are displayed here, the first in list is the top of the website)
diff --git a/generator.lisp b/generator.lisp
index 9ff7d25..c800524 100644
--- a/generator.lisp
+++ b/generator.lisp
@@ -131,7 +131,9 @@
 ;; xml generation of the items for the rss
 (defun generate-rss-item()
   (strip-quotes
-   (loop for article in *articles* collect
+   (loop for article in *articles*
+	 for i from 1 to (if (> (length *articles*) (getf *config* :rss-item-number)) (getf *config* :rss-item-number) (length *articles*))
+	 collect
 	 (prepare "template/rss-item.tpl"
 		  (template "%%Title%%" (getf article :title))
 		  (template "%%Description%%" (load-file (format nil "data/~d.txt" (getf article :id))))