Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (60 sloc) 2.137 kb
/*
* Copyright 2007-2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hellolift {
package comet {
import _root_.net.liftweb.http._
import _root_.net.liftweb.common._
import _root_.net.liftweb.util._
import _root_.net.liftweb.sitemap._
import _root_.net.liftweb.sitemap.Loc._
import _root_.scala.xml._
import _root_.com.hellolift.model.Entry
import _root_.com.hellolift.controller.BlogCache
import _root_.com.hellolift.controller.BlogUpdate
import _root_.com.hellolift.controller.AddBlogWatcher
class DynamicBlogView extends CometActor {
override def defaultPrefix = Full("blog")
var blogtitle = ""
var blog : List[Entry] = Nil
var blogid : Long = 0L
def _entryview(e : Entry) : Node = {
<div>
<strong>{e.title}</strong><br />
<span>{e.body}</span>
</div>
}
// render draws the content on the screen.
def render = {
bind("view" -> <span>{blog.flatMap(e => _entryview(e))}</span>)
}
// localSetup is the first thing run, we use it to setup the blogid or
// redirect them to / if no blogid was given.
override def localSetup {
name match {
case Full(t) => this.blogid = Helpers.toLong(t)
}
// Let the BlogCache know that we are watching for updates for this blog.
(BlogCache.cache !? AddBlogWatcher(this, this.blogid)) match {
case BlogUpdate(entries) => this.blog = entries
}
}
// lowPriority will receive messages sent from the BlogCache
override def lowPriority : PartialFunction[Any, Unit] = {
case BlogUpdate(entries : List[Entry]) => this.blog = entries; reRender(false)
}
}
}
}
Jump to Line
Something went wrong with that request. Please try again.