3. What’s GitBucket?
• Open-Source Github clone based on
Scala and JGit
• Easy installation by pure JVM based
solution
• Main target is intranet users who can’t
use Github by political reason
4. Demo
Demo site (Thanks to @xuwei_k)
http://gitbucket.herokuapp.com/
19. Technologies
• Type safety supports our aggressive
development
• Based on existing Java resources
• Pure JVM based solution makes easy
installation
20. Scalatra
• Simple and powerful servlet based
web framework inspired by Sinatra
• More dynamic than Play2, but high
extendibility
class MyServlet extends ScalatraServlet with ScalateSupport {!
get("/") {!
<html>!
<body>!
<h1>Hello, world!</h1>!
Say <a href="hello-scalate">hello to Scalate</a>.!
</body>!
</html>!
}!
}
21. scalatra-forms
• Extension library for Scalatra
• Server side and client side validation
at once
case class SignInForm(userName: String, password: String)!
!
val form = mapping(!
"userName" -> trim(label("Username", text(required))),!
"password" -> trim(label("Password", text(required)))!
)(SignInForm.apply)!
!!
post("/signin", form){ form =>!
authenticate(context.settings, form.userName, form.password) match {!
case Some(account) => signin(account)!
case None => redirect("/signin")!
}!
}
22. scalatra-forms
Send form data to /signin/validate by Ajax
Validation result as JSON
Web Browser Server
Send form data to /signin if validation passed
Response
Added by scalatra-forms
automatically
Display errors if
validation failed
Validate again
System error if
validation failed
25. JGit
• Git implementation in Java
• Includes GitServlet which provides Git
server
// Clone repository!
Git.cloneRepository()!
.setURI("https://github.com/takezoe/solr-scala-client.git")!
.setDirectory(new File("git"))!
.call()!
!
// Show logs!
val logs = Git.open(new java.io.File("git")).log().call()!
logs.asScala.foreach { rev =>!
println(rev.getCommitterIdent().getEmailAddress() + " - " + rev.getCommitTime())!
println(rev.getFullMessage())!
}
26. H2
• Embeddable pure Java RDBMS
• GitBucket has automatic migration
system on H2
Differences of these
SQLs are run in order.
27. Apache MINA
• Apache MINA is a framework for NIO
based network applications
• GitBucket uses MINA SSHD which is an
sshd implementation based on MINA
28. Apache MINA
import org.apache.sshd.SshServer;!
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;!
import org.apache.sshd.server.shell.ProcessShellFactory;!
import java.util.EnumSet;!
!
public class Main {!
!
public static void main(String[] args) throws Exception {!
SshServer server = SshServer.setUpDefaultServer();!
server.setPort(8080);!
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("key.ser"));!
server.setPasswordAuthenticator((userName, password, serverSession) -> true);!
server.setPublickeyAuthenticator((userName, publicKey, serverSession) -> true);!
!
server.setShellFactory(new ProcessShellFactory(new String[]{"cmd.exe"},!
EnumSet.of(!
ProcessShellFactory.TtyOptions.Echo,!
ProcessShellFactory.TtyOptions.ONlCr,!
ProcessShellFactory.TtyOptions.ICrNl)));!
!
server.start();!
}!
}
30. Github
• The greatest source code hosting
service and social coding platform
• We are always watching Github to
catch up new features or changes
31. IntelliJ IDEA
• The best IDE for Scala
• Not perfect, but practical enough
• GitBucket project has OpenSource
license
32. Gitter
• Chat service which has high affinity
with Github
• Sign-in by Github account
• Chat room which corresponds to
Github repository
• Displays users who saw the message
33. ZenHub
• Provides “Kanban” to Github Issues by
Chrome Extension
• Visualizes issue status and priority
34. Roadmap
• Scala based plug-in system
• Features for code review
• Mobile support
• Performance Improvement