Skip to content

Commit ba058e4

Browse files
committed
Refactor webapp.lisp update-table + render for note
Based on Alexander Artemenko (@svetlyak40wt) tips I did this. The co-existance of update-table and update-proposition it's unecessary and confuse. There is some problems about rendering string, add render-note instead of defining that all strings will be rendered using :pre.
1 parent 738df95 commit ba058e4

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

web/webapp.lisp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,23 @@
5757
:prop (format nil "~a" exp)
5858
:truth (truth-table exp)))
5959

60-
(defun update-table (table exp)
61-
(setf (prop table) (format nil "~a" exp))
62-
(setf (truth table) (truth-table exp)))
63-
64-
(defgeneric update-proposition (table exp))
60+
(defgeneric update-table (table exp))
6561

66-
(defmethod update-proposition (table (exp list))
67-
(update-table table exp)
62+
(defmethod update-table (table (exp list))
63+
(setf (prop table) (format nil "~a" exp))
64+
(setf (truth table) (truth-table exp))
6865
(update table))
6966

70-
(defmethod update-proposition (table (string string))
71-
(update-proposition
72-
table
73-
(parse-string string)))
67+
(defmethod update-table (table (exp string))
68+
(update-table
69+
table
70+
(parse-string exp)))
7471

7572
(defmethod render ((table table))
7673
(with-html
7774
(:h1 "Lisp Inference Truth Table System")
7875
(with-html-form (:POST (lambda (&key prop &allow-other-keys)
79-
(update-proposition table prop)))
76+
(update-table table prop)))
8077
(:input :type "text"
8178
:name "prop"
8279
:placeholder (prop table))
@@ -87,7 +84,7 @@
8784
(:p "Some notes: "
8885
(:ul
8986
(loop for note in *notes*
90-
do (:li (render note)))))
87+
do (:li (render-note note)))))
9188
(:span "Source: "
9289
(:a :href "https://github.com/ryukinix/lisp-inference"
9390
"ryukinix/lisp-inference"))
@@ -96,7 +93,7 @@
9693
(:a :href
9794
"https://lerax.me/lisp-inference" "lerax.me/lisp-inference"))))
9895

99-
(defmethod render ((string string))
96+
(defun render-note (string)
10097
(with-html
10198
(:pre string)))
10299

0 commit comments

Comments
 (0)