Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 53 lines (44 sloc) 1.525 kB
4b05a86 @archimag update examples
authored
1 ;;;; example 2
09bce2b @archimag update
authored
2
4b05a86 @archimag update examples
authored
3 (asdf:operate 'asdf:load-op :cl-who)
09bce2b @archimag update
authored
4 (asdf:operate 'asdf:load-op :restas)
5
4b05a86 @archimag update examples
authored
6 (restas:defsite :restas.example-2
7 (:use :cl :iter))
09bce2b @archimag update
authored
8
9 (in-package :restas.example-2)
10
4b05a86 @archimag update examples
authored
11 (restas:define-site-plugin default (:restas.example-2))
12
13 (define-route root ("")
14 (who:with-html-output-to-string (out)
15 (:html
16 (:head
17 (:title "Example 2: Index"))
18 (:body
19 (:h1 "Index")
20 (:ul
21 (iter (for x from 1 to 10)
22 (who:htm (:li
23 ((:a :href (genurl 'chapter-?.html :id x))
24 (who:fmt "Chapter ~A" x))))))))))
25
26 (define-route chapter-?.html ("chapter-:(id).html")
27 (who:with-html-output-to-string (out)
28 (:html
29 (:head
30 (:title (who:fmt "Example 2. Chapter ~A" id)))
31 (:body
32 (:h1 (who:fmt "Chapter ~A" id))
33 (:ul
34 (iter (for x from 1 to 10)
35 (who:htm (:li
36 ((:a :href (genurl 'chapter-?-?.html :id1 id :id2 x))
37 (who:fmt "Chapter ~A-~A" id x))))))
38 ((:a :href (genurl 'root))
39 "Back to Index")))))
40
41 (define-route chapter-?-?.html ("chapter-:(id1)-:(id2).html")
42 (who:with-html-output-to-string (out)
43 (:html
44 (:head
45 (:title (who:fmt "Example 2. Chapter ~A-~A" id1 id2)))
46 (:body
47 (:h1 (who:fmt "Chapter ~A-~A" id1 id2))
48 (:p (who:fmt "This is a chapter ~A-~A" id1 id2))
49 ((:a :href (genurl 'chapter-?.html :id id1))
50 (who:fmt "Back to Chapter ~A" id1))))))
81da31b @archimag update examples
authored
51
4b05a86 @archimag update examples
authored
52 (restas:start-site :restas.example-2 :port 8080)
Something went wrong with that request. Please try again.