Skip to content

Commit

Permalink
Initial stable at Lift/Cappuccino integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dpp committed Sep 3, 2009
0 parents commit 9db6d7c
Show file tree
Hide file tree
Showing 480 changed files with 124,167 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitignore
@@ -0,0 +1,41 @@
# use glob syntax.
syntax: glob
*.ser
*.class
*~
*.bak
*.off
*.old
.DS_Store

# logs
derby.log

# eclipse conf file
.settings
.classpath
.project
.manager

# building
target
build
null
tmp*
dist
test-output

# other scm
.svn
.CVS
.hg*

# switch to regexp syntax.
# syntax: regexp
# ^\.pc/


# IntelliJ
*.iml
*.ipr
*.iws
163 changes: 163 additions & 0 deletions pom.xml
@@ -0,0 +1,163 @@

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.liftcode</groupId>
<artifactId>frothy</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>frothy</name>
<inceptionYear>2007</inceptionYear>
<properties>
<scala.version>2.7.5</scala.version>
</properties>

<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
<repository>
<id>scala-tools.org.snapshots</id>
<name>Scala-Tools Maven2 Repository for Snapshots</name>
<url>http://scala-tools.org/repo-snapshots</url>
<snapshots/>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-core</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.4.2.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>[6.1.6, 6.1.19)</version>
<scope>test</scope>
</dependency>
<!-- for LiftConsole -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<contextPath>/</contextPath>
<scanIntervalSeconds>5</scanIntervalSeconds>
</configuration>
</plugin>
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<nosuffix>true</nosuffix>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<excludes>
<exclude>org.scala-lang:scala-library</exclude>
</excludes>
<classpathContainers>
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
</classpathContainers>
<projectnatures>
<java.lang.String>ch.epfl.lamp.sdt.core.scalanature</java.lang.String>
<java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>
</projectnatures>
<buildcommands>
<java.lang.String>ch.epfl.lamp.sdt.core.scalabuilder</java.lang.String>
</buildcommands>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
87 changes: 87 additions & 0 deletions src/main/scala/bootstrap/liftweb/Boot.scala
@@ -0,0 +1,87 @@
package bootstrap.liftweb

import _root_.net.liftweb.util._
import _root_.net.liftweb.http._
import _root_.net.liftweb.http.provider._
import _root_.net.liftweb.sitemap._
import _root_.net.liftweb.sitemap.Loc._
import Helpers._
import _root_.net.liftweb.mapper.{DB, ConnectionManager, Schemifier, DefaultConnectionIdentifier, ConnectionIdentifier}
import _root_.java.sql.{Connection, DriverManager}


/**
* A class that's instantiated early and run. It allows the application
* to modify lift's environment
*/
class Boot {
def boot {
// where to search snippet
LiftRules.addToPackages("com.liftcode")

// Build SiteMap
val entries = Menu(Loc("Home", List("index"), "Home")) ::
Menu(Loc("Cappucinno", List("capp"), "Cappucinno")) ::
Nil

LiftRules.setSiteMap(SiteMap(entries:_*))

/*
* Show the spinny image when an Ajax call starts
*/
LiftRules.ajaxStart =
Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)

/*
* Make the spinny image go away when it ends
*/
LiftRules.ajaxEnd =
Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)

LiftRules.early.append(makeUtf8)

LiftRules.useXhtmlMimeType = false

// We serve Cappuccino files with wicked friendly
// mime types
LiftRules.liftRequest.append {
case Req( _, "j", GetRequest) => true
case Req( _, "sj", GetRequest) => true
case Req( _, "plist", GetRequest) => true
}

LiftRules.statelessDispatchTable.prepend {
case r @ Req( _, "j", GetRequest) => ObjJServer.serve(r)
case r @ Req( _, "sj", GetRequest) => ObjJServer.serve(r)
case r @ Req( _, "plist", GetRequest) => ObjJServer.serve(r)
}
}

/**
* Force the request to be UTF-8
*/
private def makeUtf8(req: HTTPRequest) {
req.setCharacterEncoding("UTF-8")
}

}

object ObjJServer {
def serve(req: Req)(): Box[LiftResponse] =
for {
url <- LiftRules.getResource(req.path.wholePath.mkString("/", "/", ""))
urlConn <- tryo(url.openConnection)
lastModified = ResourceServer.calcLastModified(urlConn)
} yield {
req.testFor304(lastModified, "Expires" -> toInternetDate(millis + 30.days)) openOr {
val stream = url.openStream
StreamingResponse(stream, () => stream.close, urlConn.getContentLength,
(if (lastModified == 0L) Nil else
List(("Last-Modified", toInternetDate(lastModified)))) :::
List(("Expires", toInternetDate(millis + 30.days)),
("Content-Type","application/text")), Nil,
200)
}
}

}
Empty file.
37 changes: 37 additions & 0 deletions src/main/scala/com/liftcode/comet/Clock.scala
@@ -0,0 +1,37 @@
/*
* Clock.scala
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package com.liftcode.comet

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

class Clock extends CometActor {

override def localSetup() {
super.localSetup()
ActorPing.schedule(this, 'Ping , 3 seconds)
}

override def highPriority = {
case 'Ping =>
partialUpdate(currentTime)
ActorPing.schedule(this, 'Ping , 3 seconds)
}

def currentTime: JsCmd = JsRaw("clockCallback("+(""+now).encJs+");")

def render = {
val str: String = """var f = function() {try {"""+(currentTime.toJsCmd)+"""} catch (e) {setTimeout(f, 50);}}; f();"""
OnLoad(JsRaw(str))
}
}
Empty file.
Empty file.
35 changes: 35 additions & 0 deletions src/main/scala/com/liftcode/model/User.scala
@@ -0,0 +1,35 @@
/*
package com.liftcode.model
import _root_.net.liftweb.mapper._
import _root_.net.liftweb.util._
/**
* The singleton that has methods for accessing the database
*/
object User extends User with MetaMegaProtoUser[User] {
override def dbTableName = "users" // define the DB table name
override def screenWrap = Full(<lift:surround with="default" at="content">
<lift:bind /></lift:surround>)
// define the order fields will appear in forms and output
override def fieldOrder = List(id, firstName, lastName, email,
locale, timezone, password, textArea)
// comment this line out to require email validations
override def skipEmailValidation = true
}
/**
* An O-R mapped "User" class that includes first name, last name, password and we add a "Personal Essay" to it
*/
class User extends MegaProtoUser[User] {
def getSingleton = User // what's the "meta" server
// define an additional field for a personal essay
object textArea extends MappedTextarea(this, 2048) {
override def textareaRows = 10
override def textareaCols = 50
override def displayName = "Personal Essay"
}
}
*/
Empty file.

0 comments on commit 9db6d7c

Please sign in to comment.