Skip to content

Commit

Permalink
Fill in code block filenames where relevant
Browse files Browse the repository at this point in the history
This sets us up for some nice preprocessing later to fill in context around our
example blocks.
  • Loading branch information
Shadowfiend committed Mar 3, 2018
1 parent c4160a7 commit 46606aa
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started-tutorial/2-the-lift-menu-system.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ more complicated. All you have to do for the chat page is add a line to your
`SiteMap.scala` that names the page and points to the file in the `webapp`
directory:

```
```src/scala/bootstrap/liftweb/Boot.scala
...
Menu.i("Chat") / "chat"
...
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started-tutorial/3-adding-snippet-bindings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ Let's look at our chat app specifically. We're going to bind two things: the
list of chat messages, and the text input that lets us actually chat. To the
`ol` that contains the chat messages, we add:

```
```html:src/main/webapp/index.html
<ol class="messages" data-lift="Chat.messages">
```

And to the input form:

```
```html:src/main/webapp/index.html
<form class="send-message" data-lift="Chat.sendMessage">
```

Expand All @@ -46,7 +46,7 @@ We'll write a very basic version that just passes through the contents of the
list and form unchanged, and then in the next section we'll start adding some
behavior. In `src/main/scala/code/snippet/Chat.scala`, add:

```
```scala:src/main/scala/code/snippet/Chat.scala
package code
package snippet

Expand Down
10 changes: 5 additions & 5 deletions docs/getting-started-tutorial/4-css-selector-transforms.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the list changing.

