Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of the example app of the HelloWorld Lift module.
- Loading branch information
0 parents
commit 61483e5
Showing
13 changed files
with
335 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target/ | ||
lib_managed/ | ||
src_managed/ | ||
project/boot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Project properties | ||
#Fri Dec 24 01:59:21 CET 2010 | ||
project.organization=net.lift_modules | ||
project.name=HelloWorldExampleApp | ||
sbt.version=0.7.4 | ||
project.version=1.0 | ||
build.scala.versions=2.8.1 | ||
project.initialize=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
|
||
import sbt._ | ||
|
||
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) { | ||
val mavenLocal = "Local Maven Repository" at | ||
"file://"+Path.userHome+"/.m2/repository" | ||
|
||
val scalatoolsSnapshot = "Scala Tools Snapshot" at | ||
"http://scala-tools.org/repo-snapshots/" | ||
|
||
val scalatoolsRelease = "Scala Tools Snapshot" at | ||
"http://scala-tools.org/repo-releases/" | ||
|
||
val liftVersion = "2.3-SNAPSHOT" | ||
|
||
override def libraryDependencies = Set( | ||
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default", | ||
"net.liftweb" %% "lift-testkit" % liftVersion % "compile->default", | ||
"org.mortbay.jetty" % "jetty" % "6.1.22" % "test->default", | ||
"junit" % "junit" % "4.5" % "test->default", | ||
"org.scala-tools.testing" % "specs" % "1.6.1" % "test->default", | ||
"net.lift_modules" %% "helloworld" % "1.0" | ||
) ++ super.libraryDependencies | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
|
||
package bootstrap.liftweb | ||
|
||
import _root_.net.liftweb.http.{LiftRules, NotFoundAsTemplate, ParsePath} | ||
import _root_.net.liftweb.sitemap.{SiteMap, Menu, Loc} | ||
import _root_.net.liftweb.util.{ NamedPF } | ||
|
||
import net.lift_modules.HelloWorld.HelloWorld | ||
|
||
class Boot { | ||
def boot { | ||
|
||
|
||
// where to search snippet | ||
LiftRules.addToPackages("net.lift_modules.HelloWorldExampleApp") | ||
|
||
// build sitemap | ||
val entries = List(Menu("Home") / "index") ::: | ||
Nil | ||
|
||
LiftRules.uriNotFound.prepend(NamedPF("404handler"){ | ||
case (req,failure) => NotFoundAsTemplate( | ||
ParsePath(List("exceptions","404"),"html",false,false)) | ||
}) | ||
|
||
LiftRules.setSiteMap(SiteMap(entries:_*)) | ||
|
||
// set character encoding | ||
LiftRules.early.append(_.setCharacterEncoding("UTF-8")) | ||
|
||
HelloWorld.init | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
|
||
<!DOCTYPE web-app | ||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | ||
"http://java.sun.com/dtd/web-app_2_3.dtd"> | ||
|
||
<web-app> | ||
<filter> | ||
<filter-name>LiftFilter</filter-name> | ||
<display-name>Lift Filter</display-name> | ||
<description>The Filter that intercepts lift calls</description> | ||
<filter-class>net.liftweb.http.LiftFilter</filter-class> | ||
</filter> | ||
|
||
|
||
<filter-mapping> | ||
<filter-name>LiftFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
|
||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<lift:surround with="default" at="content"> | ||
<h2>Welcome to your project!</h2> | ||
|
||
|
||
</lift:surround> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | ||
<meta name="description" content="" /> | ||
<meta name="keywords" content="" /> | ||
|
||
<title>code:app:0.1-SNAPSHOT</title> | ||
<lift:CSS.blueprint /> | ||
<lift:CSS.fancyType /> | ||
<script id="jquery" src="/classpath/jquery.js" type="text/javascript"/> | ||
<script id="json" src="/classpath/json.js" type="text/javascript"/> | ||
<style type="text/css"> | ||
/* <![CDATA[ */ | ||
.edit_error_class { | ||
display: block; | ||
color: red; | ||
} | ||
|
||
.sidebar ul { | ||
margin:0; | ||
padding:0; | ||
border-bottom:1px solid #ccc; | ||
} | ||
|
||
|
||
.sidebar ul li { | ||
margin:0; | ||
padding:0; | ||
list-style:none; | ||
border:1px solid #ccc; | ||
border-bottom:none; | ||
} | ||
|
||
.sidebar ul li a { | ||
display:block; | ||
padding:3px; | ||
text-indent:30px; | ||
text-decoration:none; | ||
} | ||
|
||
.sidebar ul li span { | ||
display:block; | ||
padding:3px; | ||
text-indent:30px; | ||
text-decoration:none; | ||
} | ||
|
||
.sidebar ul li a:hover { | ||
background-color: #eee; | ||
} | ||
|
||
|
||
/* ]]> */ | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="column span-12 last" style="text-align: right"> | ||
<h1 class="alt">app<img alt="" id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> | ||
</div> | ||
|
||
<hr/> | ||
|
||
<div class="column span-6 colborder sidebar"> | ||
<hr class="space" /> | ||
<lift:Menu.builder /> | ||
<div> | ||
<lift:Msgs showAll="true"/> | ||
<hr class="space" /> | ||
</div> | ||
</div> | ||
|
||
<div class="column span-17 last"> | ||
<lift:bind name="content" /> | ||
</div> | ||
|
||
<hr /> | ||
<div class="column span-23 last" style="text-align: center"> | ||
<h4 class="alt"> | ||
<a href="http://www.liftweb.net"><i>Lift</i></a> | ||
is Copyright 2007-2010 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div> | ||
<wizard:screen_info><div>Page <wizard:screen_number/> of <wizard:total_screens/></div></wizard:screen_info> | ||
<wizard:wizard_top> <div> <wizard:bind/> </div> </wizard:wizard_top> | ||
<wizard:screen_top> <div> <wizard:bind/> </div> </wizard:screen_top> | ||
<wizard:errors> <div> <ul> <wizard:item> <li> <wizard:bind/> </li> </wizard:item> </ul> </div> </wizard:errors> | ||
<div> <wizard:fields> | ||
<table> | ||
<wizard:line> | ||
<tr> | ||
<td> | ||
<wizard:label><label wizard:for=""><wizard:bind/></label></wizard:label> | ||
<wizard:help><span><wizard:bind/></span></wizard:help> | ||
<wizard:field_errors> <ul> <wizard:error> <li> <wizard:bind/> </li> </wizard:error> </ul> </wizard:field_errors> | ||
</td> | ||
<td> <wizard:form/> </td> | ||
</tr> | ||
</wizard:line> | ||
</table> | ||
</wizard:fields> </div> | ||
<div> <table> <tr> <td> <wizard:prev/> </td> <td> <wizard:cancel/> </td> <td> <wizard:next/> </td> </tr> </table> </div> | ||
<wizard:screen_bottom> <div> <wizard:bind/> </div> </wizard:screen_bottom> | ||
<wizard:wizard_bottom> <div> <wizard:bind/> </div> </wizard:wizard_bottom> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import _root_.bootstrap.liftweb.Boot | ||
import _root_.scala.tools.nsc.MainGenericRunner | ||
|
||
object LiftConsole { | ||
def main(args : Array[String]) { | ||
// Instantiate your project's Boot file | ||
val b = new Boot() | ||
// Boot your project | ||
b.boot | ||
// Now run the MainGenericRunner to get your repl | ||
MainGenericRunner.main(args) | ||
// After the repl exits, then exit the scala script | ||
exit(0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import _root_.org.mortbay.jetty.Connector | ||
import _root_.org.mortbay.jetty.Server | ||
import _root_.org.mortbay.jetty.webapp.WebAppContext | ||
import org.mortbay.jetty.nio._ | ||
|
||
object RunWebApp extends Application { | ||
val server = new Server | ||
val scc = new SelectChannelConnector | ||
scc.setPort(8080) | ||
server.setConnectors(Array(scc)) | ||
|
||
val context = new WebAppContext() | ||
context.setServer(server) | ||
context.setContextPath("/") | ||
context.setWar("src/main/webapp") | ||
|
||
server.addHandler(context) | ||
|
||
try { | ||
println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP") | ||
server.start() | ||
while (System.in.available() == 0) { | ||
Thread.sleep(5000) | ||
} | ||
server.stop() | ||
server.join() | ||
} catch { | ||
case exc : Exception => { | ||
exc.printStackTrace() | ||
System.exit(100) | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/test/scala/net/lift_modules/HelloWorldExampleApp/AppTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
|
||
package net.lift_modules.HelloWorldExampleApp { | ||
|
||
import _root_.java.io.File | ||
import _root_.junit.framework._ | ||
import Assert._ | ||
import _root_.scala.xml.XML | ||
import _root_.net.liftweb.util._ | ||
import _root_.net.liftweb.common._ | ||
|
||
object AppTest { | ||
def suite: Test = { | ||
val suite = new TestSuite(classOf[AppTest]) | ||
suite | ||
} | ||
|
||
def main(args : Array[String]) { | ||
_root_.junit.textui.TestRunner.run(suite) | ||
} | ||
} | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
class AppTest extends TestCase("app") { | ||
|
||
/** | ||
* Rigourous Tests :-) | ||
*/ | ||
def testOK() = assertTrue(true) | ||
// def testKO() = assertTrue(false); | ||
|
||
/** | ||
* Tests to make sure the project's XML files are well-formed. | ||
* | ||
* Finds every *.html and *.xml file in src/main/webapp (and its | ||
* subdirectories) and tests to make sure they are well-formed. | ||
*/ | ||
def testXml() = { | ||
var failed: List[File] = Nil | ||
|
||
def handledXml(file: String) = | ||
file.endsWith(".xml") | ||
|
||
def handledXHtml(file: String) = | ||
file.endsWith(".html") || file.endsWith(".htm") || file.endsWith(".xhtml") | ||
|
||
def wellFormed(file: File) { | ||
if (file.isDirectory) | ||
for (f <- file.listFiles) wellFormed(f) | ||
|
||
if (file.isFile && handledXml(file.getName)) { | ||
try { | ||
XML.loadFile(file) | ||
} catch { | ||
case e: _root_.org.xml.sax.SAXParseException => failed = file :: failed | ||
} | ||
} | ||
if (file.isFile && handledXHtml(file.getName)) { | ||
PCDataXmlParser(new _root_.java.io.FileInputStream(file.getAbsolutePath)) match { | ||
case Full(_) => // file is ok | ||
case _ => failed = file :: failed | ||
} | ||
} | ||
} | ||
|
||
wellFormed(new File("src/main/webapp")) | ||
|
||
val numFails = failed.size | ||
if (numFails > 0) { | ||
val fileStr = if (numFails == 1) "file" else "files" | ||
val msg = "Malformed XML in " + numFails + " " + fileStr + ": " + failed.mkString(", ") | ||
println(msg) | ||
fail(msg) | ||
} | ||
} | ||
} | ||
} |