Browse code

Added SVG generation

Jaidyn Lev authored on 2018-06-14 20:35:52
Showing 4 changed files
... ...
@@ -6,6 +6,8 @@
6 6
     :create-entry
7 7
 
8 8
     :init
9
-    :dm-txt))
9
+    :dm-txt
10
+    :dm-svg
11
+    :dm-html))
10 12
 
11 13
 (in-package :doormat)
... ...
@@ -38,3 +38,31 @@
38 38
                            (format nil "~A" visitors)
39 39
                            (format nil "1"))
40 40
                          " visitors! :)</p></div>"))))
41
+
42
+
43
+(defun dm-svg ()
44
+  "Prints out/creates visitor-count for the requesed URL in SVG."
45
+  
46
+  (format t "Content-Type: image/svg+xml~%~%")
47
+
48
+  (let ((visitors (doormat:fetch-visitors cl-cgi:*query-string*)))
49
+    (if visitors
50
+      (doormat:increment-visitors cl-cgi:*query-string*)
51
+      (doormat:create-entry cl-cgi:*query-string*))
52
+
53
+    (if (not visitors)
54
+      (setq visitors 1))
55
+
56
+    (format t
57
+            "<!DOCTYPE svg PUBLIC
58
+            \"-//W3C//DTD SVG 1.1//EN\"
59
+            \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">
60
+            <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"
61
+            xmlns:xlink=\"http://www.w3.org/1999/xlink\"
62
+            xml:space=\"preserve\">
63
+
64
+            <text x=\"0\" y=\"15\" fill=\"red\">
65
+              ~A people've visited this page! :)
66
+            </text>
67
+            </svg>" visitors)))
68
+
41 69
new file mode 100755
... ...
@@ -0,0 +1,3 @@
1
+#!/bin/sh
2
+
3
+sbcl --core doormat.core --script res/exec/dm-svg.lisp
0 4
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+(doormat:init)
2
+
3
+(doormat:dm-svg)