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 0beb1a03cf6a8f8aa14c515b74938bddc7b33fbe
Solène Rapenne <solene@perso.pw>
2017-03-24 13:07:52 +0100

fixing gopher title

 generator.lisp | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/generator.lisp b/generator.lisp
index 3ceaeb3..a69ff2f 100644
--- a/generator.lisp
+++ b/generator.lisp
@@ -186,16 +186,26 @@
 	     (let ((output (load-file "template/gopher_head.tpl")))
 	       (dolist (article *articles*)
 		 (setf output
-		       (concatenate 'string output
-				    (format nil "~a by ~a (~a) ~%0~a	/article-~d.txt	~a	~a~%~%"
-					    (getf article :date)
-					    (getf article :author (getf *config* :webmaster))
-					    (format nil "~{#~a ~}" (split-str (getf article :tag)))
-					    (getf article :title)
-					    (getf article :id)
-					    (getf *config* :gopher-server)
-					    (getf *config* :gopher-port)
-					    ))))
+		       (string
+			(concatenate 'string output
+				     (format nil "0~a	~a/article-~d.txt	~a	~a~%~%"
+					     
+					     ;; here we create a 80 width char string with title on the left
+					     ;; and date on the right
+					     ;; we truncate the article title if it's too large
+					     (let ((title (format nil "~80a"
+								  (if (< 80 (length (getf article :title)))
+								      (subseq (getf article :title) 0 80)
+								    (getf article :title)))))
+					       (replace title (getf article :date) :start1 (- (length title) (length (getf article :date)))))
+					     
+					     
+					     (getf *config* :gopher-path)
+					     (getf article :id)
+					     (getf *config* :gopher-server)
+					     (getf *config* :gopher-port)
+					     )))))
+	       
 	       output))
   
   ;; produce each article file (only a copy/paste in fact)