Commits

Anonymous committed f82d388

init

  • Participants
  • Parent commits a7d95c7

Comments (0)

Files changed (15)

+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+  
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>yoshihiro503</groupId>
+  <artifactId>twigraph</artifactId>
+  <version>1.0</version>
+  <packaging>war</packaging>
+  <name>twigraph Project</name>
+  <inceptionYear>2010</inceptionYear>
+  <properties>
+    <scala.version>2.8.1</scala.version>
+    <!-- Common plugin settings -->
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
+    <!-- vscaladoc settings -->
+    <maven.scaladoc.vscaladocVersion>1.2-m1</maven.scaladoc.vscaladocVersion>
+    <vscaladoc.links.liftweb.pathsufix>scaladocs/</vscaladoc.links.liftweb.pathsufix>
+    <vscaladoc.links.liftweb.baseurl>http://scala-tools.org/mvnsites/liftweb</vscaladoc.links.liftweb.baseurl>
+  </properties>
+
+  <repositories>
+    <repository>
+      <id>scala-tools.releases</id>
+      <name>Scala-Tools Dependencies Repository for Releases</name>
+      <url>http://scala-tools.org/repo-releases</url>
+    </repository>
+  </repositories>
+
+  <pluginRepositories>
+    <pluginRepository>
+      <id>scala-tools.releases</id>
+      <name>Scala-Tools Plugins Repository for Releases</name>
+      <url>http://scala-tools.org/repo-releases</url>
+    </pluginRepository>
+  </pluginRepositories>
+
+  <dependencies>
+    <dependency>
+      <groupId>net.liftweb</groupId>
+      <artifactId>lift-mapper_2.8.1</artifactId>
+      <version>2.2</version>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <version>0.9.26</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.7</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>6.1.25</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>
+        <version>2.14.3</version>
+        <configuration>
+          <charset>${project.build.sourceEncoding}</charset>
+          <jvmArgs>
+            <jvmArg>-Xmx1024m</jvmArg>
+            <jvmArg>-DpackageLinkDefs=file://${project.build.directory}/packageLinkDefs.properties</jvmArg>
+          </jvmArgs>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compile</goal>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.4.2</version>
+        <executions>
+          <execution>
+            <id>default-copy-resources</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <overwrite>true</overwrite>
+              <outputDirectory>${project.build.directory}</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>${project.basedir}/src</directory>
+                  <includes>
+                    <include>packageLinkDefs.properties</include>
+                  </includes>
+                  <filtering>true</filtering>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>maven-jetty-plugin</artifactId>
+        <version>6.1.25</version>
+        <configuration>
+          <contextPath>/</contextPath>
+          <scanIntervalSeconds>5</scanIntervalSeconds>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>net.sf.alchim</groupId>
+        <artifactId>yuicompressor-maven-plugin</artifactId>
+        <version>0.7.1</version>
+        <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>
+        <version>2.2</version>
+        <configuration>
+          <downloadSources>true</downloadSources>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <version>2.7</version>
+        <configuration>
+          <downloadSources>true</downloadSources>
+          <additionalProjectnatures>
+            <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
+          </additionalProjectnatures>
+          <additionalBuildcommands>
+            <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
+          </additionalBuildcommands>
+          <classpathContainers>
+            <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
+            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+          </classpathContainers>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.scala-tools</groupId>
+        <artifactId>maven-scala-plugin</artifactId>
+        <version>2.14.3</version>
+        <configuration>
+          <charset>${project.build.sourceEncoding}</charset>
+          <jvmArgs>
+            <jvmArg>-Xmx1024m</jvmArg>
+            <jvmArg>-DpackageLinkDefs=file://${project.build.directory}/packageLinkDefs.properties</jvmArg>
+          </jvmArgs>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>

project/build.properties

+project.organization=yoshihiro503
+project.name=twigraph
+project.version=1.0
+sbt.version=0.7.4
+def.scala.version=2.7.7
+build.scala.versions=2.8.1
+project.initialize=false

