A new Lift Chat App screencast

138 views
Skip to first unread message

David Pollak

unread,
Nov 12, 2010, 3:08:14 PM11/12/10
to liftweb
Enjoy: http://liftweb.blip.tv/file/4374370/

The HTML Template:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
    <title>Home</title>
    
  </head><body class="lift:content_id=main">
    <div id="main" class="lift:surround?with=default;at=content">
      <h2>Welcome to your project!</h2>
      This is my chat app, baby<br />
      <ul class="lift:comet?type=Chat">
<li>Chat Line 1</li>
<li class="clearable">Chat Line 2</li>
<li class="clearable">Chat line 3<br />
</li>
      </ul>
      <form action="/" class="lift:form.ajax"><input id="chat_in" class="lift:ChatIn" name="foo" /><br />
<input value="say something" type="submit" /></form>
      <br />
      <p> <span class="lift:helloWorld.howdy"> Welcome to your Lift app at <span id="time">Time goes here</span> </span> </p>
    </div>

</body></html>



The Chat.scala file:

package code
package comet

import net.liftweb._
import http._
import actor._
import util._
import Helpers._

object ChatServer extends LiftActor with ListenerManager {
  private var msgs = Vector("Welcome")

  def createUpdate = msgs

  override def lowPriority = {
    case s: String => msgs :+= s; updateListeners()
  }
}

class Chat extends CometActor with CometListener {
  private var msgs: Vector[String] = Vector()

  def registerWith = ChatServer

  override def lowPriority = {
    case v: Vector[String] => msgs = v; reRender()
  }

  def render = "li *" #> msgs & ClearClearable
}

And the ChatIn.scala snippet:

package code
package snippet

import net.liftweb._
import http._
import js._
import JsCmds._
import JE._

import comet.ChatServer

object ChatIn {
  def render = SHtml.onSubmit(s => {
    ChatServer ! s
    SetValById("chat_in", "")
  })
}


TylerWeir

unread,
Nov 12, 2010, 3:54:55 PM11/12/10
to Lift
Nice, downloaded.

On Nov 12, 3:08 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:

David Pollak

unread,
Nov 12, 2010, 3:59:35 PM11/12/10
to lif...@googlegroups.com


On Fri, Nov 12, 2010 at 12:54 PM, TylerWeir <tyler...@gmail.com> wrote:
Nice, downloaded.

For a higher resolution, Ogg encoded version: http://tunaforcats.com/chat_screencast.ogg
 
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Heiko Seeberger

unread,
Nov 13, 2010, 4:09:38 AM11/13/10
to lif...@googlegroups.com
Amazing! Much "better" than "before". I like the designer-friendly templates and the onSubmit thing a lot.

Heiko

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.



--
Heiko Seeberger

Company: weiglewilczek.com
Blog: heikoseeberger.name
Follow me: twitter.com/hseeberger
OSGi on Scala: scalamodules.org
Lift, the simply functional web framework: liftweb.net
Akka - Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Actors: akkasource.org

Naftoli Gugenheim

unread,
Nov 13, 2010, 9:42:37 PM11/13/10
to liftweb
Now what's the line count comparison to what language was it that someone once posted about that makes comet very concise? ;)

sorenbs

unread,
Nov 14, 2010, 10:55:12 AM11/14/10
to Lift
So this is Lifts counterpart to the rails "build a blog app in 15
minutes."

Pretty cool


On Nov 12, 9:08 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages