Skip to content
Newer
Older
100644 101 lines (85 sloc) 5.72 KB
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
1 (in-package :cl-common-blog)
2
3 ;;;; call for hunchentoot
4
5 (defun param-get (name)
6 (hunchentoot:get-parameter name))
7
6ebb1be @gihnius publish as version 0.2
authored Sep 14, 2011
8 (defun param-get-trim (name)
9 (aif (param-get name)
10 (string-trim " " it)))
11
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
12 (defun param-post (name)
13 (hunchentoot:post-parameter name))
14
15 (defun param-post-trim (name)
6ebb1be @gihnius publish as version 0.2
authored Sep 14, 2011
16 (aif (param-post name)
17 (string-trim " " it)))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
18
19 (defun request-url ()
104da63 @gihnius update: add patch for url decode/encode
authored Oct 4, 2011
20 (hunchentoot:url-decode (hunchentoot:request-uri*)))
21
22 (defun url-encode (str)
23 (hunchentoot:url-encode str hunchentoot::+utf-8+))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
24
25 (defun login-session (user)
fe1ea1d @gihnius update ht-server, fix login
authored Sep 6, 2011
26 (setf (hunchentoot:session-value 'logined) user))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
27
28 (defun login-p ()
fe1ea1d @gihnius update ht-server, fix login
authored Sep 6, 2011
29 (hunchentoot:session-value 'logined))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
30
31 (defun logout-session ()
fe1ea1d @gihnius update ht-server, fix login
authored Sep 6, 2011
32 (hunchentoot:delete-session-value 'logined))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
33
34 (defun http-redirect (url)
35 (hunchentoot:redirect url))
36
37 (defun no-cache ()
38 (hunchentoot:no-cache))
39
40 ;;;;
41 (setf hunchentoot:*dispatch-table*
42 (list (hunchentoot:create-regex-dispatcher "^/$" 'show-index)
43 (hunchentoot:create-regex-dispatcher "^/index/\\d+$" 'show-index)
44 (hunchentoot:create-regex-dispatcher "^/index$" 'show-index)
45 (hunchentoot:create-regex-dispatcher "^/index/$" 'show-index)
104da63 @gihnius update: add patch for url decode/encode
authored Oct 4, 2011
46 (hunchentoot:create-regex-dispatcher "^/category/.+$" 'show-category-tag-index-page)
47 (hunchentoot:create-regex-dispatcher "^/tags/.+$" 'show-category-tag-index-page)
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
48 (hunchentoot:create-regex-dispatcher "^/articles/\\d\\d\\d\\d/$" 'show-archive-index)
49 (hunchentoot:create-regex-dispatcher "^/articles/\\d\\d\\d\\d/\\d\\d/$" 'show-archive-index)
50 (hunchentoot:create-regex-dispatcher "^/articles/\\d\\d\\d\\d/\\d\\d/\\d\\d/$" 'show-archive-index)
51 (hunchentoot:create-regex-dispatcher "^/article/\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d$" 'show-post)
52 (hunchentoot:create-regex-dispatcher "^/about$" 'show-about)
6ebb1be @gihnius publish as version 0.2
authored Sep 14, 2011
53 (hunchentoot:create-regex-dispatcher "^/feed$" 'show-posts-rss)
54 (hunchentoot:create-regex-dispatcher "^/comments-feed$" 'show-comments-rss)
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
55 (hunchentoot:create-regex-dispatcher "^/search$" 'show-search-page)
56 (hunchentoot:create-regex-dispatcher "^/post-comment$" 'get-post-comment)
57 (hunchentoot:create-regex-dispatcher "^/edit-category-tag$" 'edit-category-tag)
58 (hunchentoot:create-regex-dispatcher "^/post-blog$" 'get-post-blog)
59 (hunchentoot:create-regex-dispatcher "^/edit-post$" 'show-admin-page)
60 (hunchentoot:create-regex-dispatcher "^/delete-post$" 'delete-post-blog)
61 (hunchentoot:create-regex-dispatcher "^/delete-comment$" 'delete-comment-blog)
62 (hunchentoot:create-regex-dispatcher "^/admin$" 'show-admin-page)
63 (hunchentoot:create-regex-dispatcher "^/login$" 'show-login-page)
64 (hunchentoot:create-regex-dispatcher "^/auth-login$" 'auth-login)
65 (hunchentoot:create-regex-dispatcher "^/logout$" 'auth-logout)
66 (hunchentoot:create-folder-dispatcher-and-handler "/statics/" (merge-pathnames "public/statics/" *blog-root*))
67 (hunchentoot:create-static-file-dispatcher-and-handler "/blog.css" (merge-pathnames "public/blog.css" *blog-root*))
68 (hunchentoot:create-static-file-dispatcher-and-handler "/blog.js" (merge-pathnames "public/js/blog.js" *blog-root*))
69 (hunchentoot:create-static-file-dispatcher-and-handler "/jquery.min.js" (merge-pathnames "public/js/jquery.min.js" *blog-root*))
70 (hunchentoot:create-static-file-dispatcher-and-handler "/robots.txt" (merge-pathnames "public/robots.txt" *blog-root*) "text/plain")
71 (hunchentoot:create-static-file-dispatcher-and-handler "/images/buttons.gif" (merge-pathnames "public/js/cleditor/images/buttons.gif" *blog-root*) "image/gif")
72 (hunchentoot:create-static-file-dispatcher-and-handler "/images/toolbar.gif" (merge-pathnames "public/js/cleditor/images/toolbar.gif" *blog-root*) "image/gif")
73 (hunchentoot:create-static-file-dispatcher-and-handler "/images/table.gif" (merge-pathnames "public/js/cleditor/images/table.gif" *blog-root*) "image/gif")
74 (hunchentoot:create-static-file-dispatcher-and-handler "/images/code.gif" (merge-pathnames "public/js/cleditor/images/code.gif" *blog-root*) "image/gif")
75 (hunchentoot:create-static-file-dispatcher-and-handler "/jquery.cleditor.css" (merge-pathnames "public/js/cleditor/jquery.cleditor.css" *blog-root*))
76 (hunchentoot:create-static-file-dispatcher-and-handler "/jquery.cleditor.advancedtable.min.js" (merge-pathnames "public/js/cleditor/jquery.cleditor.advancedtable.min.js" *blog-root*))
77 (hunchentoot:create-static-file-dispatcher-and-handler "/jquery.cleditor.min.js" (merge-pathnames "public/js/cleditor/jquery.cleditor.min.js" *blog-root*))
78 (hunchentoot:create-static-file-dispatcher-and-handler "/jquery.cleditor.xhtml.min.js" (merge-pathnames "public/js/cleditor/jquery.cleditor.xhtml.min.js" *blog-root*))
79 ))
80
81 (defun start-blog ()
82 (unless *store-controller*
83 (open-store *db-spec*))
6ebb1be @gihnius publish as version 0.2
authored Sep 14, 2011
84 (when *store-controller*
85 (setf *total-posts* (total-posts))
86 (setf *all-posts-timestamp* (get-all-posts-timestamp))
87 (setf *total-comments* (length (get-all-comments-timestamp))))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
88 (unless *ht-server*
004bd1e @gihnius update for this version 0.x
authored Jan 1, 2012
89 (let ((blog-acceptor (make-instance 'hunchentoot:easy-acceptor :address *ht-listen*
90 :port *ht-port*
91 :access-log-destination *access-log*
92 :message-log-destination *message-log*
93 :document-root *doc-root*)))
94 (setf *ht-server* (hunchentoot:start blog-acceptor)))))
03580f2 @gihnius split hunchentoot call into ht-server.lisp
authored Sep 6, 2011
95
96 (defun stop-blog ()
97 "Close the Elephant store and stop the web server."
98 (close-store)
99 (hunchentoot:stop *ht-server*)
100 (setf *ht-server* nil))
Something went wrong with that request. Please try again.