blob: 0c80060a9053c6a2990fd3d925f9e46aa8746800 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
(ql:quickload '(hunchentoot spinneret cl-yesql cl-yesql/sqlite parenscript))
(defpackage :webstats
(:use :common-lisp :hunchentoot :spinneret))
(defpackage :webstats-js
(:use :cl :parenscript))
(in-package :webstats-js)
(setf *js-target-version* "1.9")
(in-package :webstats)
(overlord:set-package-base "/home/titan/dev/scratch/webstats/")
(yesql:import log-queries
:from "/home/titan/dev/scratch/webstats/queries.sql"
:as :cl-yesql/sqlite
:binding :all-functions)
;; (sqlite:with-open-database (db "test.db")
;; (drop-stats-table db)
;; (create-stats-table db))
;; (sqlite:with-open-database (db "test.db")
;; (insert db
;; :click nil
;; :page "ho"
;; :referer "ref"
;; :ip "13"
;; :user-agent "sly"
;; :title "try"))
(defvar *acceptor* (make-instance 'hunchentoot:easy-acceptor
:port 4252))
(hunchentoot:start *acceptor*)
(hunchentoot:define-easy-handler (vars-disp :uri "/vars") ()
(setf (hunchentoot:content-type*) "text/plain")
(format nil "Hey ~{~A ~% ~}~%"
(list
(remote-addr*)
(header-in* :x-forwarded-for)
(authorization)
(hunchentoot::iso-time)
(request-method*)
(script-name*)
(query-string*)
(server-protocol*)
(return-code*)
(content-length*)
(referer)
(user-agent))))
(hunchentoot:define-easy-handler
(visit :uri "/visit" :default-request-type :both)
(title page referer click)
(sqlite:with-open-database (db "test.db")
(format nil "you are our visit ~d"
(insert db
:click click
:page page
:referer referer
:ip (remote-addr*)
:user-agent (user-agent)
:title title))))
(hunchentoot:define-easy-handler (stat-js :uri "/stats.js") ()
(ps:ps-compile-file "stats.paren"))
(hunchentoot:define-easy-handler (link :uri "/link") ()
(with-html-string
(:doctype)
(:html
(:header (:title "hu yu ipi")
(:script :src "/stats.js"))
(:body
(:p "learning "
(:a :href "vars" "some explodiert")
(:a :href "visit" "count visit"))
(:form :action "/visit"
:method "post"
(:input :type "text" :name "title")
(:input :type "submit" :value "submit" :name "submit"))))
))
|