Browse code

Added HTML guest-count

Jaidyn Lev authored on 2018-06-14 19:35:09
Showing 7 changed files
... ...
@@ -7,7 +7,7 @@
7 7
 
8 8
 
9 9
 (defun dm-txt ()
10
-  "Prints out/creates visitor-count for the requested URL."
10
+  "Prints out/creates visitor-count for the requested URL in plain-text."
11 11
 
12 12
   (format t "Content-Type: text/plain~%~%")
13 13
 
... ...
@@ -19,3 +19,22 @@
19 19
     (if visitors
20 20
       (format t "~A" visitors)
21 21
       (format t "1"))))
22
+
23
+
24
+(defun dm-html ()
25
+  "Prints out/creates visitor-count for the requested URL in HTML."
26
+
27
+  (format t "Content-Type: text/html~%~%")
28
+
29
+  (let ((visitors (doormat:fetch-visitors cl-cgi:*query-string*)))
30
+    (if visitors
31
+      (doormat:increment-visitors cl-cgi:*query-string*)
32
+      (doormat:create-entry cl-cgi:*query-string*))
33
+  
34
+    (format t
35
+            (concatenate `string
36
+                         "<div id='visitor-count'><p>This page's had "
37
+                         (if visitors
38
+                           (format nil "~A" visitors)
39
+                           (format nil "1"))
40
+                         " visitors! :)</p></div>"))))
... ...
@@ -1,16 +1,16 @@
1 1
 To set up Doormat, you need to:
2 2
 
3 3
 
4
-1) Place `dm.cgi` and `dm-txt.lisp` on your webserver somewhere.
4
+1) Place `dm-*.cgi` and `res/` on your webserver somewhere.
5 5
 
6 6
 2) Use ASDF, Quicklisp, or whatever to load the :doormat package and all of
7 7
    its dependencies.
8 8
 
9 9
 3) Make a core-file (save-lisp-and-die "doormat.core"), and place it in your
10
-   webserver in the same directory as dm.cgi and dm-txt.lisp under the name
10
+   webserver in the same directory as `dm.cgi` and `res/` under the name
11 11
    of `doormat.core`
12 12
 
13
-3.5) Steps 2 and 3 can be automated/made easier with the "generate-core.lisp"
13
+3.5) Steps 2 and 3 can be automated/made easier with the "res/exec/generate-core.lisp"
14 14
      script. If you have SBCL and Quicklisp installed, it'll make a Doormat
15 15
      core automatically. :)
16 16
 
17 17
new file mode 100755
... ...
@@ -0,0 +1,3 @@
1
+#!/bin/sh
2
+
3
+sbcl --core doormat.core --script res/exec/dm-html.lisp
0 4
new file mode 100755
... ...
@@ -0,0 +1,3 @@
1
+#!/bin/sh
2
+
3
+sbcl --core doormat.core --script res/exec/dm-txt.lisp
0 4
deleted file mode 100755
... ...
@@ -1,3 +0,0 @@
1
-#!/bin/sh
2
-
3
-sbcl --core doormat.core --script dm-txt.lisp
4 0
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+(doormat:init)
2
+
3
+(doormat:dm-html)
0 4
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+(doormat:init)
2
+
3
+(doormat:dm-txt)