First, we'll define a variable to hold the messages:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
object Chat {
var messageEntries = List[String]()
Expand All @@ -31,7 +31,7 @@ object Chat {
Then, we can change the definition of the `messages` method to bind the
contents of the message list:

```
```scala:src/main/scala/code/snippet/Chat.scala
...

import net.liftweb.util.Helpers._
Expand Down Expand Up @@ -76,7 +76,7 @@ Once you see the success message, point your browser to
there are no message entries. To fix this, we're going to add a chat message
every time we render the message list:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
def messages = {
messageEntries :+= "It is now " + formattedTimeNow
Expand Down Expand Up @@ -133,7 +133,7 @@ without getting nasty in our HTML?

Lift lets us tag the extra elements with a class `clearable`:

```
```html:src/main/webapp/index.html
...
<li>Hi!</li>
<li class="clearable">Oh, hey there.</li>
Expand All @@ -146,7 +146,7 @@ Then, in our snippet, we can use a special transform called `ClearClearable`,
which will remove all of the tagged elements before we start transforming the
template:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
def messages = {
messageEntries :+= "It is now " + formattedTimeNow
Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started-tutorial/5-basic-forms.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ connection.
Let's look at a simple example with our chat application. Currently our form
looks like this:

```
```html
<form class="send-message" data-lift="Chat.sendMessage">
<label for="new-message">Post message</label>
<input id="new-message" type="text">
Expand All @@ -35,7 +35,7 @@ looks like this:

Our `sendMessage` snippet looks like this:

```
```scala
...
def sendMessage(contents: NodeSeq) = contents
...
Expand All @@ -45,7 +45,7 @@ We want to bind two things above. The first is the text field, which we want to
bind so that we can get a message from the user, and the second is the submit
button, so that we can process the new message. Here's how we can do that:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
import net.liftweb.http.SHtml

Expand Down Expand Up @@ -78,7 +78,7 @@ value of `message` to the existing message entries list.
Before continuing, let's change the `messages` snippet so it doesn't keep
adding a new message on each page load:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
def messages = {
ClearClearable &
Expand Down
10 changes: 5 additions & 5 deletions docs/getting-started-tutorial/6-adding-usernames.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We're about to add another use case to our chat system:
The first thing we'll do is change the HTML to look like we want it to. Let's
add the username:

```
```html:src/main/webapp/index.html
...
<li>
<span class="poster">Antonio</span> <span class="body">Hi!</span>
Expand All @@ -40,7 +40,7 @@ thrown away, as will the associated `SessionVar` values and related data.

For now, let's look at adding the `SessionVar` to the `Chat` snippet:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
object username extends SessionVar[String]("username")

Expand All @@ -51,7 +51,7 @@ object Chat {
Here, we create a new `SessionVar`, whose default value will be “username” if it
is accessed without having been set. We can change that to be random:

```
```scala:src/main/scala/code/snippet/Chat.scala
object username extends SessionVar[String]("User " + randomString(5))
```

Expand All @@ -62,7 +62,7 @@ user session has a (reasonably) unique username.
Now, we need to store usernames alongside messages. Let's do that by making the
messageEntries list contain a case class instance instead of a simple `String`:

```scala
```scala:src/main/scala/code/snippet/Chat.scala
...
case class ChatMessage(poster: String, body: String) // <1>
class Chat {
Expand Down Expand Up @@ -94,7 +94,7 @@ class Chat {
Now let's update the binding of the `sendMessage` form to deal with the new
`ChatMessage` class:

```scala
```scala:src/main/scala/code/snippet/Chat.scala
def sendMessage = {
var message = ChatMessage("", "") // <1>

Expand Down
10 changes: 5 additions & 5 deletions docs/getting-started-tutorial/7-using-actors-for-chat.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ http://aka.io[Akka], but they're only necessary in cases where you need more
flexibility or fault tolerance. We'll stick to the easy stuff, starting with a
new file at `src/main/scala/code/actor/ChatActor.scala`:

```
```scala:src/main/scala/code/actor/ChatActor.scala
package code
package actor

Expand Down Expand Up @@ -55,7 +55,7 @@ To ask the actor to add a message, we'll send it the `MessagePosted` message
using the `!` operator. Here's how we can update our code in the `Chat`
snippet:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
import actor._
...
Expand All @@ -80,7 +80,7 @@ isn't useful if we can't get them back out!

To retrieve messages, we can add a new message for the `ChatActor`:

```
```scala:src/main/scala/code/actor/ChatActor.scala
...
case class MessagePosted(message: ChatMessage)
case object GetMessages
Expand All @@ -89,7 +89,7 @@ case object GetMessages

And a handler for it:

```
```scala:src/main/scala/code/actor/ChatActor.scala
...
def messageHandler = {
...
Expand All @@ -109,7 +109,7 @@ with it.
To wait for a reply, we have to use the `!?` operator instead. We do this when
listing messages by updating the `Chat` snippet:

```
```scala:src/main/scala/code/snippet/Chat.scala
...
def messages = {
val messageEntries = Box.asA[List[ChatMessage]](ChatActor !? GetMessages) openOr List()
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started-tutorial/8-customizable-usernames.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Let's deal with the next use case:
What we really want is a text box on the client that will let us edit the name.
We'll add it to the top of our chat area in `chat.html`:

```html
```html:src/main/webapp/index.html
...
<section id="chat">
<header>
Expand All @@ -27,7 +27,7 @@ The ideal way for this to work would be for you to be able to change the value
of the field and have it save once the cursor leaves the field (i.e., on blur).
We can do exactly that using Lift's `ajaxText` helper in `Chat.scala`:

```scala
```scala:src/main/scala/code/snippet/Chat.scala
...
def nameField = {
"input" #> SHtml.ajaxText(username.is, username.set _)
Expand All @@ -45,7 +45,7 @@ a change occurs on the client, and we hook it up directly to the ``SessionVar``'
However, maybe we want to provide some feedback to the user to let them know
the name has been updated. We can get a little more detailed:

```scala
```scala:src/main/scala/code/snippet/Chat.scala
...
def nameField = {
"input" #> SHtml.ajaxText(username.is, { updatedUsername: String =>
Expand Down

0 comments on commit 46606aa

Please sign in to comment.