> cabal update
@@ -75,14 +85,13 @@ package and then compile them.
## Initialization
-Open a terminal and:
+Open a terminal and type:
> yesod init
-I entered my name, the name of the project was `yosog` and the name of the Foundation was `Yosog`, then I chosen `sqlite`.
-
+Enter your name, name the project `yosog` and the name of the Foundation as `Yosog`, then choose `sqlite`.
Perfect. Now you can start the development cycle:
@@ -90,19 +99,20 @@ Perfect. Now you can start the development cycle:
> cabal-dev install && yesod --dev devel
-This will compile the entire project.
-In the end you should now be able to see your local website by clicking this link:
+This will compile the entire project. Be patient it could take some time.
+Once finished a server is launched and you could visit it by clicking this link:
[`http://localhost:3000`](http://localhost:3000)
-Congratulation! You were able to see your yesod powered website.
-For the rest of the tutorial, use another terminal and let this one open in a corner to see what occurs.
+Congratulation! Yesod works.
+
+Until the end of the tutorial, use another terminal and let this one open in a corner to see what occurs.
## Configure git
-It is not mandatory for a tutorial, but it is a good practice to have a CVS.
+This step is not mandatory for a tutorial, but I wanted to jump directly in good practice. There are many different choice of CVS, but for this tutorial I'll use `git`.
-To use `git` copy this `.gitignore` file into the `yosog` folder.
+Copy this `.gitignore` file into the `yosog` folder.
cabal-dev
@@ -120,18 +130,18 @@ Then initialize your git repository:
> git commit -a -m "Initial yesod commit"
-Now we are ready to modify our web application.
+Now we are almost ready to start.
## A last point
-What did we done:
+Until here it was just an installation, an initialization and a configuration.
-1. We have a directory containing a bunch of files
-2. We have a local web server on port 3000
+We have a directory containing a bunch of files and
+we have a local web server that listen the port 3000.
If we modify a file inside this directory, yesod should try
-to recompile as fast as possible the site. This way, you should
-see the modification you done.
+to recompile as fast as possible the site.
+This way, you should see the modification you do.
Instead of explaining the role of every file,
let's get straight to the point.
@@ -141,27 +151,29 @@ Inside the `yosog` the important files/directories for this tutorial are:
1. `config/routes`
2. `Handler/`
3. `templates/`
-4. `static/`
-5. `config/models`
+4. `config/models`
Obviously:
- `config/routes` is where you'll configure the map URL → Code.
- `Handler/` contains the files that will contain the code called when a URL is accessed.
- `templates/` contains HTML, JS and CSS templates.
-- `static/` contains static files.
- `config/models` is where you'll configure the persistent objects (database tables).
-With these informations we should be able to do a lot.
Also note until here we don't even typed any line of Haskell.
+It is now time to start the interesting stuff.
## Protected echo
-To verify the quality of the security of the yesod framework, let's look at a minimal echo application.
+To verify the quality of the security of the yesod framework, let's make a minimal echo application.
Our goal:
-Accessing [`http://localhost:3000/echo/some%20text`](http://localhost:3000/echo/some%20text), should display "some text" in an %html web page.
+Make a server that when accessed `/echo/`_[some text]_ should return a web page containing "some text" inside an `h1` bloc.
+
+For example, accessing [`http://localhost:3000/echo/some%20text`](http://localhost:3000/echo/some%20text), should display "some text" in an %html web page.
+
+First, we must declare URL of the form /echo/... are meaningful.
Let's take a look at the file `config/routes`:
@@ -184,10 +196,9 @@ We add the following:
This line contains three elements: the url pattern, a handler name, an HTTP method.
I am not particularly fan of the big R in the end of handler names.
-But this is the standard convention, then I use it.
+But this is the standard convention, then let's use it.
-If you save `config/routes`, you should see your terminal in which you launched `yesod devel` do things.
-And certainly break in error.
+If you save `config/routes`, you should see your terminal in which you launched `yesod devel` activate and certainly displaying an error message.
Application.hs:31:1: Not in scope: `getEchoR'
@@ -203,18 +214,29 @@ getEchoR theText = do
[whamlet|#{theText}|]
+Don't worry if you find all of this a bit cryptic.
+This is normal when learning a new framework.
+In short it just declare a function named getEchoR with one argument (`theText`) of type String.
+When this function is called, it return a "Handler RepHtml" whatever it is.
+But mainly this will encapsulate our expected result inside an HTML text.
+
After saving the file, you should see yesod recompile the application.
When the compilation is finished you'll see the message: `Starting devel application`.
-You can now visit: [`http://localhost:3000/echo/Yesod%20rocks!`](http://localhost:3000/echo/Yesod%20rocks!)
+
+Now you can visit: [`http://localhost:3000/echo/Yesod%20rocks!`](http://localhost:3000/echo/Yesod%20rocks!)
TADA! It works.
-Now, let's try to attack our website by entering name with special characters:
+### Secure?
+
+Let's try to attack our website by entering a text with special characters:
[`http://localhost:3000/echo/