diff --git a/docs/getting-started-tutorial/2-the-lift-menu-system.adoc b/docs/getting-started-tutorial/2-the-lift-menu-system.adoc index dc28ac1559..373db1f283 100644 --- a/docs/getting-started-tutorial/2-the-lift-menu-system.adoc +++ b/docs/getting-started-tutorial/2-the-lift-menu-system.adoc @@ -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" ... diff --git a/docs/getting-started-tutorial/3-adding-snippet-bindings.adoc b/docs/getting-started-tutorial/3-adding-snippet-bindings.adoc index 7dc67ac51f..00334f75c9 100644 --- a/docs/getting-started-tutorial/3-adding-snippet-bindings.adoc +++ b/docs/getting-started-tutorial/3-adding-snippet-bindings.adoc @@ -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
    ``` And to the input form: -``` +```html:src/main/webapp/index.html
    ``` @@ -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 diff --git a/docs/getting-started-tutorial/4-css-selector-transforms.adoc b/docs/getting-started-tutorial/4-css-selector-transforms.adoc index f7bd576e55..2d7b7ee4bb 100644 --- a/docs/getting-started-tutorial/4-css-selector-transforms.adoc +++ b/docs/getting-started-tutorial/4-css-selector-transforms.adoc @@ -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]() @@ -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._ @@ -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 @@ -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 ...
  1. Hi!
  2. Oh, hey there.
  3. @@ -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 diff --git a/docs/getting-started-tutorial/5-basic-forms.adoc b/docs/getting-started-tutorial/5-basic-forms.adoc index a2b10c8304..0cb9dcaaed 100644 --- a/docs/getting-started-tutorial/5-basic-forms.adoc +++ b/docs/getting-started-tutorial/5-basic-forms.adoc @@ -25,7 +25,7 @@ connection. Let's look at a simple example with our chat application. Currently our form looks like this: -``` +```html @@ -35,7 +35,7 @@ looks like this: Our `sendMessage` snippet looks like this: -``` +```scala ... def sendMessage(contents: NodeSeq) = contents ... @@ -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 @@ -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 & diff --git a/docs/getting-started-tutorial/6-adding-usernames.adoc b/docs/getting-started-tutorial/6-adding-usernames.adoc index 9935bd523b..2289cfe850 100644 --- a/docs/getting-started-tutorial/6-adding-usernames.adoc +++ b/docs/getting-started-tutorial/6-adding-usernames.adoc @@ -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 ...
  4. Antonio Hi! @@ -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") @@ -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)) ``` @@ -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 { @@ -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> diff --git a/docs/getting-started-tutorial/7-using-actors-for-chat.adoc b/docs/getting-started-tutorial/7-using-actors-for-chat.adoc index fd4e2f17e8..35d3ef4004 100644 --- a/docs/getting-started-tutorial/7-using-actors-for-chat.adoc +++ b/docs/getting-started-tutorial/7-using-actors-for-chat.adoc @@ -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 @@ -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._ ... @@ -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 @@ -89,7 +89,7 @@ case object GetMessages And a handler for it: -``` +```scala:src/main/scala/code/actor/ChatActor.scala ... def messageHandler = { ... @@ -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() diff --git a/docs/getting-started-tutorial/8-customizable-usernames.adoc b/docs/getting-started-tutorial/8-customizable-usernames.adoc index cbf62441c0..76a2cab454 100644 --- a/docs/getting-started-tutorial/8-customizable-usernames.adoc +++ b/docs/getting-started-tutorial/8-customizable-usernames.adoc @@ -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 ...
    @@ -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 _) @@ -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 =>