Permalink
Commits on Mar 19, 2012
  1. In progress.

    committed Mar 19, 2012
  2. The backend chat setup is actually super-easy. We have a basic

    ChatActor, modeled mostly after Simply Lift's ChatServer. Paired to it
    is a per-client ChatComet, which takes care of posting and receiving
    messages and handling changes in usernames. Each user gets a default
    username using Lift's built-in randon number generator function,
    nextNum, which we expose by importing net.liftweb.util.Helpers._ .
    
    Last but not least, every new client gets the last message that was sent
    (rather than all messages ever, for our purposes we stick to the last
    one). We leave stubs for now for how we will call down into the client;
    we'll be filling those in after we implement the JavaScript side of
    the interactions, so that we know what we want to call into from the
    server.
    committed Mar 19, 2012
  3. First off, we're going to set up a quick skeleton of what we're going to

    be looking at. We're not super worried about seeing online users at the
    moment; all we want to implement is basic chat. So our template contains
    just enough to display chat and give us a field to type our chat
    into. We use a bit of bootstrap magic and some simple styles of our own
    to fix the message and post buttons to the bottom of the screen. We also
    style the ordered list tag that we'll be using to display chats so that
    it has the traditional chat content layout.
    
    Now we have our base view to work with; our next step is the backend
    logic. Note that we won't be hooking anything up with the client side
    yet; we're just going to set up the comet interactions that will post
    and receive messages. We'll do the actual form interactions and knockout
    bindings after all the infrastructure is set up on both ends.
    committed Mar 18, 2012
Commits on Mar 18, 2012
  1. One thing worth mentioning in passing is that we're going to be using

    Lift's XML input, but its HTML5 output. We do care about valid output,
    but we gain a bit of flexibility from allowing the main Lift templates
    from being XML. Sometimes we don't want a wrapping HTML container just
    so we can invoke a Lift snippet or what have you.
    committed Mar 18, 2012
  2. Lift Push Knock Out is a project to show how to use Lift with knockou…

    …t.js
    
    For simplicity's sake, we'll be using Twitter's bootstrap in conjunction
    with jQuery and knockout.js. All we want to do is build a nice, simple
    chat client. We're not going to be complicating it with too many
    features; initially, all we'll be looking at is a simple chat
    interaction, but mediated entirely through a Lift comet.
    
    I'll elaborate a little bit on that last part. Typically, Lift
    interactions are defined in a snippet somewhere in the snippet package,
    bound on the client by a CSS transform, and interactions with it happen
    within the snippet package. Occasionally, the only thing the snippet
    does is send a message to an intermediary actor, which then talks to the
    comet.
    
    At OpenStudy, we use a slightly different interaction model, and this
    project will be demonstrating that model. The key difference is that we
    bind the vast majority of our UI via knockout, so all form handling
    functions and field names are also sent down via comet and bound via
    knockout. This introduces a couple of small thorns that we need to deal
    with in terms of bringing our handling in life with some of Lift's
    assumptions, but they're fairly trivial. We'll look at them in a bit.
    
    Starting Point
    --------------
    
    The project starts off from the basis of the lift_blank template in the
    main Lift 2.4 download at http://liftweb.net/download . We strip out
    some extraneous files, add Twitter bootstrap, the latest jQuery, and
    knockout.js, and make the main package com.withoutincident instead of
    the default code that is used in the Lift template. Then, we're ready to
    start!
    committed Mar 18, 2012