sort tags list per articles in it

This commit is contained in:
Solene Rapenne 2018-10-12 11:50:16 +02:00
parent 142b84ab78
commit e9fb727d69
2 changed files with 15 additions and 3 deletions

View File

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

View File

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