Permalink
Browse files

Anfang

  • Loading branch information...
0 parents commit bb8b6ff4dbf8931a208bc9eadc6ddd73ce350626 @13yo committed Feb 27, 2012
0 README
No changes.
@@ -0,0 +1,21 @@
+import sbt._
+import Keys._
+
+object MinimalBuild extends Build {
+
+ lazy val buildVersion = "2.0-RC3-SNAPSHOT"
+
+ lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
+ lazy val typesafeSnapshot = "Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/"
+
+ lazy val root = Project(id = "iCal", base = file("."), settings = Project.defaultSettings).settings(
+ version := buildVersion,
+ organization := "eu.kaatz",
+ resolvers += typesafe,
+ resolvers += typesafeSnapshot,
+ libraryDependencies += "com.typesafe" %% "play-mini" % buildVersion withSources() withJavadoc(),
+ libraryDependencies += "com.github.jsuereth.scala-arm" %% "scala-arm" % "1.0" withSources() withJavadoc(),
+ libraryDependencies += "org.mnode.ical4j" % "ical4j" % "1.0.3" withSources() withJavadoc(),
+ mainClass in (Compile, run) := Some("play.core.server.NettyServer")
+ )
+}
@@ -0,0 +1 @@
+sbt.version=0.11.2
@@ -0,0 +1,25 @@
+package eu.kaatz.iCal
+
+import com.typesafe.play.mini._
+import play.api.mvc._
+import play.api.mvc.Results._
+import play.api.libs.json.JsObject
+
+/**
+ * this application is registered via Global
+ */
+object App extends Application {
+ def route = {
+ case GET(Path("/coco")) & QueryString(qs) => Action { request =>
+ println(request.body)
+ println(play.api.Play.current)
+ val result = QueryString(qs, "foo").getOrElse("noh")
+ Ok(<h1>It works!, query String { result }</h1>).as("text/html")
+ }
+ case GET(Path("/import")) => Action { request =>
+
+ val res = Importer.go.toString
+ Ok(JsObject(res)).as("text/html")
+ }
+ }
+}
@@ -0,0 +1 @@
+object Global extends com.typesafe.play.mini.Setup(eu.kaatz.iCal.App)
@@ -0,0 +1,44 @@
+package eu.kaatz.iCal
+import net.fortuna.ical4j.data.CalendarBuilder
+import net.fortuna.ical4j.model.Calendar
+import net.fortuna.ical4j.data.UnfoldingReader
+import java.io.InputStreamReader
+import scala.io.Source
+import java.net.URL
+import scala.io.Codec
+import net.fortuna.ical4j.model.Component
+import scala.collection.mutable.ListBuffer
+import play.api.libs.json.JsValue
+import scala.collection.mutable.Buffer
+import play.api.libs.json.JsString
+
+object Importer {
+ def go = {
+ implicit val codec = Codec.UTF8
+ val url = new URL("https://webmail.software-friends.de/horde/rpc.php/kronolith/tobias.kaatz@software-friends.de/8HqxAk7pT-BOX3bACfJ3PtA.ics")
+ val conn = url.openConnection()
+ val login = new StringBuffer("tobias.kaatz@software-friends.de").append(":").append("Z3t1O2-5j8").toString();
+ val base = login.getBytes();
+ val authorizationString = "Basic " + new String(new sun.misc.BASE64Encoder().encode(base));
+ conn.setRequestProperty("Authorization", authorizationString);
+
+ val s = Source.fromInputStream(conn.getInputStream())
+
+ val reader : UnfoldingReader = new UnfoldingReader(s.reader(), 3000);
+
+ val builder : CalendarBuilder = new CalendarBuilder()
+
+ val calendar : Calendar = builder.build(reader)
+
+ def toJson(cals : Buffer[Component]) = {
+ val eList : Buffer[(String, JsValue)] = cals.map({ x => ("test" -> JsString("demo")) })
+ }
+
+ for (c <- scala.collection.JavaConversions.asBuffer(calendar.getComponents())) {
+ println(c.asInstanceOf[Component].getProperties())
+
+ }
+
+ }
+
+}

0 comments on commit bb8b6ff

Please sign in to comment.