Fix presentation of index page and sign-in page.

This commit is contained in:
takezoe
2013-06-29 03:49:31 +09:00
parent 7da39b4785
commit c7d6a56ea2
7 changed files with 68 additions and 21 deletions

View File

@@ -2,12 +2,13 @@ package app
import service._
class IndexController extends IndexControllerBase with RepositoryService with AccountService
class IndexController extends IndexControllerBase with RepositoryService with AccountService with SystemSettingsService
trait IndexControllerBase extends ControllerBase { self: RepositoryService =>
trait IndexControllerBase extends ControllerBase { self: RepositoryService with SystemSettingsService =>
get("/"){
html.index(getAccessibleRepositories(context.loginAccount, baseUrl))
html.index(getAccessibleRepositories(context.loginAccount, baseUrl), loadSystemSettings(),
context.loginAccount.map{ account => getRepositoryNamesOfUser(account.userName) }.getOrElse(Nil))
}
}

View File

@@ -31,7 +31,7 @@ trait SignInControllerBase extends ControllerBase { self: SystemSettingsService
get("/signout"){
session.invalidate
redirect("/signin")
redirect("/")
}
}

View File

@@ -1,7 +1,12 @@
@(account: Option[model.Account])(implicit context: app.Context)
@import context._
@import view.helpers._
@html.main((if(account.isDefined) "Your Profile" else "Create account")){
@html.main((if(account.isDefined) "Edit your profile" else "Create your account")){
@if(account.isDefined){
<h3>Edit your profile</h3>
} else {
<h3>Create your account</h3>
}
<form action="@if(account.isDefined){@url(account.get.userName)/_edit}else{/register}" method="POST" validate="true">
@if(account.isEmpty){
<fieldset>

View File

@@ -1,11 +1,14 @@
@(repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context)
@(repositories: List[service.RepositoryService.RepositoryInfo], systemSettings: service.SystemSettingsService.SystemSettings,
userRepositories: List[String])(implicit context: app.Context)
@import context._
@import view.helpers._
@main("GitBucket"){
<div class="row-fluid">
<div class="span8">
<h3>Recent updated repositories</h3>
@repositories.map { repository =>
<div class="block">
<div class="block-header-2">
<div class="block-header">
<a href="@url(repository.owner)">@repository.owner</a>
/
<a href="@url(repository)">@repository.name</a>
@@ -19,4 +22,23 @@
<div><span class="muted small">Last updated: @datetime(repository.repository.lastActivityDate)</span></div>
</div>
}
</div>
<div class="span4">
@if(loginAccount.isEmpty){
@signinform(systemSettings)
} else {
<table class="table table-bordered">
<tr>
<th>Your repositories (@userRepositories.size)</th>
</tr>
@userRepositories.map { repositoryName =>
<tr>
<td><a href="@path/@loginAccount.get.userName/@repositoryName">@repositoryName</a></td>
</tr>
}
</table>
}
</div>
</div>
}

View File

@@ -1,18 +1,7 @@
@(systemSettings: service.SystemSettingsService.SystemSettings)(implicit context: app.Context)
@import context._
@main("Sign in"){
<form action="@path/signin" method="POST" validate="true">
<label for="userName">Username</label>
<input type="text" name="userName" id="userName"/>
<span id="error-userName" class="error"></span>
<label for="password">Password</label>
<input type="password" name="password" id="password"/>
<span id="error-password" class="error"></span>
<div>
<input type="submit" class="btn btn-success" value="Sign in"/>
@if(systemSettings.allowAccountRegistration){
<a href="@path/register" class="btn">Create new account</a>
}
<div class="signin-form">
@signinform(systemSettings)
</div>
</form>
}

View File

@@ -0,0 +1,25 @@
@(systemSettings: service.SystemSettingsService.SystemSettings)(implicit context: app.Context)
@import context._
<table class="table table-bordered">
<tr>
<th>Sign in</th>
</tr>
<tr>
<td>
<form action="@path/signin" method="POST" validate="true">
<label for="userName">Username</label>
<input type="text" name="userName" id="userName" style="width: 95%"/>
<span id="error-userName" class="error"></span>
<label for="password">Password</label>
<input type="password" name="password" id="password" style="width: 95%"/>
<span id="error-password" class="error"></span>
<div>
<input type="submit" class="btn btn-success" value="Sign in"/>
@if(systemSettings.allowAccountRegistration){
<a href="@path/register" class="btn">Create new account</a>
}
</div>
</form>
</td>
</tr>
</table>

View File

@@ -172,6 +172,11 @@ hr {
margin-bottom: 4px;
}
div.signin-form {
width: 350px;
margin: 30px auto;
}
/****************************************************************************/
/* Repository Viewer */
/****************************************************************************/