Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 56 lines (48 sloc) 1.67 kB
2179dbd @archimag added COPYING
authored
1 ;;;; example-2.lisp
2 ;;;;
3 ;;;; This file is part of the RESTAS library, released under Lisp-LGPL.
4 ;;;; See file COPYING for details.
5 ;;;;
6 ;;;; Author: Moskvitin Andrey <archimag@gmail.com>
7
c988dcb @archimag Fixes in the examples.
authored
8 (ql:quickload "cl-who")
9 (ql:quickload "restas")
09bce2b @archimag update
authored
10
f4fe75f @archimag fix examples
authored
11 (restas:define-module #:restas.example-2
12 (:use #:cl #:iter))
09bce2b @archimag update
authored
13
f4fe75f @archimag fix examples
authored
14 (in-package #:restas.example-2)
09bce2b @archimag update
authored
15
f4fe75f @archimag fix examples
authored
16 (restas:define-route root ("")
4b05a86 @archimag update examples
authored
17 (who:with-html-output-to-string (out)
18 (:html
19 (:head
20 (:title "Example 2: Index"))
21 (:body
22 (:h1 "Index")
23 (:ul
24 (iter (for x from 1 to 10)
25 (who:htm (:li
f4fe75f @archimag fix examples
authored
26 ((:a :href (restas:genurl 'chapter-?.html :id x))
4b05a86 @archimag update examples
authored
27 (who:fmt "Chapter ~A" x))))))))))
28
f4fe75f @archimag fix examples
authored
29 (restas:define-route chapter-?.html ("chapter-:(id).html")
4b05a86 @archimag update examples
authored
30 (who:with-html-output-to-string (out)
31 (:html
32 (:head
33 (:title (who:fmt "Example 2. Chapter ~A" id)))
34 (:body
35 (:h1 (who:fmt "Chapter ~A" id))
36 (:ul
37 (iter (for x from 1 to 10)
38 (who:htm (:li
f4fe75f @archimag fix examples
authored
39 ((:a :href (restas:genurl 'chapter-?-?.html :id1 id :id2 x))
4b05a86 @archimag update examples
authored
40 (who:fmt "Chapter ~A-~A" id x))))))
f4fe75f @archimag fix examples
authored
41 ((:a :href (restas:genurl 'root))
4b05a86 @archimag update examples
authored
42 "Back to Index")))))
43
f4fe75f @archimag fix examples
authored
44 (restas:define-route chapter-?-?.html ("chapter-:(id1)-:(id2).html")
4b05a86 @archimag update examples
authored
45 (who:with-html-output-to-string (out)
46 (:html
47 (:head
48 (:title (who:fmt "Example 2. Chapter ~A-~A" id1 id2)))
49 (:body
50 (:h1 (who:fmt "Chapter ~A-~A" id1 id2))
51 (:p (who:fmt "This is a chapter ~A-~A" id1 id2))
f4fe75f @archimag fix examples
authored
52 ((:a :href (restas:genurl 'chapter-?.html :id id1))
4b05a86 @archimag update examples
authored
53 (who:fmt "Back to Chapter ~A" id1))))))
81da31b @archimag update examples
authored
54
f4fe75f @archimag fix examples
authored
55 (restas:start '#:restas.example-2 :port 8080)
Something went wrong with that request. Please try again.