diff --git a/src/main/scala/app/IndexController.scala b/src/main/scala/app/IndexController.scala
index b710ea5..7eff0cd 100644
--- a/src/main/scala/app/IndexController.scala
+++ b/src/main/scala/app/IndexController.scala
@@ -2,12 +2,16 @@
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))
}
diff --git a/src/main/scala/service/ActivityService.scala b/src/main/scala/service/ActivityService.scala
index 7fc64b5..0d0b494 100644
--- a/src/main/scala/service/ActivityService.scala
+++ b/src/main/scala/service/ActivityService.scala
@@ -21,6 +21,16 @@
.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,
diff --git a/src/main/twirl/account/activity.scala.html b/src/main/twirl/account/activity.scala.html
index 4c41c2e..39af829 100644
--- a/src/main/twirl/account/activity.scala.html
+++ b/src/main/twirl/account/activity.scala.html
@@ -15,39 +15,7 @@
@tab(account, "activity")
- @if(activities.isEmpty){
- No activity
- } else {
- @activities.map { activity =>
-
-
@datetime(activity.activityDate)
-
@activityMessage(activity.message)
- @activity.additionalInfo.map { additionalInfo =>
- @(activity.activityType match {
- case "create_wiki" => {
-
- }
- case "edit_wiki" => {
-
- }
- case "push" => {
-
- {additionalInfo.split("\n").map{ commit =>
-
- }}
-
- }
- case _ => {
-
{additionalInfo}
- }
- })
- }
-
- }
- }
+ @helper.html.activities(activities)
diff --git a/src/main/twirl/helper/activities.scala.html b/src/main/twirl/helper/activities.scala.html
new file mode 100644
index 0000000..7d46d2c
--- /dev/null
+++ b/src/main/twirl/helper/activities.scala.html
@@ -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 =>
+
+
@datetime(activity.activityDate)
+
@activityMessage(activity.message)
+ @activity.additionalInfo.map { additionalInfo =>
+ @(activity.activityType match {
+ case "create_wiki" => {
+
+ }
+ case "edit_wiki" => {
+
+ }
+ case "push" => {
+
+ {additionalInfo.split("\n").map{ commit =>
+
+ }}
+
+ }
+ case _ => {
+
{additionalInfo}
+ }
+ })
+ }
+
+ }
+}
diff --git a/src/main/twirl/index.scala.html b/src/main/twirl/index.scala.html
index 6683f00..e2feac5 100644
--- a/src/main/twirl/index.scala.html
+++ b/src/main/twirl/index.scala.html
@@ -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"){
-
Recent updated repositories
- @if(repositories.isEmpty){
- No repositories
- } else {
- @repositories.map { repository =>
-
-
- @if(repository.repository.description.isDefined){
-
@repository.repository.description
- }
-
Last updated: @datetime(repository.repository.lastActivityDate)
-
- }
- }
+
News Feed
+ @helper.html.activities(activities)
@if(loginAccount.isEmpty){
@@ -47,12 +30,33 @@
} else {
@userRepositories.map { repositoryName =>
- @repositoryName |
+ @repositoryName |
}
}
}
+
+
+
+
+ Recent updated repositories
+ |
+
+ @if(repositories.isEmpty){
+
+ No repositories |
+
+ } else {
+ @repositories.map { repository =>
+
+
+ @repository.owner/@repository.name
+ |
+
+ }
+ }
+