Recently Written · git

cl-yag

Mirror and rewrite of Solène Rapenne's cl-yag SSG of renown

git clone https://github.com/equwal/cl-yag

Log | Files | Refs


commit eeb8131035ae98f04288c319848f23acb16c35cd
Solene Rapenne <solene@perso.pw>
2018-10-12 16:56:55 +0200

Add articles metadata as header in gopher articles

 generator.lisp            | 22 ++++++++++++++--------
 templates/gopher_head.tpl |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/generator.lisp b/generator.lisp
index 86aa752..26c4829 100644
--- 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
diff --git a/templates/gopher_head.tpl b/templates/gopher_head.tpl
index d4b1248..a2fbef5 100644
--- 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]
 
  -----------------------------------------------------------------