From d6f27cafa4ee0c562e84d5df1408d87ddde0e878 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 19 Feb 2012 12:55:30 +0100 Subject: [PATCH] First commit with minimalized play2 installation --- .gitignore | 5 +++ README | 9 +++++ Validation.scala | 59 +++++++++++++++++++++++++++++++ app/controllers/Application.scala | 12 +++++++ app/resources/log4j.properties | 4 +++ conf/application.conf | 50 ++++++++++++++++++++++++++ conf/routes | 1 + package.scala | 26 ++++++++++++++ project/Build.scala | 39 ++++++++++++++++++++ project/build.properties | 1 + project/plugins.sbt | 8 +++++ 11 files changed, 214 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100644 Validation.scala create mode 100644 app/controllers/Application.scala create mode 100644 app/resources/log4j.properties create mode 100644 conf/application.conf create mode 100644 conf/routes create mode 100644 package.scala create mode 100644 project/Build.scala create mode 100644 project/build.properties create mode 100644 project/plugins.sbt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b807d65d72 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +logs +project/project +project/target +target +tmp diff --git a/README b/README new file mode 100644 index 0000000000..88ff9273d2 --- /dev/null +++ b/README @@ -0,0 +1,9 @@ +lichess.org in scala +===================================== + +Long way to go. + + +--- + +[http://lichess.org](http://lichess.org) diff --git a/Validation.scala b/Validation.scala new file mode 100644 index 0000000000..e43596f265 --- /dev/null +++ b/Validation.scala @@ -0,0 +1,59 @@ +//import util.control.Exception.allCatch +//import scalaz.{ Validation ⇒ SValidation, Success, Failure, Semigroup, Apply } + +//trait Validation + //extends scalaz.Validations + //with scalaz.Semigroups + //with scalaz.Options + //with scalaz.Identitys { + + //type Valid[A] = SValidation[Error, A] + + //implicit def eitherToValidation[E, B](either: Either[E, B]): Valid[B] = + //validation(either.left map { + //case e: Error => e + //case e: Throwable => Error(e) + //case s: String => Error(s wrapNel) + //}) + + //implicit def stringToError(str: String): Error = Error(str wrapNel) + + //implicit def richStringToError(str: String) = new { + //def toError: Error = stringToError(str) + //} + + //implicit def errorSemigroup: Semigroup[Error] = semigroup(_ |+| _) + + //implicit def richValidation[A](validation: Valid[A]) = new { + //def and[B](f: Valid[A => B])(implicit a: Apply[Valid]): Valid[B] = validation <*> f + //} + + //def unsafe[A](op: ⇒ A)(implicit handle: Throwable => Error = Error.apply): Valid[A] = + //(allCatch either op).left map handle + + //def validateOption[A, B](ao: Option[A])(op: A => Valid[B]): Valid[Option[B]] = + //ao some { a ⇒ op(a) map (_.some) } none success(none) + + //def sequenceValid[A](as: List[Valid[A]]): Valid[List[A]] = + //as.sequence[({ type λ[α] = Valid[α] })#λ, A] +//} + +//import scalaz.NonEmptyList + +//case class Error(messages: NonEmptyList[String]) { + + //def |+|(error: Error): Error = Error(messages |+| error.messages) + + //def messageList = messages.list + + //def size = messageList.size + + //override def toString = messageList map ("* " + _) mkString "\n" +//} + +//object Error { + + //def apply(t: Throwable): Error = string(t.getMessage) + + //def string(str: String): Error = Error(str wrapNel) +//} diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala new file mode 100644 index 0000000000..c99e477b78 --- /dev/null +++ b/app/controllers/Application.scala @@ -0,0 +1,12 @@ +package controllers + +import play.api._ +import play.api.mvc._ + +object Application extends Controller { + + def index = Action { + Ok("Your new application is ready.") + } + +} diff --git a/app/resources/log4j.properties b/app/resources/log4j.properties new file mode 100644 index 0000000000..5d21c4e205 --- /dev/null +++ b/app/resources/log4j.properties @@ -0,0 +1,4 @@ +log4j.rootLogger=info, R +log4j.appender.R=org.apache.log4j.ConsoleAppender +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%-5p %-30.30c{1} %x - %m%n diff --git a/conf/application.conf b/conf/application.conf new file mode 100644 index 0000000000..7903bfa004 --- /dev/null +++ b/conf/application.conf @@ -0,0 +1,50 @@ +# This is the main configuration file for the application. +# ~~~~~ + +# Secret key +# ~~~~~ +# The secret key is used to secure cryptographics functions. +# If you deploy your application to several instances be sure to use the same key! +application.secret="a@23iWMuTu?v=^HqWBe4>Th^RqCRATWI=mPAkdY`_I`m>ovpLi1KKR;CLv`Iny4B" + +# The application languages +# ~~~~~ +application.langs="en" + +# Global object class +# ~~~~~ +# Define the Global object class for this application. +# Default to Global in the root package. +# global=Global + +# Database configuration +# ~~~~~ +# You can declare as many datasources as you want. +# By convention, the default datasource is named `default` +# +# db.default.driver=org.h2.Driver +# db.default.url="jdbc:h2:mem:play" +# db.default.user=sa +# db.default.password= + +mongo.host = localhost +mongo.dbname = lichess + +# Evolutions +# ~~~~~ +# You can disable evolutions if needed +# evolutionplugin=disabled + +# Logger +# ~~~~~ +# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory . + +# Root logger: +logger.root=ERROR + +# Logger used by the framework: +logger.play=INFO + +# Logger provided to your application: +logger.application=DEBUG + diff --git a/conf/routes b/conf/routes new file mode 100644 index 0000000000..90a3b5ddb2 --- /dev/null +++ b/conf/routes @@ -0,0 +1 @@ +GET / controllers.Application.index diff --git a/package.scala b/package.scala new file mode 100644 index 0000000000..5544385a19 --- /dev/null +++ b/package.scala @@ -0,0 +1,26 @@ +package object lila + //extends Validation + //with DateTime + extends scalaz.Identitys + with scalaz.Equals + with scalaz.MABs + with scalaz.Options + with scalaz.Lists + with scalaz.Booleans + with scalaz.Strings + with scalaz.NonEmptyLists + with scalaz.Semigroups { + + /** + * K combinator implementation + * Provides oneliner side effects + * See http://hacking-scala.posterous.com/side-effecting-without-braces + */ + implicit def addKcombinator[A](any: A) = new { + def kCombinator(sideEffect: A => Unit): A = { + sideEffect(any) + any + } + def ~(sideEffect: A => Unit): A = kCombinator(sideEffect) + } +} diff --git a/project/Build.scala b/project/Build.scala new file mode 100644 index 0000000000..78e8189e2e --- /dev/null +++ b/project/Build.scala @@ -0,0 +1,39 @@ +import sbt._ +import Keys._ +import PlayProject._ + +trait Resolvers { + val codahale = "repo.codahale.com" at "http://repo.codahale.com/" + //val twitter = "twitter.com" at "http://maven.twttr.com/" + val typesafe = "typesafe.com" at "http://repo.typesafe.com/typesafe/releases/" + val iliaz = "iliaz.com" at "http://scala.iliaz.com/" + val sonatype = "sonatype" at "http://oss.sonatype.org/content/repositories/releases" +} + +trait Dependencies { + val twitterUtilVersion = "1.12.12" + + val twitterCore = "com.twitter" % "util-core" % twitterUtilVersion + val slf4jNop = "org.slf4j" % "slf4j-nop" % "1.6.4" + val scalaz = "org.scalaz" %% "scalaz-core" % "6.0.4" + val specs2 = "org.specs2" %% "specs2" % "1.8" + val redis = "net.debasishg" %% "redisclient" % "2.4.2" + val json = "net.liftweb" %% "lift-json" % "2.4-RC1" + val casbah = "com.mongodb.casbah" %% "casbah" % "2.1.5-1" + val salat = "com.novus" %% "salat-core" % "0.0.8-SNAPSHOT" +} + +object ApplicationBuild extends Build with Resolvers with Dependencies { + + val appName = "lila" + val appVersion = "1.0-SNAPSHOT" + + val main = PlayProject(appName, appVersion, Seq( + scalaz, specs2, redis, json, slf4jNop + ), mainLang = SCALA).settings( + resolvers := Seq( + codahale, typesafe, iliaz, sonatype + ) + ) + +} diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000000..f4ff7a5afa --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=0.11.2 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000000..11b5324748 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,8 @@ +// Comment to get more information during initialization +logLevel := Level.Warn + +// The Typesafe repository +resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" + +// Use the Play sbt plugin for Play projects +addSbtPlugin("play" % "sbt-plugin" % "2.0-RC3-SNAPSHOT") \ No newline at end of file