mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 03:26:06 +01:00
(refs #4)Add 'News Feed' to the index page.
This commit is contained in:
@@ -2,12 +2,16 @@ package app
|
||||
|
||||
import service._
|
||||
|
||||
class IndexController extends IndexControllerBase with RepositoryService with AccountService with SystemSettingsService
|
||||
class IndexController extends IndexControllerBase
|
||||
with RepositoryService with AccountService with SystemSettingsService with ActivityService
|
||||
|
||||
trait IndexControllerBase extends ControllerBase { self: RepositoryService with SystemSettingsService =>
|
||||
trait IndexControllerBase extends ControllerBase { self: RepositoryService
|
||||
with SystemSettingsService with ActivityService =>
|
||||
|
||||
get("/"){
|
||||
html.index(getAccessibleRepositories(context.loginAccount, baseUrl), loadSystemSettings(),
|
||||
html.index(getRecentActivities(),
|
||||
getAccessibleRepositories(context.loginAccount, baseUrl),
|
||||
loadSystemSettings(),
|
||||
context.loginAccount.map{ account => getRepositoryNamesOfUser(account.userName) }.getOrElse(Nil))
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,16 @@ trait ActivityService {
|
||||
.take(30)
|
||||
.list
|
||||
}
|
||||
|
||||
def getRecentActivities(): List[Activity] =
|
||||
Query(Activities)
|
||||
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
||||
.filter { case (t1, t2) => t2.isPrivate is false.bind }
|
||||
.sortBy { case (t1, t2) => t1.activityId desc }
|
||||
.map { case (t1, t2) => t1 }
|
||||
.take(30)
|
||||
.list
|
||||
|
||||
|
||||
def recordCreateRepositoryActivity(userName: String, repositoryName: String, activityUserName: String): Unit =
|
||||
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||
|
||||
@@ -15,39 +15,7 @@
|
||||
</div>
|
||||
<div class="span8">
|
||||
@tab(account, "activity")
|
||||
@if(activities.isEmpty){
|
||||
No activity
|
||||
} else {
|
||||
@activities.map { activity =>
|
||||
<div class="block">
|
||||
<div class="muted small">@datetime(activity.activityDate)</div>
|
||||
<div class="strong">@activityMessage(activity.message)</div>
|
||||
@activity.additionalInfo.map { additionalInfo =>
|
||||
@(activity.activityType match {
|
||||
case "create_wiki" => {
|
||||
<div class="small">Created <a href={"%s/%s/%s/wiki/%s".format(path, activity.userName, activity.repositoryName, additionalInfo)}>{additionalInfo}</a>.</div>
|
||||
}
|
||||
case "edit_wiki" => {
|
||||
<div class="small">Edited <a href={"%s/%s/%s/wiki/%s".format(path, activity.userName, activity.repositoryName, additionalInfo)}>{additionalInfo}</a>.</div>
|
||||
}
|
||||
case "push" => {
|
||||
<div class="small">
|
||||
{additionalInfo.split("\n").map{ commit =>
|
||||
<div>
|
||||
<a href={"%s/%s/%s/commit/%s".format(path, activity.userName, activity.repositoryName, commit.substring(0, 40))} class="monospace">{commit.substring(0, 7)}</a>
|
||||
<span>{commit.substring(41)}</span>
|
||||
</div>
|
||||
}}
|
||||
</div>
|
||||
}
|
||||
case _ => {
|
||||
<div>{additionalInfo}</div>
|
||||
}
|
||||
})
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@helper.html.activities(activities)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
36
src/main/twirl/helper/activities.scala.html
Normal file
36
src/main/twirl/helper/activities.scala.html
Normal file
@@ -0,0 +1,36 @@
|
||||
@(activities: List[model.Activity])(implicit context: app.Context)
|
||||
@import context._
|
||||
@import view.helpers._
|
||||
@if(activities.isEmpty){
|
||||
No activity
|
||||
} else {
|
||||
@activities.map { activity =>
|
||||
<div class="block">
|
||||
<div class="muted small">@datetime(activity.activityDate)</div>
|
||||
<div class="strong">@activityMessage(activity.message)</div>
|
||||
@activity.additionalInfo.map { additionalInfo =>
|
||||
@(activity.activityType match {
|
||||
case "create_wiki" => {
|
||||
<div class="small">Created <a href={"%s/%s/%s/wiki/%s".format(path, activity.userName, activity.repositoryName, additionalInfo)}>{additionalInfo}</a>.</div>
|
||||
}
|
||||
case "edit_wiki" => {
|
||||
<div class="small">Edited <a href={"%s/%s/%s/wiki/%s".format(path, activity.userName, activity.repositoryName, additionalInfo)}>{additionalInfo}</a>.</div>
|
||||
}
|
||||
case "push" => {
|
||||
<div class="small">
|
||||
{additionalInfo.split("\n").map{ commit =>
|
||||
<div>
|
||||
<a href={"%s/%s/%s/commit/%s".format(path, activity.userName, activity.repositoryName, commit.substring(0, 40))} class="monospace">{commit.substring(0, 7)}</a>
|
||||
<span>{commit.substring(41)}</span>
|
||||
</div>
|
||||
}}
|
||||
</div>
|
||||
}
|
||||
case _ => {
|
||||
<div>{additionalInfo}</div>
|
||||
}
|
||||
})
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,14 @@
|
||||
@(repositories: List[service.RepositoryService.RepositoryInfo], systemSettings: service.SystemSettingsService.SystemSettings,
|
||||
@(activities: List[model.Activity],
|
||||
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>
|
||||
@if(repositories.isEmpty){
|
||||
No repositories
|
||||
} else {
|
||||
@repositories.map { repository =>
|
||||
<div class="block">
|
||||
<div class="block-header">
|
||||
<a href="@url(repository.owner)">@repository.owner</a>
|
||||
/
|
||||
<a href="@url(repository)">@repository.name</a>
|
||||
@if(repository.repository.isPrivate){
|
||||
<i class="icon-lock"></i>
|
||||
}
|
||||
</div>
|
||||
@if(repository.repository.description.isDefined){
|
||||
<div>@repository.repository.description</div>
|
||||
}
|
||||
<div><span class="muted small">Last updated: @datetime(repository.repository.lastActivityDate)</span></div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<h3>News Feed</h3>
|
||||
@helper.html.activities(activities)
|
||||
</div>
|
||||
<div class="span4">
|
||||
@if(loginAccount.isEmpty){
|
||||
@@ -47,12 +30,33 @@
|
||||
} else {
|
||||
@userRepositories.map { repositoryName =>
|
||||
<tr>
|
||||
<td><a href="@path/@loginAccount.get.userName/@repositoryName">@repositoryName</a></td>
|
||||
<td><a href="@path/@loginAccount.get.userName/@repositoryName"><strong>@repositoryName</strong></a></td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
}
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th class="metal">
|
||||
Recent updated repositories
|
||||
</th>
|
||||
</tr>
|
||||
@if(repositories.isEmpty){
|
||||
<tr>
|
||||
<td>No repositories</td>
|
||||
</tr>
|
||||
} else {
|
||||
@repositories.map { repository =>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="@url(repository)">@repository.owner/<strong>@repository.name</strong></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user