Skip to content

Commit b543ef5

Browse files
authored
Merge pull request #27 from ryukinix/improvements
Add make server and refactor webapp after feedback
2 parents 0216fc3 + ba058e4 commit b543ef5

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ check:
1313
@$(SBCL_CMD) run-test.lisp
1414

1515

16+
server:
17+
@$(SBCL_CMD) run-server.lisp
18+
1619
.PHONY: check

run-server.lisp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(load "fix-quicklisp")
2+
(ql:quickload :lisp-inference/web)
3+
(webapp:start)
4+
(loop do
5+
(sleep 10))

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)