diff --git a/src/main/scala/app/CreateRepositoryServlet.scala b/src/main/scala/app/CreateRepositoryServlet.scala index 66e8a61..7477fe4 100644 --- a/src/main/scala/app/CreateRepositoryServlet.scala +++ b/src/main/scala/app/CreateRepositoryServlet.scala @@ -24,7 +24,7 @@ * Show the new repository form. */ get("/") { - html.newrepo.render() + html.newrepo() } /** diff --git a/src/main/scala/app/RepositoryViewerServlet.scala b/src/main/scala/app/RepositoryViewerServlet.scala index e878a30..cbe009d 100644 --- a/src/main/scala/app/RepositoryViewerServlet.scala +++ b/src/main/scala/app/RepositoryViewerServlet.scala @@ -25,7 +25,7 @@ */ get("/:owner") { val owner = params("owner") - html.user.render(owner, getRepositories(owner).map(getRepositoryInfo(owner, _))) + html.user(owner, getRepositories(owner).map(getRepositoryInfo(owner, _))) } /** @@ -85,7 +85,7 @@ } } - html.commits.render(branchName, getRepositoryInfo(owner, repository), + html.commits(branchName, getRepositoryInfo(owner, repository), listBuffer.toSeq.splitWith{ (commit1, commit2) => view.helpers.date(commit1.time) == view.helpers.date(commit2.time) }, page, i.hasNext) @@ -108,7 +108,7 @@ val git = Git.open(dir) val latestRev = git.log.addPath(path).call.iterator.next - html.blob.render(branchName, getRepositoryInfo(owner, repository), path.split("/").toList, content, + html.blob(branchName, getRepositoryInfo(owner, repository), path.split("/").toList, content, CommitInfo(latestRev.getName, latestRev.getCommitterIdent.getWhen, latestRev.getCommitterIdent.getName, latestRev.getShortMessage)) } @@ -187,7 +187,7 @@ val git = Git.open(dir) val latestRev = {if(path == ".") git.log else git.log.addPath(path)}.call.iterator.next - html.files.render( + html.files( // current branch branchName, // repository diff --git a/src/main/scala/app/ServletBase.scala b/src/main/scala/app/ServletBase.scala index c153d3b..b8a35b3 100644 --- a/src/main/scala/app/ServletBase.scala +++ b/src/main/scala/app/ServletBase.scala @@ -14,6 +14,8 @@ implicit val jsonFormats = DefaultFormats + implicit def context: Context = Context(servletContext.getContextPath) + // TODO get from session val LoginUser = System.getProperty("user.name") @@ -42,4 +44,6 @@ } } -} \ No newline at end of file +} + +case class Context(path: String) \ No newline at end of file diff --git a/src/main/twirl/blob.scala.html b/src/main/twirl/blob.scala.html index 96f1e7e..158def3 100644 --- a/src/main/twirl/blob.scala.html +++ b/src/main/twirl/blob.scala.html @@ -1,14 +1,15 @@ -@(branch: String, repository: app.RepositoryInfo, pathList: List[String], content: String, latestCommit: app.CommitInfo) +@(branch: String, repository: app.RepositoryInfo, pathList: List[String], content: String, latestCommit: app.CommitInfo)(implicit context: app.Context) +@import context._ @main(repository.owner+"/"+repository.name) { @header(branch, repository) @navtab(branch, repository, "files")
- @repository.name / + @repository.name / @pathList.zipWithIndex.map { case (path, i) => @if(i == pathList.length - 1){ @path } else { - @path / + @path / } }
@@ -17,7 +18,7 @@
- @latestCommit.committer + @latestCommit.committer @view.helpers.datetime(latestCommit.time) @view.helpers.cut(latestCommit.message, 100)
@@ -49,5 +50,5 @@ padding-left: 20px; } - + } diff --git a/src/main/twirl/commits.scala.html b/src/main/twirl/commits.scala.html index 0fdf42d..64e4334 100644 --- a/src/main/twirl/commits.scala.html +++ b/src/main/twirl/commits.scala.html @@ -1,9 +1,10 @@ -@(branch: String, repository: app.RepositoryInfo, commits: Seq[Seq[app.CommitInfo]], page: Int, hasNext: Boolean) +@(branch: String, repository: app.RepositoryInfo, commits: Seq[Seq[app.CommitInfo]], page: Int, hasNext: Boolean)(implicit context: app.Context) +@import context._ @main(repository.owner+"/"+repository.name) { @header(branch, repository) @navtab(branch, repository, "commits")
- @repository.name / Commit History + @repository.name / Commit History
@commits.map { date => @@ -17,7 +18,7 @@
@view.helpers.cut(commit.message, 100)
- @commit.committer + @commit.committer @view.helpers.datetime(commit.time)
diff --git a/src/main/twirl/files.scala.html b/src/main/twirl/files.scala.html index 575ddc2..a0d579d 100644 --- a/src/main/twirl/files.scala.html +++ b/src/main/twirl/files.scala.html @@ -1,11 +1,12 @@ -@(branch: String, repository: app.RepositoryInfo, pathList: List[String], latestCommit: app.CommitInfo, files: List[app.FileInfo]) +@(branch: String, repository: app.RepositoryInfo, pathList: List[String], latestCommit: app.CommitInfo, files: List[app.FileInfo])(implicit context: app.Context) +@import context._ @main(repository.owner+"/"+repository.name) { @header(branch, repository) @navtab(branch, repository, "files")
- @repository.name / + @repository.name / @pathList.zipWithIndex.map { case (path, i) => - @path / + @path / }
@@ -24,7 +25,7 @@ @if(pathList.size > 0){ - + @@ -33,20 +34,20 @@ - + }
....
@if(file.isDirectory){ - + } else { - + } @if(file.isDirectory){ - @file.name + @file.name } else { - @file.name + @file.name } @view.helpers.datetime(file.time)@view.helpers.cut(file.message, 60) [@file.committer]@view.helpers.cut(file.message, 60) [@file.committer]
diff --git a/src/main/twirl/header.scala.html b/src/main/twirl/header.scala.html index cbc6b62..e6a534b 100644 --- a/src/main/twirl/header.scala.html +++ b/src/main/twirl/header.scala.html @@ -1,6 +1,7 @@ -@(branch: String, repository: app.RepositoryInfo) +@(branch: String, repository: app.RepositoryInfo)(implicit context: app.Context) +@import context._
- @repository.owner / @repository.name + @repository.owner / @repository.name