Skip to content

Commit 8e64b9b

Browse files
committed
anchor and figures in chapter 01 and 02
1 parent 6d74818 commit 8e64b9b

File tree

2 files changed

+635
-47
lines changed

2 files changed

+635
-47
lines changed

Chapters/01-Pharo/Pharo.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ In this book, we use Seaside 3.0.4, included in the _One Click Image_ which
1616
you can find on the Seaside website at [http://www.seaside.st/download](http://www.seaside.st/download). The
1717
_One Click Image_ is a bundle of everything you need to run Seaside.
1818

19-
![The Seaside development environment.%width=100&label=fig:seasideDesk](figures/seasideApplicationDesk.png)
19+
![The Seaside development environment.%width=100&anchor=fig:seasideDesk](figures/seasideApplicationDesk.png)
2020

2121
You should see the Seaside development environment open in
2222
a single window on your desktop similar to the one presented in Figure *@fig:seasileDesk@*.
@@ -36,15 +36,15 @@ pointing your web browser to [http://localhost:8080/](http://localhost:8080/). Y
3636
like Figure *@fig:seasideServer@*. If you don’t see this page, it is possible
3737
that port 8080 is already in use by another application on your computer.
3838

39-
![The Seaside server running.% width=100&label=fig:seasideServer](figures/seasideServer.png)
39+
![The Seaside server running.% width=100&anchor=fig:seasideServer](figures/seasideServer.png)
4040

4141
**Changing the Seaside port number.**
4242
If you did not see Figure *@fig:seasideServer@*, you will need to try modifying
4343
the workspace to restart the Comanche web server on a different port number
4444
\(like 8081\). The script *@scr:startServer@* asks the server to stop serving and start
4545
serving on port 8081.
4646

47-
```language=smalltalk&label=scr:startServer&caption=Stop the server and start a new one.
47+
```language=smalltalk&anchor=scr:startServer&caption=Stop the server and start a new one.
4848
WAKom stop.
4949
WAKom startOn: 8081.
5050
```
@@ -89,7 +89,7 @@ _component_ refers to any class which inherits from the class `WAComponent`
8989
To start creating your class, click on the `WebCounter` package you just
9090
created. The "class creation template" will appear in the source pane of the browser. Edit this template so that it looks as in the script *@scr:pharoClassTemplate@*
9191

92-
```language=smalltalk&caption=Pharo class template for the `Web Counter`&label=scr:pharoClassTemplate
92+
```language=smalltalk&caption=Pharo class template for the `Web Counter`&anchor=scr:pharoClassTemplate
9393
WAComponent << #WebCounter
9494
slots: { #count };
9595
package: 'WebCounter'
@@ -109,14 +109,14 @@ pane to bring up the context menu, and select the menu item _Accept \(s\)_ as
109109
shown in Figure *@fig:createdClass@*. Accept in Pharo jargon means
110110
compile.
111111
112-
![Creating the class `WebCounter`. % width=100&label=fig:createClass](figures/createClass.png)
112+
![Creating the class `WebCounter`. % width=100&anchor=fig:createClass](figures/createClass.png)
113113
114114
Once you have accepted, your browser should look similar to the one shown in
115115
Figure *@fig:createdClass@*. The browser now shows the class that you have
116116
created in the class pane. Now we are ready to define some behaviour for our
117117
component.
118118
119-
![The class has been created.% width=100&label=createdClass](figures/createdClass.png)
119+
![The class has been created.% width=100&anchor=createdClass](figures/createdClass.png)
120120
121121
### Defining Basic Methods
122122
@@ -134,7 +134,7 @@ by using the message `new`, which will create the new instance and then send
134134
the message `initialize` to this new instance.
135135
136136
137-
```language=smalltalk&label=scr:WebCounterInitialize&caption=WebCounter initialize method.
137+
```language=smalltalk&anchor=scr:WebCounterInitialize&caption=WebCounter initialize method.
138138
WebCounter >> initialize
139139
super initialize.
140140
count := 0
@@ -153,11 +153,11 @@ At this point Pharo might ask you to enter your full name. This is for the
153153
source code version control system to keep track of the author that wrote this
154154
code.
155155

156-
![Compiling a method. % width=100&label=fig:compilingMethod](figures/compilingMethod.png)
156+
![Compiling a method. % width=100&anchor=fig:compilingMethod](figures/compilingMethod.png)
157157

158158
The method signature will also appear in the method pane as shown in Figure *@fig:compiledMethod@*.
159159

160-
![The method has been compiled.%width=100&label=fig:compiledMethod](figures/compiledMethod.png )
160+
![The method has been compiled.%width=100&anchor=fig:compiledMethod](figures/compiledMethod.png )
161161

162162
Now let’s review what this means. To create a method, we need to define two
163163
things, the name of the method and the code to be executed. The first line gives
@@ -168,13 +168,13 @@ variable to 0.
168168
To be ready to define Seaside-specific behaviour, define two more instance methods to change the counter state as in
169169
scripts *@scr:increaseMethod@* and *@scr:decreaseMethod@*. You can group them in a protocol 'action'.
170170

171-
```language=smalltalk&caption=Increase method.&label=scr:increaseMethod
171+
```language=smalltalk&caption=Increase method.&anchor=scr:increaseMethod
172172
WebCounter >> increase
173173
count := count + 1
174174
```
175175

176176

177-
```language=smalltalk&caption=Decrease method.&label=scr:decreaseMethod
177+
```language=smalltalk&caption=Decrease method.&anchor=scr:decreaseMethod
178178
WebCounter >> decrease
179179
count := count - 1
180180
```
@@ -194,7 +194,7 @@ rendered.
194194
Add a new method category called rendering, and add the method definition in
195195
script *@scr:pharoRenderContentOn@*
196196

197-
```language=smalltalk&caption=Example of `renderContentOn:` method&label=scr:pharoRenderContentOn
197+
```language=smalltalk&caption=Example of `renderContentOn:` method&anchor=scr:pharoRenderContentOn
198198
WebCounter>>renderContentOn: html
199199
html heading: count
200200
```
@@ -207,7 +207,7 @@ message `heading:` to the html object that we were given as an argument.
207207
As we will see later, when we have completed our application, this method will
208208
give us output as shown in Figure *@fig:simpleCounter@*.
209209
210-
![A simple counter. % width=100&label=simpleCounter](figures/simpleCounter.png)
210+
![A simple counter. % width=100&anchor=simpleCounter](figures/simpleCounter.png)
211211
212212
#### Registering as a Seaside Application
213213
@@ -226,7 +226,7 @@ we add to the `register:asApplicationAt:` message specifies the root component
226226
and the path that will be used to access the component from the web browser. You
227227
can reach the application under the URL [http://localhost:8080/webcounter](http://localhost:8080/webcounter).
228228
229-
![Register a component as an application from a workspace.](figures/registerComponent.png width=100&label=fig:registerComponent)
229+
![Register a component as an application from a workspace.](figures/registerComponent.png width=100&anchor=fig:registerComponent)
230230
231231
Now you can launch the application in your web browser by going to
232232
[http://localhost:8080/webcounter/](http://localhost:8080/webcounter/) and you will see your first Seaside
@@ -249,7 +249,7 @@ A _class_ `initialize` method is automatically invoked when the class is
249249
loaded from a file. The script *@scr:classInitialize@* the `initialize` class
250250
method definition.
251251
252-
```language=smalltalk&caption=Automitically register your application with an initialize method.&label=scr:classInitialize
252+
```language=smalltalk&caption=Automitically register your application with an initialize method.&anchor=scr:classInitialize
253253
WebCounter class >> initialize
254254
WAAdmin register: self asApplicationAt: 'webcounter'
255255
```
@@ -278,7 +278,7 @@ often use: it adds the expression to be executed as comment in the method. This
278278
way you just have to put your cursor after the first double quote, click once to
279279
select the expression and execute it using the _Do it \(d\)_ menu item or shortcut.
280280

281-
![Adding the executable comment.% width=100&label=fig:executableComment](figures/executableComment.png)
281+
![Adding the executable comment.% width=100&anchor=fig:executableComment](figures/executableComment.png)
282282

283283
#### Adding Behavior
284284

@@ -290,12 +290,12 @@ callbacks attached to links (also known as anchors) displayed when the component
290290
is rendered in a web browser, as shown in Figure *@fig:addLink@*. Using callbacks
291291
allows us to define some code that will be executed when a link is clicked.
292292

293-
![A simple counter with actions. % width=100&label=fig:addLink](figures/addLink.png)
293+
![A simple counter with actions. % width=100&anchor=fig:addLink](figures/addLink.png)
294294

295295
We modify the method `WAComponent>>renderContentOn:` as in script
296296
*@scr:addCallback@*.
297297

298-
```language=smalltalk&caption=Add anchors and callbacks to your counter&label=scr:addCallback
298+
```language=smalltalk&caption=Add anchors and callbacks to your counter&anchor=scr:addCallback
299299
WebCounter >> renderContentOn: html
300300
html heading: count.
301301
html anchor
@@ -319,7 +319,7 @@ the user clicks on the anchor.
319319
Click on the links to see that the counter get increased or decreased as shown
320320
in Figure *@fig:callbackResult@*.
321321

322-
![A simple counter with a different value.% width=100&label=fig:callbackResult](figures/callbackResult.png)
322+
![A simple counter with a different value.% width=100&anchor=fig:callbackResult](figures/callbackResult.png)
323323

324324
#### Adding a Class Comment
325325
@pharoClassComment
@@ -333,7 +333,7 @@ place to start reading. Classes that don’t have them require a lot more
333333
developer effort to figure out so get in the habit of adding these comments to
334334
all of your classes.
335335

336-
![A class comment.% width=100&label=fig:classComment](figures/classComment.png)
336+
![A class comment.% width=100&anchor=fig:classComment](figures/classComment.png)
337337

338338
Now you are set to code in Seaside.
339339

0 commit comments

Comments
 (0)