Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 40f459b16a7c62a78293998729bd9d4187423a09 @hleinone committed Feb 2, 2012
@@ -0,0 +1,9 @@
+.project
+.classpath
+.settings
+.cache
+/target
+/project/target
+/project/projec
+/project/target
+/project/project
@@ -0,0 +1 @@
+web: target/start
@@ -0,0 +1,26 @@
+import com.typesafe.startscript.StartScriptPlugin
+import com.github.siasia.WebPlugin.webSettings
+
+seq(StartScriptPlugin.startScriptForClassesSettings: _*)
+
+seq(webSettings :_*)
+
+name := "scalatra-neo4j"
+
+version := "1.0"
+
+scalaVersion := "2.9.1"
+
+libraryDependencies ++= Seq(
+ "org.scalatra" %% "scalatra" % "2.0.3",
+ "org.scalatra" %% "scalatra-scalate" % "2.0.1",
+ "org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "container",
+ "org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725",
+ "javax.servlet" % "servlet-api" % "2.5" % "provided->default"
+)
+
+resolvers ++= Seq(
+ "Sonatype OSS" at "http://oss.sonatype.org/content/repositories/releases/",
+ "Web plugin repo" at "http://siasia.github.com/maven2",
+ "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
+)
@@ -0,0 +1 @@
+sbt.version=0.11.2
@@ -0,0 +1,3 @@
+resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
+
+addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.5.0")
@@ -0,0 +1 @@
+libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))
@@ -0,0 +1,30 @@
+import org.scalatra.ScalatraFilter
+import org.scalatra.scalate.ScalateSupport
+import java.net.URL
+
+class ExampleEndpointFilter extends ScalatraFilter with ScalateSupport {
+ get("/") {
+ <html>
+ <body>
+ <h1>Hello, world!</h1>
+ Say <a href="hello-scalate">hello to Scalate</a>.
+ </body>
+ </html>
+ }
+
+ notFound {
+ // If no route matches, then try to render a Scaml template
+ val templateBase = requestPath match {
+ case s if s.endsWith("/") => s + "index"
+ case s => s
+ }
+ val templatePath = "/WEB-INF/scalate/templates/" + templateBase + ".scaml"
+ servletContext.getResource(templatePath) match {
+ case url: URL =>
+ contentType = "text/html"
+ templateEngine.layout(templatePath)
+ case _ =>
+ filterChain.doFilter(request, response)
+ }
+ }
+}
@@ -0,0 +1,23 @@
+/*
+* Starts jetty for scalatra programatically
+*
+* Replace YourApplicationEndpointFilter with the filter in your application
+*/
+import org.eclipse.jetty.server.Server
+import org.eclipse.jetty.servlet.{DefaultServlet, ServletContextHandler}
+
+object JettyLauncher {
+ def main(args: Array[String]) {
+ val port = if(System.getenv("PORT") != null) System.getenv("PORT").toInt else 8080
+
+ val server = new Server(port)
+ val context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS)
+
+ context.addFilter(classOf[ExampleEndpointFilter], "/*", 0)
+ context.addServlet(classOf[DefaultServlet], "/");
+ context.setResourceBase("src/main/webapp")
+
+ server.start
+ server.join
+ }
+}
@@ -0,0 +1,12 @@
+-@ val title: String
+-@ val headline: String = title
+-@ val body: String
+
+!!!
+%html
+ %head
+ %title= title
+ %body
+ #content
+ %h1= headline
+ != body
@@ -0,0 +1,4 @@
+- attributes("title") = "Scalatra: a tiny, Sinatra-like web framework for Scala"
+- attributes("headline") = "Welcome to Scalatra"
+
+Hello, Scalate!
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <filter>
+ <filter-name>scalatra</filter-name>
+ <filter-class>ExampleEndpointFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>scalatra</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+</web-app>

0 comments on commit 40f459b

Please sign in to comment.