make history displaying a browseable gopher menu - clic - Clic is an command line interactive client for gopher written in Common LISP
HTML git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 90c19265b9f782d0106bae0e2172a4e7d6f65477
DIR parent f79c520e1489d0c5a69ec274057e562db47d8369
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Wed, 13 Nov 2019 19:20:43 +0100
make history displaying a browseable gopher menu
Diffstat:
M clic.1 | 2 +-
M clic.lisp | 31 ++++++++++++++++++++++---------
2 files changed, 23 insertions(+), 10 deletions(-)
---
DIR diff --git 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 .
DIR diff --git 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)