adding a way to choose the number of rss items - cl-yag - Common Lisp Yet Another website Generator
HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 76baf068a53ee155aa4850c0beac0ecfeb51b59d
DIR parent 5224dea43a91267d621f6ed78fcea25ed5c67243
HTML Author: solene rapenne <solene@dataswamp.org>
Date: Wed, 8 Jun 2016 12:25:02 +0200
adding a way to choose the number of rss items
Diffstat:
M README.md | 10 ++++++++++
M data/articles.lisp | 1 +
M generator.lisp | 4 +++-
3 files changed, 14 insertions(+), 1 deletion(-)
---
DIR diff --git 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)
DIR diff --git 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)
DIR diff --git 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))))