mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 03:26:06 +01:00
Add app.Context to transfer implicit data from Servlet to view.
This commit is contained in:
@@ -24,7 +24,7 @@ class CreateRepositoryServlet extends ServletBase {
|
||||
* Show the new repository form.
|
||||
*/
|
||||
get("/") {
|
||||
html.newrepo.render()
|
||||
html.newrepo()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ class RepositoryViewerServlet extends ServletBase {
|
||||
*/
|
||||
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 @@ class RepositoryViewerServlet extends ServletBase {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class RepositoryViewerServlet extends ServletBase {
|
||||
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 @@ class RepositoryViewerServlet extends ServletBase {
|
||||
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
|
||||
|
||||
@@ -14,6 +14,8 @@ abstract class ServletBase extends ScalatraServlet with JacksonJsonSupport {
|
||||
|
||||
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 @@ abstract class ServletBase extends ScalatraServlet with JacksonJsonSupport {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
case class Context(path: String)
|
||||
@@ -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")
|
||||
<div class="head">
|
||||
<a href="/@repository.owner/@repository.name/tree/@branch">@repository.name</a> /
|
||||
<a href="@path/@repository.owner/@repository.name/tree/@branch">@repository.name</a> /
|
||||
@pathList.zipWithIndex.map { case (path, i) =>
|
||||
@if(i == pathList.length - 1){
|
||||
@path
|
||||
} else {
|
||||
<a href="/@repository.owner/@repository.name/tree/@branch/@pathList.take(i + 1).mkString("/")">@path</a> /
|
||||
<a href="@path/@repository.owner/@repository.name/tree/@branch/@pathList.take(i + 1).mkString("/")">@path</a> /
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@@ -17,7 +18,7 @@
|
||||
<tr>
|
||||
<th style="font-weight: normal;">
|
||||
<div class="pull-left">
|
||||
<a href="/@latestCommit.committer">@latestCommit.committer</a>
|
||||
<a href="@path/@latestCommit.committer">@latestCommit.committer</a>
|
||||
<span class="description">@view.helpers.datetime(latestCommit.time)</span>
|
||||
@view.helpers.cut(latestCommit.message, 100)<br>
|
||||
</div>
|
||||
@@ -49,5 +50,5 @@
|
||||
padding-left: 20px;
|
||||
}
|
||||
</style>
|
||||
<script src="/assets/google-code-prettify/run_prettify.js"></script>
|
||||
<script src="@path/assets/google-code-prettify/run_prettify.js"></script>
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
<div class="head">
|
||||
<a href="/@repository.owner/@repository.name/tree/@branch">@repository.name</a> / Commit History
|
||||
<a href="@path/@repository.owner/@repository.name/tree/@branch">@repository.name</a> / Commit History
|
||||
</div>
|
||||
|
||||
@commits.map { date =>
|
||||
@@ -17,7 +18,7 @@
|
||||
<div class="pull-left">
|
||||
<a href="#"><strong>@view.helpers.cut(commit.message, 100)</strong></a><br>
|
||||
<div class="small">
|
||||
<a href="/@commit.committer">@commit.committer</a>
|
||||
<a href="@path/@commit.committer">@commit.committer</a>
|
||||
<span class="description">@view.helpers.datetime(commit.time)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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")
|
||||
<div class="head">
|
||||
<a href="/@repository.owner/@repository.name/tree/@branch">@repository.name</a> /
|
||||
<a href="@path/@repository.owner/@repository.name/tree/@branch">@repository.name</a> /
|
||||
@pathList.zipWithIndex.map { case (path, i) =>
|
||||
<a href="/@repository.owner/@repository.name/tree/@branch/@pathList.take(i + 1).mkString("/")">@path</a> /
|
||||
<a href="@path/@repository.owner/@repository.name/tree/@branch/@pathList.take(i + 1).mkString("/")">@path</a> /
|
||||
}
|
||||
</div>
|
||||
<table class="table table-file-list">
|
||||
@@ -24,7 +25,7 @@
|
||||
@if(pathList.size > 0){
|
||||
<tr>
|
||||
<td width="16"></td>
|
||||
<td><a href="/@repository.owner/@repository.name@if(pathList.size > 1){/tree/@branch/@pathList.init.mkString("/")}">..</a></td>
|
||||
<td><a href="@path/@repository.owner/@repository.name@if(pathList.size > 1){/tree/@branch/@pathList.init.mkString("/")}">..</a></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@@ -33,20 +34,20 @@
|
||||
<tr>
|
||||
<td width="16">
|
||||
@if(file.isDirectory){
|
||||
<img src="/assets/common/images/folder.png"/>
|
||||
<img src="@path/assets/common/images/folder.png"/>
|
||||
} else {
|
||||
<img src="/assets/common/images/file.png"/>
|
||||
<img src="@path/assets/common/images/file.png"/>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if(file.isDirectory){
|
||||
<a href="/@repository.owner/@repository.name/tree@{(branch :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
||||
<a href="@path/@repository.owner/@repository.name/tree@{(branch :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
||||
} else {
|
||||
<a href="/@repository.owner/@repository.name/blob@{(branch :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
||||
<a href="@path/@repository.owner/@repository.name/blob@{(branch :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
||||
}
|
||||
</td>
|
||||
<td>@view.helpers.datetime(file.time)</td>
|
||||
<td>@view.helpers.cut(file.message, 60) [<a href="/@file.committer">@file.committer</a>]</td>
|
||||
<td>@view.helpers.cut(file.message, 60) [<a href="@path/@file.committer">@file.committer</a>]</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@(branch: String, repository: app.RepositoryInfo)
|
||||
@(branch: String, repository: app.RepositoryInfo)(implicit context: app.Context)
|
||||
@import context._
|
||||
<div class="head">
|
||||
<a href="/@repository.owner">@repository.owner</a> / <a href="/@repository.owner/@repository.name">@repository.name</a>
|
||||
<a href="@path/@repository.owner">@repository.owner</a> / <a href="@path/@repository.owner/@repository.name">@repository.name</a>
|
||||
</div>
|
||||
<div class="navbar">
|
||||
<div class="navbar-inner">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@(title: String)(body: Html)
|
||||
@(title: String)(body: Html)(implicit context: app.Context)
|
||||
@import context._
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -6,16 +7,16 @@
|
||||
<title>@title - GitBucket</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- Le styles -->
|
||||
<link href="/assets/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="/assets/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="@path/assets/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="@path/assets/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="/assets/bootstrap/js/html5shiv.js"></script>
|
||||
<script src="@path/assets/bootstrap/js/html5shiv.js"></script>
|
||||
<![endif]-->
|
||||
<link href="/assets/common/css/gitbucket.css" rel="stylesheet">
|
||||
<script src="/assets/common/js/jquery-1.9.1.js"></script>
|
||||
<script src="/assets/common/js/validation.js"></script>
|
||||
<script src="/assets/bootstrap/js/bootstrap.js"></script>
|
||||
<link href="@path/assets/common/css/gitbucket.css" rel="stylesheet">
|
||||
<script src="@path/assets/common/js/jquery-1.9.1.js"></script>
|
||||
<script src="@path/assets/common/js/validation.js"></script>
|
||||
<script src="@path/assets/bootstrap/js/bootstrap.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse">
|
||||
@@ -29,7 +30,7 @@
|
||||
<a class="brand" href="#">GitBucket</a>
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav pull-right">
|
||||
<li><a href="/new">New repo</a></li>
|
||||
<li><a href="@path/new">New repo</a></li>
|
||||
<li><a href="#about">Account</a></li>
|
||||
<li><a href="#contact">Sign out</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
@(branch: String, repository: app.RepositoryInfo, active: String)
|
||||
@(branch: String, repository: app.RepositoryInfo, active: String)(implicit context: app.Context)
|
||||
@import context._
|
||||
<ul class="nav nav-tabs">
|
||||
<li>
|
||||
<div class="btn-group" style="margin-right: 20px;">
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">branch: <strong>@branch</strong> <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
@repository.branchList.map { branch =>
|
||||
<li><a href="/@repository.owner/@repository.name/@if(active=="commits"){commits} else {tree}/@branch">@branch</a></li>
|
||||
<li><a href="@path/@repository.owner/@repository.name/@if(active=="commits"){commits} else {tree}/@branch">@branch</a></li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li@if(active=="files"){ class="active"}><a href="/@repository.owner/@repository.name/tree/@branch">Files</a></li>
|
||||
<li@if(active=="commits"){ class="active"}><a href="/@repository.owner/@repository.name/commits/@branch">Commits</a></li>
|
||||
<li@if(active=="files"){ class="active"}><a href="@path/@repository.owner/@repository.name/tree/@branch">Files</a></li>
|
||||
<li@if(active=="commits"){ class="active"}><a href="@path/@repository.owner/@repository.name/commits/@branch">Commits</a></li>
|
||||
<li@if(active=="tags"){ class="active"}><a href="#">Tags</a></li>
|
||||
<li class="pull-right">
|
||||
<div class="input-prepend">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@()
|
||||
@()(implicit context: app.Context)
|
||||
@import context._
|
||||
@main("Create a New Repository"){
|
||||
<form id="form" method="post" action="/new" validate="true">
|
||||
<form id="form" method="post" action="@path/new" validate="true">
|
||||
<fieldset>
|
||||
<label for="name"><strong>Repository name</strong></label>
|
||||
<input type="text" name="name" id="name" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@(user: String, repositories: List[app.RepositoryInfo])
|
||||
@(user: String, repositories: List[app.RepositoryInfo])(implicit context: app.Context)
|
||||
@import context._
|
||||
@main(user){
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
@@ -24,7 +25,7 @@
|
||||
</ul>
|
||||
@repositories.map { repository =>
|
||||
<div class="block">
|
||||
<div class="block-header-2"><a href="/@user/@repository.name">@repository.name</a></div>
|
||||
<div class="block-header-2"><a href="@path/@user/@repository.name">@repository.name</a></div>
|
||||
<div>xxxxxxxxxxxxxxxxxxxx</div>
|
||||
<div><span class="description small">Last updated: yyyy/mm/dd</span></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user