sort tags list per articles in it - 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 e9fb727d69131de4b7b2662825bc130e2bf0020d
DIR parent 142b84ab78cb64423e2781a3e520bbd1e9cb40cd
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Fri, 12 Oct 2018 11:50:16 +0200
sort tags list per articles in it
Diffstat:
M data/articles.lisp | 3 ++-
M generator.lisp | 15 +++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
---
DIR diff --git a/data/articles.lisp b/data/articles.lisp
@@ -47,7 +47,8 @@
(post :title "test"
- :id "t" :date "20171214" :tag "f" :converter :org-mode)
+ :id "t" :date "20171214" :tag "cl-yag" :converter :org-mode)
+
;; CSS
(post :title "CSS For cl-yag"
:id "css" :date "20171202" :tag "cl-yag"
DIR diff --git a/generator.lisp b/generator.lisp
@@ -357,7 +357,10 @@
(ensure-directories-exist directory-path)
(save-file index-path
(let ((output (load-file "templates/gopher_head.tpl")))
- (loop for tag in (articles-by-tag)
+ (loop for tag in
+ ;; sort tags per articles in it
+ (sort (articles-by-tag) #'>
+ :key #'(lambda (x) (length (getf x :value))))
do
(setf output
(string
@@ -365,7 +368,15 @@
'string output
(format nil (getf *config* :gopher-format)
1 ;; gopher type, 1 for menus
- (getf tag :NAME)
+ ;; here we create a 72 width char string with title on the left
+ ;; and number of articles on the right
+ ;; we truncate the article title if it's too large
+ (let ((title (format nil "~72a"
+ (if (< 72 (length (getf tag :NAME)))
+ (subseq (getf tag :NAME) 0 80)
+ (getf tag :NAME))))
+ (article-number (format nil "~d article~p" (length (getf tag :value)) (length (getf tag :value)))))
+ (replace title article-number :start1 (- (length title) (length article-number))))
(concatenate 'string
(getf *config* :gopher-path) "/" (getf tag :NAME) "/")
(getf *config* :gopher-server)