Add articles metadata as header in gopher articles - cl-yag - Common Lisp Yet Another website Generator
 (HTM) 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 eeb8131035ae98f04288c319848f23acb16c35cd
 (DIR) parent e9fb727d69131de4b7b2662825bc130e2bf0020d
 (HTM) Author: Solene Rapenne <solene@perso.pw>
       Date:   Fri, 12 Oct 2018 16:56:55 +0200
       
       Add articles metadata as header in gopher articles
       
       Diffstat:
         M generator.lisp                      |      22 ++++++++++++++--------
         M templates/gopher_head.tpl           |       1 +
       
       2 files changed, 15 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/generator.lisp b/generator.lisp
       @@ -24,7 +24,6 @@
           (declare (ignore second minute hour date month year dst-p tz))
           day-of-week))
        
       -
        ;; parse the date to
        (defun date-parse(date)
          (if (= 8 (length date))
       @@ -41,7 +40,7 @@
                 :year year))
            nil))
        
       -(defun post(&optional &key title tag date id (tiny nil) (author nil) (converter nil))
       +(defun post(&optional &key title tag date id (tiny nil) (author (getf *config* :webmaster)) (converter nil))
          (push (make-article :title title
                              :tag tag
                              :date (date-parse date)
       @@ -394,13 +393,20 @@
                 (ensure-directories-exist directory-path)
                 (save-file index-path (generate-gopher-index articles-with-tag))))
        
       -  ;; produce each article file (only a copy/paste in fact)
       +  ;; produce each article file (adding some headers)
          (loop for article in *articles*
       -        do
       -        (with-converter
       -         (let ((id (article-id article)))
       -           (save-file (format nil "output/gopher/article-~d.txt" id)
       -                      (load-file (format nil "data/~d~d" id (converter-extension converter-object))))))))
       +     do
       +       (with-converter
       +           (let ((id (article-id article)))
       +             (save-file (format nil "output/gopher/article-~d.txt" id)
       +                        (format nil "~{~a~}"
       +                                (list
       +                                 "Title: " (article-title article) "~%"
       +                                 "Author: " (article-author article) "~%"
       +                                 "Date: " (date-format (getf *config* :date-format) (article-date article)) "~%"
       +                                 "Tags: " (article-tag article) "~%"
       +                                 "==========~%~%"
       +                                 (load-file (format nil "data/~d~d" id (converter-extension converter-object))))))))))
        
        
        ;; This is function called when running the tool
 (DIR) diff --git a/templates/gopher_head.tpl b/templates/gopher_head.tpl
       @@ -2,6 +2,7 @@ Hello, this is the head of your gophermap page, you can
        customize it how you want !
        
        [0|RSS Feed|/~me/rss.xml|server|port]
       +[1|Phlog index|/~me/|server|port]
        [1|Browse by tag|/~me/_tags_/|server|port]
        
         -----------------------------------------------------------------