adding a way to choose the number of rss items

This commit is contained in:
solene rapenne 2016-06-08 12:25:02 +02:00
parent 5224dea43a
commit 76baf068a5
3 changed files with 14 additions and 1 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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))))