Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


commit 90c19265b9f782d0106bae0e2172a4e7d6f65477
Solene Rapenne <solene@perso.pw>
2019-11-13 19:20:43 +0100

make history displaying a browseable gopher menu

 clic.1    |  2 +-
 clic.lisp | 31 ++++++++++++++++++++++---------
 2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/clic.1 b/clic.1
index 25aed60..850d7ad 100644
--- a/clic.1
+++ b/clic.1
@@ -53,7 +53,7 @@ Follows the link numbered
 .It Cm p | / | cd ..
 Go to previous page.
 .It Cm h
-Display the history.
+Display the history as a browseable menu.
 .It Cm sNUMBER
 Show the full URL of link numbered
 .Cm NUMBER .
diff --git a/clic.lisp b/clic.lisp
index 9402351..a11b4a1 100644
--- a/clic.lisp
+++ b/clic.lisp
@@ -40,7 +40,7 @@
 ;;;; END C binding
 
 ;; structure to store links
-(defstruct location host port type uri tls
+(defstruct location host port type uri tls text
            :predicate)
 
 ;;;; kiosk mode 
@@ -207,13 +207,13 @@
                 ;; 0 text file
                 (check "0"
                        (setf (gethash line-number *links*)
-                             (make-location :host host :port port :uri uri :type line-type ))
+                             (make-location :host host :port port :uri uri :type line-type :text text))
                        (print-with-color text 'file line-number))
 
                 ;; 1 directory
                 (check "1"
                        (setf (gethash line-number *links*)
-                             (make-location :host host :port port :uri uri :type line-type ))
+                             (make-location :host host :port port :uri uri :type line-type :text text))
                        (print-with-color text 'folder line-number))
 
                 ;; 2 CSO phone-book
@@ -239,7 +239,7 @@
                 ;; 7 Index search server
                 (check "7"
                        (setf (gethash line-number *links*)
-                             (make-location :host host :port port :uri uri :type line-type ))
+                             (make-location :host host :port port :uri uri :type line-type :text text))
                        (print-with-color text 'red line-number))
 
                 ;; 8 Telnet session
@@ -249,7 +249,7 @@
                 ;; 9 Binary
                 (check "9"
                        (setf (gethash line-number *links*)
-                             (make-location :host host :port port :uri uri :type line-type ))
+                             (make-location :host host :port port :uri uri :type line-type :text text))
                        (print-with-color text 'red line-number))
 
                 ;; + redundant server
@@ -263,13 +263,13 @@
                 ;; g GIF file
                 (check "g"
                        (setf (gethash line-number *links*)
-                             (make-location :host host :port port :uri uri :type line-type))
+                             (make-location :host host :port port :uri uri :type line-type :text text))
                        (print-with-color text 'red line-number))
 
                 ;; I image
                 (check "I"
                        (setf (gethash line-number *links*)
-                             (make-location :host host :port port :uri uri :type line-type ))
+                             (make-location :host host :port port :uri uri :type line-type :text text))
                        (print-with-color text 'red line-number))
 
                 ;; h http link
@@ -444,6 +444,7 @@
         ((= 0 (or (search "file://" url) 1))
          (load-file-menu (subseq url 7))
          (make-location :host 'local-file
+                        :text url
                         :port nil
                         :type "1"
                         :uri url))
@@ -465,6 +466,8 @@
                                        (parse-integer (car host-port))
                                        70)
 
+                             :text url
+
                              ;; if type is empty we default to "1"
                              :type (let ((type (pop infos)))
                                      (if (< 0 (length type)) type "1"))
@@ -528,7 +531,17 @@
 
     ;; show history
     ((string= "h" input)
-     (format t "~{~a~%~}" *history*))
+      (setf *links* (make-hash-table))
+        (loop for element in *history*
+          do
+            (formatted-output
+              (format nil "~a~a	~a	~a	~a~%"
+                    (location-type element)
+                    (location-text element)
+                    (location-uri element)
+                    (location-host element)
+                    (location-port element)))))
+
 
     ;; follow a link
     (t
@@ -782,7 +795,7 @@
 
       ;; if we didn't passed a url as parameter, use a default
       (if (not (location-p destination))
-          (setf destination (make-location :host "gopherproject.org" :port 70 :uri "/" :type "1")))
+          (setf destination (make-location :host "gopherproject.org" :port 70 :uri "/" :type "1" :text "gopherproject")))
 
       ;; is there an output redirection ?
       (if (ttyp)