Skip to content

Commit f08af0e

Browse files
committed
structure++
1 parent 1db947c commit f08af0e

File tree

9 files changed

+37
-163
lines changed

9 files changed

+37
-163
lines changed

content/building-blocks/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ title = "Building blocks"
44
weight = 1
55
+++
66

7-
In this chapter we'll start by creating our first route, we'll serve
7+
In this chapter we'll create routes, we'll serve
88
local files and we'll run more than one web app in the same running
99
image.
1010

11-
Let's install the libraries we'll use:
11+
We'll use those libraries:
1212

1313
~~~lisp
1414
(ql:quickload '("hunchentoot" "easy-routes" "djula" "spinneret"))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
title = "Building a binary"
3+
weight = 150
4+
+++
5+

content/building-blocks/database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
+++
33
title = "Connecting to a database"
4-
weight = 170
4+
weight = 120
55
+++
66

77
Please see the [databases section](databases.html). The Mito ORM

content/building-blocks/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
+++
22
title = "Error handling"
3-
weight = 150
3+
weight = 100
44
+++
55

66
In all frameworks, we can choose the level of interactivity. The web

content/building-blocks/headers.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
+++
3+
title = "Headers"
4+
weight = 40
5+
+++
6+
7+
~~~lisp
8+
(setf (hunchentoot:header-out "HX-Trigger") "myEvent")
9+
~~~

content/building-blocks/routing.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ title = "Routing"
33
weight = 15
44
+++
55

6+
I prefer the easy-routes library than pure Hunchentoot to define
7+
routes, as we did in the tutorial, so skip to its section below if you
8+
want. However, it can only be benificial to know the built-in
9+
Hunchentoot ways.
610

7-
{{% notice info %}}
8-
9-
I prefer the easy-routes library than pure Hunchentoot to define routes, skip to its section if you want.
10-
11-
{{% /notice %}}
1211

1312
## Hunchentoot
1413

@@ -171,7 +170,7 @@ You probably have nothing to do to get the value of those parameters: if you def
171170

172171
However, here's how to interact more with URL parameters. In particular, we can define the default type of a parameter: they are strings by default, but we can ask to receive an integer.
173172

174-
### Hunchentoot
173+
### Hunchentoot URL parameters
175174

176175
First of all, note that we can access query parameters anytime with
177176

@@ -192,15 +191,15 @@ We defined the following handler:
192191
~~~lisp
193192
(hunchentoot:define-easy-handler (say-yo :uri "/yo") (name)
194193
(setf (hunchentoot:content-type*) "text/plain")
195-
(format nil "Hey~@[ ~A~]!" name))
194+
(format nil "Hey ~a!" name))
196195
~~~
197196

198197
The variable `name` is a string by default. Let's check it out:
199198

200199
~~~lisp
201200
(hunchentoot:define-easy-handler (say-yo :uri "/yo") (name)
202201
(setf (hunchentoot:content-type*) "text/plain")
203-
(format nil "Hey~@[ ~A~] you are of type ~a" name (type-of name)))
202+
(format nil "Hey ~a you are of type ~a" name (type-of name)))
204203
~~~
205204

206205
Going to [http://localhost:4242/yo?name=Alice](http://localhost:4242/yo?name=Alice) returns

content/building-blocks/simple-web-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Before dwelving into web development, we might want to do something simple: serv
88

99
### Serve local files
1010

11-
Create and start a webserver like this:
11+
If you followed the tutorial you know that we can create and start a webserver like this:
1212

1313
~~~lisp
1414
(defvar *acceptor* (make-instance 'hunchentoot:easy-acceptor :port 4242))

content/building-blocks/templates.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ weight = 30
77
### Djula - HTML markup
88

99
[Djula](https://github.com/mmontone/djula) is a port of Python's
10-
Django template engine to Common Lisp. It has [excellent documentation](https://mmontone.github.io/djula/doc/build/html/index.html).
10+
Django template engine to Common Lisp. It has [excellent documentation](https://mmontone.github.io/djula/djula/).
1111

1212
Install it if you didn't already do it:
1313

@@ -61,13 +61,13 @@ the most downloaded libraries of Quicklisp.
6161
#### Djula filters
6262

6363
Filters allow to modify how a variable is displayed. Djula comes with
64-
a good set of built-in filters and they are [well documented](https://mmontone.github.io/djula/doc/build/html/filters.html). They are not to be confused with [tags](https://mmontone.github.io/djula/doc/build/html/tags.html).
64+
a good set of built-in filters and they are [well documented](https://mmontone.github.io/djula/djula/Filters.html#Filters). They are not to be confused with [tags](https://mmontone.github.io/djula/djula/Tags.html#Tags).
6565

66-
They look like this: `{{ name | lower }}`, where `lower` is an
66+
They look like this: `{{ var | lower }}`, where `lower` is an
6767
existing filter, which renders the text into lowercase.
6868

69-
Filters sometimes take arguments. For example: `{{ value | add:2 }}` calls
70-
the `add` filter with arguments `value` and 2.
69+
Filters sometimes take arguments. For example: `{{ var | add:2 }}` calls
70+
the `add` filter with arguments `var` and 2.
7171

7272
Moreover, it is very easy to define custom filters. All we have to do
7373
is to use the `def-filter` macro, which takes the variable as first
@@ -76,11 +76,11 @@ argument, and which can take more optional arguments.
7676
Its general form is:
7777

7878
~~~lisp
79-
(def-filter :myfilter-name (value arg) ;; arg is optional
79+
(def-filter :myfilter-name (var arg) ;; arg is optional
8080
(body))
8181
~~~
8282

83-
and it is used like this: `{{ value | myfilter-name }}`.
83+
and it is used like this: `{{ var | myfilter-name }}`.
8484

8585
Here's how the `add` filter is defined:
8686

@@ -112,9 +112,10 @@ HTML5 generator. It looks like this:
112112
(:footer ("Last login: ~A" *last-login*)))
113113
~~~
114114

115-
The author finds it is easier to compose the HTML in separate
116-
functions and macros than with the more famous cl-who. But it
117-
has more features under it sleeves:
115+
I find it is easier to compose the HTML than with the more famous
116+
cl-who, but I personnally prefer to use HTML templates.
117+
118+
Spinneret has nice features under it sleeves:
118119

119120
- it warns on invalid tags and attributes
120121
- it can automatically number headers, given their depth

content/database.md

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)