mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 11:06:06 +01:00
Merge branch 'master' of https://github.com/takezoe/gitbucket
Conflicts: src/main/scala/app/SettingsController.scala
This commit is contained in:
Binary file not shown.
2
sbt.bat
2
sbt.bat
@@ -1,2 +1,2 @@
|
||||
set SCRIPT_DIR=%~dp0
|
||||
java -Dhttp.proxyHost=proxy.intellilink.co.jp -Dhttp.proxyPort=8080 -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -jar "%SCRIPT_DIR%\sbt-launch-0.12.3.jar" %*
|
||||
java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -jar "%SCRIPT_DIR%\sbt-launch-0.12.3.jar" %*
|
||||
|
||||
@@ -118,9 +118,9 @@ INSERT INTO ACCOUNT (
|
||||
UPDATED_DATE,
|
||||
LAST_LOGIN_DATE
|
||||
) VALUES (
|
||||
'admin',
|
||||
'admin@localhost',
|
||||
'admin',
|
||||
'root',
|
||||
'root@localhost',
|
||||
'root',
|
||||
1,
|
||||
'https://github.com/takezoe/gitbucket',
|
||||
SYSDATE,
|
||||
|
||||
@@ -6,6 +6,7 @@ class ScalatraBootstrap extends LifeCycle {
|
||||
override def init(context: ServletContext) {
|
||||
context.mount(new IndexController, "/")
|
||||
context.mount(new SignInController, "/*")
|
||||
context.mount(new UsersController, "/*")
|
||||
context.mount(new WikiController, "/*")
|
||||
context.mount(new CreateRepositoryController, "/*")
|
||||
context.mount(new RepositoryViewerController, "/*")
|
||||
|
||||
@@ -18,11 +18,11 @@ class CreateRepositoryController extends CreateRepositoryControllerBase
|
||||
trait CreateRepositoryControllerBase extends ControllerBase {
|
||||
self: RepositoryService with WikiService with UsersOnlyAuthenticator =>
|
||||
|
||||
case class RepositoryCreationForm(name: String, description: String) // TODO Option?
|
||||
case class RepositoryCreationForm(name: String, description: Option[String])
|
||||
|
||||
val form = mapping(
|
||||
"name" -> trim(label("Repository name", text(required, maxlength(40), repository))),
|
||||
"description" -> trim(label("Description" , text()))
|
||||
"description" -> trim(label("Description" , optional(text())))
|
||||
)(RepositoryCreationForm.apply)
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ trait CreateRepositoryControllerBase extends ControllerBase {
|
||||
val loginUserName = context.loginAccount.get.userName
|
||||
|
||||
// Insert to the database at first
|
||||
createRepository(form.name, loginUserName, Some(form.description))
|
||||
createRepository(form.name, loginUserName, form.description)
|
||||
|
||||
// Create the actual repository
|
||||
val gitdir = getRepositoryDir(loginUserName, form.name)
|
||||
|
||||
@@ -7,22 +7,35 @@ import jp.sf.amateras.scalatra.forms._
|
||||
class SettingsController extends SettingsControllerBase
|
||||
with RepositoryService with AccountService with OwnerOnlyAuthenticator
|
||||
|
||||
|
||||
trait SettingsControllerBase extends ControllerBase {
|
||||
self: RepositoryService with AccountService with OwnerOnlyAuthenticator =>
|
||||
|
||||
case class OptionsForm(description: Option[String], defaultBranch: String, repositoryType: Int)
|
||||
|
||||
val optionsForm = mapping(
|
||||
"description" -> trim(label("Description" , optional(text()))),
|
||||
"defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100)))),
|
||||
"repositoryType" -> trim(label("Repository Type", number()))
|
||||
)(OptionsForm.apply)
|
||||
|
||||
case class CollaboratorForm(userName: String)
|
||||
|
||||
val form = mapping(
|
||||
val collaboratorForm = mapping(
|
||||
"userName" -> trim(label("Username", text(required, collaborator)))
|
||||
)(CollaboratorForm.apply)
|
||||
|
||||
/**
|
||||
* Redirect to the Options page.
|
||||
*/
|
||||
get("/:owner/:repository/settings")(ownerOnly {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
redirect("/%s/%s/settings/options".format(owner, repository))
|
||||
})
|
||||
|
||||
/**
|
||||
* Display the Options page.
|
||||
*/
|
||||
get("/:owner/:repository/settings/options")(ownerOnly {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
@@ -30,6 +43,22 @@ trait SettingsControllerBase extends ControllerBase {
|
||||
settings.html.options(getRepository(owner, repository, servletContext).get)
|
||||
})
|
||||
|
||||
/**
|
||||
* Save the repository options.
|
||||
*/
|
||||
post("/:owner/:repository/settings/options", optionsForm){ form =>
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
|
||||
// save repository options
|
||||
saveRepositoryOptions(owner, repository, form.description, form.defaultBranch, form.repositoryType)
|
||||
|
||||
redirect("%s/%s/settings/options".format(owner, repository))
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the Collaborators page.
|
||||
*/
|
||||
get("/:owner/:repository/settings/collaborators")(ownerOnly {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
@@ -37,13 +66,31 @@ trait SettingsControllerBase extends ControllerBase {
|
||||
settings.html.collaborators(getCollaborators(owner, repository), getRepository(owner, repository, servletContext).get)
|
||||
})
|
||||
|
||||
post("/:owner/:repository/settings/collaborators/_add", form)(ownerOnly { form =>
|
||||
/**
|
||||
* Add the collaborator.
|
||||
*/
|
||||
post("/:owner/:repository/settings/collaborators/add", collaboratorForm)(ownerOnly { form =>
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
addCollaborator(owner, repository, form.userName)
|
||||
redirect("/%s/%s/settings/collaborators".format(owner, repository))
|
||||
})
|
||||
|
||||
/**
|
||||
* Add the collaborator.
|
||||
*/
|
||||
get("/:owner/:repository/settings/collaborators/remove")(ownerOnly {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
val userName = params("name")
|
||||
removeCollaborator(owner, repository, userName)
|
||||
redirect("/%s/%s/settings/collaborators".format(owner, repository))
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Provides Constraint to validate the collaborator name.
|
||||
*/
|
||||
def collaborator: Constraint = new Constraint(){
|
||||
def validate(name: String, value: String): Option[String] = {
|
||||
getAccountByUserName(value) match {
|
||||
|
||||
@@ -24,6 +24,7 @@ trait SignInControllerBase extends ControllerBase { self: AccountService =>
|
||||
redirect("/signin")
|
||||
} else {
|
||||
session.setAttribute("LOGIN_ACCOUNT", account.get)
|
||||
updateLastLoginDate(account.get.userName)
|
||||
redirect("/%s".format(account.get.userName))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,76 @@
|
||||
package app
|
||||
|
||||
class UsersController extends ControllerBase {
|
||||
import model._
|
||||
import service._
|
||||
import jp.sf.amateras.scalatra.forms._
|
||||
|
||||
get("/"){
|
||||
|
||||
class UsersController extends UsersControllerBase with AccountService
|
||||
|
||||
trait UsersControllerBase extends ControllerBase { self: AccountService =>
|
||||
|
||||
// TODO ユーザ名の先頭に_は使えないようにする&利用可能文字チェック
|
||||
case class UserForm(userName: String, password: String, mailAddress: String, userType: Int, url: Option[String])
|
||||
|
||||
val newForm = mapping(
|
||||
"userName" -> trim(label("Username" , text(required, maxlength(100), unique))),
|
||||
"password" -> trim(label("Password" , text(required, maxlength(100)))),
|
||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))),
|
||||
"userType" -> trim(label("User Type" , number())),
|
||||
"url" -> trim(label("URL" , optional(text(maxlength(200)))))
|
||||
)(UserForm.apply)
|
||||
|
||||
val editForm = mapping(
|
||||
"userName" -> trim(label("Username" , text())),
|
||||
"password" -> trim(label("Password" , text(required, maxlength(100)))),
|
||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))),
|
||||
"userType" -> trim(label("User Type" , number())),
|
||||
"url" -> trim(label("URL" , optional(text(maxlength(200)))))
|
||||
)(UserForm.apply)
|
||||
|
||||
get("/admin/users"){
|
||||
admin.html.userlist(getAllUsers())
|
||||
}
|
||||
|
||||
get("/admin/users/_new"){
|
||||
admin.html.useredit(None)
|
||||
}
|
||||
|
||||
post("/admin/users/_new", newForm){ form =>
|
||||
val currentDate = new java.sql.Date(System.currentTimeMillis)
|
||||
createAccount(Account(
|
||||
userName = form.userName,
|
||||
password = form.password,
|
||||
mailAddress = form.mailAddress,
|
||||
userType = form.userType,
|
||||
url = form.url,
|
||||
registeredDate = currentDate,
|
||||
updatedDate = currentDate,
|
||||
lastLoginDate = None))
|
||||
|
||||
redirect("/admin/users")
|
||||
}
|
||||
|
||||
get("/admin/users/:userName/_edit"){
|
||||
val userName = params("userName")
|
||||
admin.html.useredit(getAccountByUserName(userName))
|
||||
}
|
||||
|
||||
post("/admin/users/:name/_edit", editForm){ form =>
|
||||
val userName = params("userName")
|
||||
val currentDate = new java.sql.Date(System.currentTimeMillis)
|
||||
updateAccount(getAccountByUserName(userName).get.copy(
|
||||
password = form.password,
|
||||
mailAddress = form.mailAddress,
|
||||
userType = form.userType,
|
||||
url = form.url,
|
||||
updatedDate = currentDate))
|
||||
|
||||
redirect("/admin/users")
|
||||
}
|
||||
|
||||
def unique: Constraint = new Constraint(){
|
||||
def validate(name: String, value: String): Option[String] =
|
||||
getAccountByUserName(value).map { _ => "User already exists." }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class WikiController extends WikiControllerBase
|
||||
trait WikiControllerBase extends ControllerBase {
|
||||
self: WikiService with RepositoryService with CollaboratorsOnlyAuthenticator =>
|
||||
|
||||
// TODO ユーザ名の先頭に_は使えないようにする
|
||||
case class WikiPageEditForm(pageName: String, content: String, message: Option[String], currentPageName: String)
|
||||
|
||||
val newForm = mapping(
|
||||
@@ -32,8 +33,8 @@ trait WikiControllerBase extends ControllerBase {
|
||||
val repository = params("repository")
|
||||
|
||||
getWikiPage(owner, repository, "Home") match {
|
||||
case Some(page) => wiki.html.wiki("Home", page, getRepository(owner, repository, servletContext).get)
|
||||
case None => wiki.html.wikiedit("Home", None, getRepository(owner, repository, servletContext).get)
|
||||
case Some(page) => wiki.html.wiki("Home", page, getRepository(owner, repository, servletContext).get, isWritable(owner, repository))
|
||||
case None => redirect("/%s/%s/wiki/Home/_edit".format(owner, repository))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +44,8 @@ trait WikiControllerBase extends ControllerBase {
|
||||
val pageName = params("page")
|
||||
|
||||
getWikiPage(owner, repository, pageName) match {
|
||||
case Some(page) => wiki.html.wiki(pageName, page, getRepository(owner, repository, servletContext).get)
|
||||
case None => wiki.html.wikiedit(pageName, None, getRepository(owner, repository, servletContext).get)
|
||||
case Some(page) => wiki.html.wiki(pageName, page, getRepository(owner, repository, servletContext).get, isWritable(owner, repository))
|
||||
case None => redirect("/%s/%s/wiki/%s/_edit".format(owner, repository, pageName)) // TODO URLEncode
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
|
||||
wiki.html.wikipages(getWikiPageList(owner, repository), getRepository(owner, repository, servletContext).get)
|
||||
wiki.html.wikipages(getWikiPageList(owner, repository), getRepository(owner, repository, servletContext).get, isWritable(owner, repository))
|
||||
}
|
||||
|
||||
get("/:owner/:repository/wiki/_history"){
|
||||
@@ -166,6 +167,15 @@ trait WikiControllerBase extends ControllerBase {
|
||||
}
|
||||
}
|
||||
|
||||
def isWritable(owner: String, repository: String): Boolean = {
|
||||
context.loginAccount match {
|
||||
case Some(a) if(a.userType == AccountService.Administrator) => true
|
||||
case Some(a) if(a.userName == owner) => true
|
||||
case Some(a) if(getCollaborators(owner, repository).contains(a.userName)) => true
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
def unique: Constraint = new Constraint(){
|
||||
def validate(name: String, value: String): Option[String] = {
|
||||
if(getWikiPageList(params("owner"), params("repository")).contains(value)){
|
||||
|
||||
@@ -6,9 +6,30 @@ import Database.threadLocalSession
|
||||
|
||||
trait AccountService {
|
||||
|
||||
def getAccountByUserName(userName: String): Option[Account] =
|
||||
def getAccountByUserName(userName: String): Option[Account] =
|
||||
Query(Accounts) filter(_.userName is userName.bind) firstOption
|
||||
|
||||
def getAllUsers(): List[Account] = Query(Accounts) sortBy(_.userName) list
|
||||
|
||||
def createAccount(account: Account): Unit = Accounts.* insert account
|
||||
|
||||
def updateAccount(account: Account): Unit =
|
||||
Query(Accounts)
|
||||
.filter { a => a.userName is account.userName.bind }
|
||||
.map { a => a.password ~ a.mailAddress ~ a.userType ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? }
|
||||
.update (
|
||||
account.password,
|
||||
account.mailAddress,
|
||||
account.userType,
|
||||
account.url,
|
||||
account.registeredDate,
|
||||
account.updatedDate,
|
||||
account.lastLoginDate)
|
||||
|
||||
def updateLastLoginDate(userName: String): Unit =
|
||||
Query(Accounts).filter(_.userName is userName.bind).map(_.lastLoginDate)
|
||||
.update(new java.sql.Date(System.currentTimeMillis))
|
||||
|
||||
}
|
||||
|
||||
object AccountService {
|
||||
|
||||
@@ -26,7 +26,7 @@ trait RepositoryService { self: AccountService =>
|
||||
|
||||
val currentDate = new java.sql.Date(System.currentTimeMillis)
|
||||
|
||||
Repositories.* insert
|
||||
Repositories insert
|
||||
Repository(
|
||||
repositoryName = repositoryName,
|
||||
userName = userName,
|
||||
@@ -104,11 +104,23 @@ trait RepositoryService { self: AccountService =>
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Updates the last activity date of the repository.
|
||||
* Updates the last activity date of the repository.
|
||||
*/
|
||||
def updateLastActivityDate(userName: String, repositoryName: String): Unit = {
|
||||
|
||||
}
|
||||
def updateLastActivityDate(userName: String, repositoryName: String): Unit =
|
||||
Query(Repositories)
|
||||
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
||||
.map { _.lastActivityDate }
|
||||
.update (new java.sql.Date(System.currentTimeMillis))
|
||||
|
||||
/**
|
||||
* Save repository options.
|
||||
*/
|
||||
def saveRepositoryOptions(userName: String, repositoryName: String,
|
||||
description: Option[String], defaultBranch: String, repositoryType: Int): Unit =
|
||||
Query(Repositories)
|
||||
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
||||
.map { r => r.description.? ~ r.defaultBranch ~ r.repositoryType ~ r.updatedDate }
|
||||
.update (description, defaultBranch, repositoryType, new java.sql.Date(System.currentTimeMillis))
|
||||
|
||||
/**
|
||||
* Add collaborator to the repository.
|
||||
@@ -118,11 +130,31 @@ trait RepositoryService { self: AccountService =>
|
||||
* @param collaboratorName the collaborator name
|
||||
*/
|
||||
def addCollaborator(userName: String, repositoryName: String, collaboratorName: String): Unit =
|
||||
Collaborators.* insert(Collaborator(userName, repositoryName, collaboratorName))
|
||||
Collaborators insert(Collaborator(userName, repositoryName, collaboratorName))
|
||||
|
||||
/**
|
||||
* Remove collaborator from the repository.
|
||||
*
|
||||
* @param userName the user name of the repository owner
|
||||
* @param repositoryName the repository name
|
||||
* @param collaboratorName the collaborator name
|
||||
*/
|
||||
def removeCollaborator(userName: String, repositoryName: String, collaboratorName: String): Unit =
|
||||
(Query(Collaborators) filter { c =>
|
||||
(c.userName is userName.bind) && (c.repositoryName is repositoryName.bind) && (c.collaboratorName is collaboratorName.bind)
|
||||
}).delete
|
||||
|
||||
|
||||
/**
|
||||
* Returns the list of collaborators name which is sorted with ascending order.
|
||||
*
|
||||
* @param userName the user name of the repository owner
|
||||
* @param repositoryName the repository name
|
||||
* @return the list of collaborators name
|
||||
*/
|
||||
def getCollaborators(userName: String, repositoryName: String): List[String] =
|
||||
(Query(Collaborators) filter { collaborator =>
|
||||
(collaborator.userName is userName.bind) && (collaborator.repositoryName is repositoryName.bind)
|
||||
(Query(Collaborators) filter { c =>
|
||||
(c.userName is userName.bind) && (c.repositoryName is repositoryName.bind)
|
||||
} sortBy(_.collaboratorName) list) map(_.collaboratorName)
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package view
|
||||
import java.util.Date
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
import twirl.api.Html
|
||||
|
||||
import org.pegdown._
|
||||
import org.pegdown.LinkRenderer.Rendering
|
||||
import org.pegdown.ast.WikiLinkNode
|
||||
@@ -19,9 +21,9 @@ object helpers {
|
||||
def date(date: Date): String = new SimpleDateFormat("yyyy/MM/dd").format(date)
|
||||
|
||||
// TODO escape html tags using HtmlEscapeUtils (Commons Lang)
|
||||
def format(value: String): twirl.api.Html = twirl.api.Html(
|
||||
def format(value: String): Html = Html(
|
||||
value.replaceAll(" ", " ").replaceAll("\t", " ").replaceAll("\n", "<br>"))
|
||||
|
||||
|
||||
/**
|
||||
* Converts the issue number and the commit id to the link.
|
||||
*/
|
||||
@@ -59,7 +61,8 @@ object helpers {
|
||||
}
|
||||
}
|
||||
})
|
||||
twirl.api.Html(html)
|
||||
|
||||
Html(html)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
40
src/main/twirl/admin/useredit.scala.html
Normal file
40
src/main/twirl/admin/useredit.scala.html
Normal file
@@ -0,0 +1,40 @@
|
||||
@(account: Option[model.Account])(implicit context: app.Context)
|
||||
@import context._
|
||||
@import service.AccountService._
|
||||
@html.main(if(account.isEmpty) "New User" else "Update User"){
|
||||
<form method="POST" action="@if(account.isEmpty){@path/admin/users/_new} else {@path/admin/users/@account.get.userName/_edit}" validate="true">
|
||||
<fieldset>
|
||||
<label for="userName"><strong>Username</strong></label>
|
||||
<input type="text" name="userName" id="userName" value="@account.map(_.userName)"@if(account.isDefined){ readonly}/>
|
||||
<span id="error-userName" class="error"></span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="password"><strong>Password</strong></label>
|
||||
<input type="password" name="password" id="password" value="@account.map(_.password)"/>
|
||||
<span id="error-password" class="error"></span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="mailAddress"><strong>Mail Address</strong></label>
|
||||
<input type="text" name="mailAddress" id="mailAddress" value="@account.map(_.mailAddress)"/>
|
||||
<span id="error-mailAddress" class="error"></span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label><strong>User Type</strong></label>
|
||||
<label for="userType_Normal">
|
||||
<input type="radio" name="userType" id="userType_Normal" value="@Normal"@if(account.isEmpty || account.get.userType==Normal){ checked}/> Normal
|
||||
</label>
|
||||
<label for="userType_Admin">
|
||||
<input type="radio" name="userType" id="userType_Admin" value="@Administrator"@if(account.isDefined && account.get.userType==Administrator){ checked}/> Administrator
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label><strong>URL (Optional)</strong></label>
|
||||
<input type="text" name="url" id="url" style="width: 400px;" value="@account.map(_.url)"/>
|
||||
<span id="error-url" class="error"></span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<input type="submit" class="btn btn-primary" value="@if(account.isEmpty){Create User} else {Update User}"/>
|
||||
<a href="@path/admin/users" class="btn">Cancel</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
}
|
||||
37
src/main/twirl/admin/userlist.scala.html
Normal file
37
src/main/twirl/admin/userlist.scala.html
Normal file
@@ -0,0 +1,37 @@
|
||||
@(users: List[model.Account])(implicit context: app.Context)
|
||||
@import context._
|
||||
@import service.AccountService._
|
||||
@html.main("Manage Users"){
|
||||
<div style="text-align: right; margin-bottom: 4px;">
|
||||
<a href="@path/admin/users/_new" class="btn">New User</a>
|
||||
</div>
|
||||
<table class="table table-borderd table-hover">
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Mail Address</th>
|
||||
<th>Type</th>
|
||||
<th>URL</th>
|
||||
<th>Registered</th>
|
||||
<th>Updated</th>
|
||||
<th>Last Login</th>
|
||||
</tr>
|
||||
@users.map { account =>
|
||||
<tr>
|
||||
<td><a href="@path/admin/users/@account.userName/_edit">@account.userName</a></td>
|
||||
<td>@account.mailAddress</td>
|
||||
<td>
|
||||
@if(account.userType == Normal){
|
||||
Normal
|
||||
}
|
||||
@if(account.userType == Administrator){
|
||||
Administrator
|
||||
}
|
||||
</td>
|
||||
<td>@account.url</td>
|
||||
<td>@account.registeredDate</td>
|
||||
<td>@account.updatedDate</td>
|
||||
<td>@account.lastLoginDate</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
@(active: String, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||
@import context._
|
||||
@import service.AccountService._
|
||||
@import service.RepositoryService._
|
||||
<div class="head">
|
||||
<a href="@path/@repository.owner">@repository.owner</a> / <a href="@path/@repository.owner/@repository.name">@repository.name</a>
|
||||
@if(repository.repository.repositoryType == Private){
|
||||
<i class="icon-lock"></i>
|
||||
}
|
||||
</div>
|
||||
<table class="global-nav box-header">
|
||||
<tr>
|
||||
@@ -14,9 +19,11 @@
|
||||
<th class="box-header@if(active=="wiki"){ active}">
|
||||
<a href="@path/@repository.owner/@repository.name/wiki">Wiki</a>
|
||||
</th>
|
||||
@if(loginAccount.isDefined && (loginAccount.get.userType == Administrator || loginAccount.get.userName == repository.owner)){
|
||||
<th class="box-header@if(active=="settings"){ active}">
|
||||
<a href="@path/@repository.owner/@repository.name/settings">Settings</a>
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@(repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context)
|
||||
@import context._
|
||||
@import service.RepositoryService._
|
||||
@main("GitBucket"){
|
||||
<h3>Recent updated repositories</h3>
|
||||
@repositories.map { repository =>
|
||||
@@ -8,8 +9,13 @@
|
||||
<a href="@path/@repository.owner">@repository.owner</a>
|
||||
/
|
||||
<a href="@path/@repository.owner/@repository.name">@repository.name</a>
|
||||
@if(repository.repository.repositoryType == Private){
|
||||
<i class="icon-lock"></i>
|
||||
}
|
||||
</div>
|
||||
<div>@repository.repository.description</div>
|
||||
@if(repository.repository.description.isDefined){
|
||||
<div>@repository.repository.description</div>
|
||||
}
|
||||
<div><span class="description small">Last updated: @repository.repository.lastActivityDate</span></div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
@if(loginAccount.isDefined){
|
||||
<li><a href="@path/new">New repo</a></li>
|
||||
<li><a href="@path/@loginAccount.get.userName">Account</a></li>
|
||||
<li><a href="#users">Users</a></li>
|
||||
<li><a href="@path/admin/users">Users</a></li>
|
||||
<li><a href="@path/signout">Sign out</a></li>
|
||||
} else {
|
||||
<li><a href="@path/signin">Sign in</a></li>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<fieldset>
|
||||
<label for="name"><strong>Repository name</strong></label>
|
||||
<input type="text" name="name" id="name" />
|
||||
<span id="error-name" class="error-message"></span>
|
||||
<span id="error-name" class="error"></span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="description"><strong>Description</strong> (optional)</label>
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
@html.header("settings", repository)
|
||||
@menu("collaborators", repository){
|
||||
<h3>Manage Collaborators</h3>
|
||||
<ul>
|
||||
<ul class="collaborator">
|
||||
@collaborators.map { collaboratorName =>
|
||||
<li>@collaboratorName</li>
|
||||
<li>
|
||||
<a href="@path/@collaboratorName">@collaboratorName</a>
|
||||
<a href="@path/@repository.owner/@repository.name/settings/collaborators/remove?name=@collaboratorName" class="remove">(remove)</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<form method="POST" action="@path/@repository.owner/@repository.name/settings/collaborators/_add" validate="true">
|
||||
<form method="POST" action="@path/@repository.owner/@repository.name/settings/collaborators/add" validate="true">
|
||||
<div>
|
||||
<span class="error" id="error-userName"></span>
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
<li@if(active=="collaborators"){ class="active"}>
|
||||
<a href="@path/@repository.owner/@repository.name/settings/collaborators">Collaborators</a>
|
||||
</li>
|
||||
<li@if(active=="delete"){ class="active"}>
|
||||
<a href="@path/@repository.owner/@repository.name/settings/delete">Delete Repository</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span9">
|
||||
|
||||
@@ -1,32 +1,41 @@
|
||||
@(repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||
@import context._
|
||||
@import service.RepositoryService._
|
||||
@html.main("Settings"){
|
||||
@html.header("settings", repository)
|
||||
@menu("options", repository){
|
||||
<form id="form" method="post" action="@path/new" validate="true">
|
||||
<form id="form" method="post" action="@path/@repository.owner/@repository.name/settings/options" validate="true">
|
||||
<div class="box">
|
||||
<div class="box-header">Settings</div>
|
||||
<div class="box-content">
|
||||
<fieldset>
|
||||
<label for="description"><strong>Description</strong></label>
|
||||
<input type="text" name="description" id="description" style="width: 600px;" value="@repository.repository.description"/>
|
||||
</fieldset>
|
||||
<hr>
|
||||
<fieldset>
|
||||
<label for="defaultBranch"><strong>Default Branch</strong></label>
|
||||
<select name="defaultBranch" id="defaultBranch">
|
||||
<option value="master">master</option>
|
||||
@repository.branchList.map { branch =>
|
||||
<option value="@branch"@if(branch==repository.repository.defaultBranch){ selected}>@branch</option>
|
||||
}
|
||||
</select>
|
||||
</fieldset>
|
||||
<hr>
|
||||
<fieldset>
|
||||
<label><strong>Repository Type</strong></label>
|
||||
<label>
|
||||
<input type="radio" name="repositoryType" value="0" checked>
|
||||
<input type="radio" name="repositoryType" value="@Public"@if(repository.repository.repositoryType==Public){ checked}>
|
||||
<strong>Public</strong> - All users and guests can read this repository.
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="repositoryType" value="1">
|
||||
<input type="radio" name="repositoryType" value="@Private"@if(repository.repository.repositoryType==Private){ checked}>
|
||||
<strong>Private</strong> - Only collaborators can read this repository.
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div class="box">
|
||||
<div class="box-header">Features</div>
|
||||
<div class="box-content">
|
||||
@@ -56,6 +65,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<fieldset>
|
||||
<input type="submit" class="btn btn-primary" value="Apply changes"/>
|
||||
<!--
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
@(account: model.Account, repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context)
|
||||
@import context._
|
||||
@import service.RepositoryService._
|
||||
@main(account.userName){
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<div class="block">
|
||||
<div class="block-header-1">Naoki Takezoe</div>
|
||||
<div class="block-header-2">@account.userName</div>
|
||||
<div class="block-header-1">@account.userName</div>
|
||||
</div>
|
||||
<div class="block">
|
||||
<div><i class="icon-home"></i> <a href="@account.url">@account.url</a></div>
|
||||
@@ -25,8 +25,15 @@
|
||||
</ul>
|
||||
@repositories.map { repository =>
|
||||
<div class="block">
|
||||
<div class="block-header-2"><a href="@path/@repository.owner/@repository.name">@repository.name</a></div>
|
||||
<div>@repository.repository.description</div>
|
||||
<div class="block-header-2">
|
||||
<a href="@path/@repository.owner/@repository.name">@repository.name</a>
|
||||
@if(repository.repository.repositoryType == Private){
|
||||
<i class="icon-lock"></i>
|
||||
}
|
||||
</div>
|
||||
@if(repository.repository.description.isDefined){
|
||||
<div>@repository.repository.description</div>
|
||||
}
|
||||
<div><span class="description small">Last updated: @repository.repository.lastActivityDate</span></div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@(pageName: String, page: service.WikiService.WikiPageInfo, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||
@(pageName: String, page: service.WikiService.WikiPageInfo, repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
||||
@import view.helpers
|
||||
@import context._
|
||||
@html.main(pageName + " - " + repository.owner + "/" + repository.name){
|
||||
@@ -10,7 +10,7 @@
|
||||
</li>
|
||||
<li class="pull-right">
|
||||
<div class="btn-group">
|
||||
@if(loginAccount.isDefined){
|
||||
@if(isWritable){
|
||||
<a class="btn" href="@path/@repository.owner/@repository.name/wiki/_new">New Page</a>
|
||||
<a class="btn" href="@path/@repository.owner/@repository.name/wiki/@pageName/_edit">Edit Page</a>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@(pages: List[String], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||
@(pages: List[String], repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
||||
@import view.helpers
|
||||
@import context._
|
||||
@html.main("Pages - " + repository.owner + "/" + repository.name){
|
||||
@@ -10,7 +10,9 @@
|
||||
</li>
|
||||
<li class="pull-right">
|
||||
<div class="btn-group">
|
||||
<a class="btn" href="@path/@repository.owner/@repository.name/wiki/_new">New Page</a>
|
||||
@if(isWritable){
|
||||
<a class="btn" href="@path/@repository.owner/@repository.name/wiki/_new">New Page</a>
|
||||
}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -152,4 +152,25 @@ dd {
|
||||
hr {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
ul.collaborator {
|
||||
list-style-type: none;
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
ul.collaborator li {
|
||||
background-color: #eee;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 3px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
ul.collaborator li:hover {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
ul.collaborator a.remove {
|
||||
color: #dd0000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
Reference in New Issue
Block a user