project/build/LiftProject.scala

+import sbt._
+
+class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
+
+  // Add Maven Local repository for SBT to search for (disable if this doesn't suit you)
+  val mavenLocal = "Local Maven Repository" at "file://"+Path.userHome+"/.m2/repository"
+
+  
+}

src/main/scala/bootstrap/liftweb/Boot.scala

+package bootstrap.liftweb
+
+import _root_.net.liftweb.common._
+import _root_.net.liftweb.util._
+import _root_.net.liftweb.http._
+import _root_.net.liftweb.sitemap._
+import _root_.net.liftweb.sitemap.Loc._
+import Helpers._
+
+/**
+  * 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("yoshihiro503")
+
+    // Build SiteMap
+    val entries = Menu(Loc("Home", List("index"), "Home")) :: Nil
+    LiftRules.setSiteMap(SiteMap(entries:_*))
+  }
+}
+

src/main/scala/yoshihiro503/comet/.keep

Empty file added.

src/main/scala/yoshihiro503/model/.keep

Empty file added.

src/main/scala/yoshihiro503/snippet/HelloWorld.scala

+package yoshihiro503 {
+package snippet {
+
+import _root_.scala.xml.NodeSeq
+import _root_.net.liftweb.util.Helpers
+import Helpers._
+
+class HelloWorld {
+  def howdy(in: NodeSeq): NodeSeq =
+    Helpers.bind("b", in, "time" -> (new _root_.java.util.Date).toString)
+}
+
+}
+}

src/main/scala/yoshihiro503/view/.keep

Empty file added.

src/main/webapp/WEB-INF/web.xml

+<?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>

src/main/webapp/index.html

+<lift:surround with="default" at="content">
+		<h2>Welcome to your project!</h2>
+		<p>
+      <lift:helloWorld.howdy>
+        <span>Welcome to twigraph at <b:time/></span>
+      </lift:helloWorld.howdy>
+    </p>
+</lift:surround>
+

src/main/webapp/templates-hidden/default.html

+<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>yoshihiro503:twigraph:1.0</title>
+		<script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
+	</head>
+	<body>
+		<lift:bind name="content" />
+		<lift:Menu.builder />
+		<lift:msgs/>
+	</body>
+</html>

src/packageLinkDefs.properties

+net.liftweb.common=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-common/${vscaladoc.links.liftweb.pathsufix}
+net.liftweb.json=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-json/${vscaladoc.links.liftweb.pathsufix}
+net.liftweb.util=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-util/${vscaladoc.links.liftweb.pathsufix}
+net.liftweb.http=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-webkit/${vscaladoc.links.liftweb.pathsufix}
+net.liftweb.http.js=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-webkit/${vscaladoc.links.liftweb.pathsufix}
+net.liftweb.sitemap=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-webkit/${vscaladoc.links.liftweb.pathsufix}
+net.liftweb.mapper=${vscaladoc.links.liftweb.baseurl}/lift-persistence/lift-mapper/${vscaladoc.links.liftweb.pathsufix}

src/test/scala/LiftConsole.scala

+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)
+  }
+}

src/test/scala/RunWebApp.scala

+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)
+    }
+  }
+}

src/test/scala/yoshihiro503/AppTest.scala

+package yoshihiro503
+
+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)
+      
+      /*
+       // disable SAX parser validation
+      if (file.isFile && file.exists && handledXml(file.getName)) {
+        try {
+          import java.io.FileInputStream
+          val fis = new FileInputStream(file)
+          try {
+            XML.load(fis)
+          } finally {
+            fis.close()
+          }
+        } catch {
+          case e: _root_.org.xml.sax.SAXParseException => failed = file :: failed
+        }
+      }
+      */
+
+      if (file.isFile && file.exists && 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)
+    }
+  }
+}