9/08/2013

GitBucket 1.5 released!

We've released GitBucket 1.5 several days before.

GitBucket is a Github clone written with Scala. It's based on Scalatra, Slick and JGit.

This release contains many important new features such as:

  • Fork and pull request
  • LDAP authentication
  • Mail notification

See here to know how to setup GitBucket. It's very easy. Please try GitBucket and any feedback is welcome!

8/02/2013

Non-blocking API for Apache Solr

Today, we've released solr-scala-client 0.0.8!!

This release includes asynchronous and non-blocking API based on AsyncHttpClient and Scala 2.10's Future. See the following simple example:

val client = new AsyncSolrClient("http://localhost:8983/solr")

// Register
client
  .register(Map(
    "id"   -> "005", 
    "name" -> "ThinkPad X1 Carbon", 
    "manu" -> "Lenovo"))
  .onComplete{
    case Success(x) => println("registered!")
    case Failure(t) => t.printStackTrace()
  }

// Query
client.query("name:%name%")
  .fields("id", "manu", "name")
  .facetFields("manu")
  .sortBy("id", Order.asc)
  .getResultAsMap(Map("name" -> "ThinkPad X201s"))
  .onComplete {
    case Success(x) => println(x)
    case Failure(t) => t.printStackTrace()
  }

Methods of AsyncSolrClient return Future. You can process result by callback handler. See more example at here.

This release also contains some other new features such as recommendation search and automatic transaction management. Check the github site to know details of solr-scala-client!

7/04/2013

GitBucket 1.0 released!

Today, we released a first public version of GitBucket which is a Github clone by Scala, it very easy to setup.

The current version of GitBucket provides a basic features below:

  • Public / Private Git repository (http access only)
  • Repository viewer (some advanced features are not implemented)
  • Wiki
  • Issues
  • User management (for Administrators)

Following features are not implemented, but we will make them in the future release!

  • Fork and pull request
  • Activity timeline
  • Search
  • Notification
  • Network graph
  • Statics
  • Watch / Star
  • Team management (like Organization in Github)

You can setup GitBucket by only putting war into your servlet container such as Tomcat or Jetty. Please try it and feedback is welcome!

4/19/2013

eclipse-scala-tools 0.0.4 released!

eclipse-scala-tools is an Eclipse plug-in for sbt.

This is a list of new features and changes in this version:

  • Use system proxy setting
  • SBT 0.12 Support (SBT 0.7 and 0.10 are removed)
  • Use sbteclipse to generate Eclipse project configuration files
  • Outline view

And I have a plan about new features in the future release:

  • Scala IDE 3.x and sbt 0.13 support
  • Select some major libraries at the project creation wizard
  • Multi project support
  • Wizard to import existing sbt project from out of workspace

I hope this plug-in helps you. Enjoy!

4/04/2013

solr-scala-client 0.0.7 is now available!

solr-scala-client is a simple Apache Solr client for Scala based on SolrJ.

The list of new features in 0.0.7:

  • Add build for Scala 2.10
  • Upgrade to SolrJ 4.2.0
  • Support search result highlighting

In this entry, I introduce search result highlighting which is a new feature in this release.

How to Highlight?

You can configure the query to return the highlighted content using QueryBuilder#highlight(). The highlighted field is required, but prefix and suffix is not required. They are optional(default is <em>...</em>).

The highlighted content is set as the "highlight" property to the Map or the case class.

val result = client.query("content: Scala")
  // NOTE: unique key field is required.
  .fields("id")
  // Specify the highlighted field, prefix and postfix (prefix and postfix is optional).
  .highlight("content", "", "")
  .getResultAsMap()

result.documents.foreach { doc: Product =>
  println("id: " + doc("id"))
  println(doc("highlight")) // highlighted content is set as the "highlight" property
}

In SolrJ, we have to map retrieved documents and highlighted contents using the unique key of the index schema. solr-scala-client expects that the unique key is "id".

If your schema has the different field as the unique key, you can specify the unique key name as following:

val result = client.query("content: Scala")
  .id("documentId") // Specify the unique key name
  .fields("documentId")
  .highlight("content", "", "")
  .getResultAsMap()

2/25/2013

Accelerate Play2 development mode

Play2 development mode is very heavy because it checks file modification and reload classes for each requests. And it seems to process requests in serial. So loading web pages which contain many resources such as external CSS, JavaScript files or images is stressful.

play2-fastassets accelerates Play2 development mode by leveraging browser cache.

Replace the routing to controllers.Assets.at by jp.sf.amateras.play2.fastassets.FastAssets.get in conf/routes. This method returns a response which has a header: Cache-Control: private, max-age=3600.

#GET /assets/*file controllers.Assets.at(path="/public", file)
GET /assets/*file jp.sf.amateras.play2.fastassets.FastAssets.get(file)

And add following configurations into conf/application.conf.

fastassets.urlPath=/assets
fastassets.realPath=/public

Use FastAssets.at instead of routes.Assets.at in HTML templates.

@(title: String)(content: Html)
@import jp.sf.amateras.play2.fastassets.FastAssets
<!DOCTYPE html>
<html>
  <head>
    <title>@title</title>
    <link rel="stylesheet" media="screen" href="@FastAssets.at("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@FastAssets.at("images/favicon.png")">
    <script src="@FastAssets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
  </head>
  <body>
    @content
  </body>
</html>

FastAssets.at appends a last modified timestamp to the filename and your browser cache it. When you update the file, this timestamp is also updated. So the browser retrieves a new file from the server instead of the cached contents.

8/25/2012

Jerkson in Play2 development mode

Play2 includes Jerkson which is a Scala wrapper for the Java based JSON library Jackson.

It's very useful and I'm loving it. However when we use it in the Play2 application, it fails to deserialize case classes after reloading in development mode. See the following code:

import com.codahale.jerkson.Json

val json = Json.generate(UserInfo("Naoki Takezoe"))
val info = Json.parse[UserInfo](json)

After reloading in the development mode, this code throws an exception such as ParsingException: Unable to find a case accessor for models.UserInfo.

The reason of this problem is Jerkson hold a class loader in the singleton object.

So this problem could be solved to create new instance which is mixed-in com.codahale.jerkson.Json trait for each Json serialization / deserialization as following:

// This code works in the development mode!
import com.codahale.jerkson.Json

val json = new Json{}.generate(UserInfo("Naoki Takezoe"))
val info = new Json{}.parse[UserInfo](json)

Some of hotswap solutions (reloading recompiled classes) on JVM have similar problem because they are based on classloader swapping. They can make rapid development on JVM and very helpful for our work. However sometimes they trouble us like this.