diff --git a/src/main/java/JettyLauncher.java b/src/main/java/JettyLauncher.java index 6c71c02..c1bebdb 100644 --- a/src/main/java/JettyLauncher.java +++ b/src/main/java/JettyLauncher.java @@ -65,9 +65,15 @@ boolean saveSessions = false; for(String arg: args) { - if(arg.equals("--save_sessions")) { + if (arg.equals("--save_sessions")) { saveSessions = true; } + if (arg.equals("--disable_news_feed")) { + System.setProperty("gitbucket.disableNewsFeed", "true"); + } + if (arg.equals("--disable_cache")) { + System.setProperty("gitbucket.disableCache", "true"); + } if(arg.startsWith("--") && arg.contains("=")) { String[] dim = arg.split("=", 2); if(dim.length == 2) { @@ -111,9 +117,6 @@ case "--jetty_idle_timeout": jettyIdleTimeout = dim[1]; break; - case "--disable_cache": - System.setProperty("gitbucket.disableCache", dim[1]); - break; } } } diff --git a/src/main/scala/gitbucket/core/controller/DashboardController.scala b/src/main/scala/gitbucket/core/controller/DashboardController.scala index 5fc1da1..9ef21f1 100644 --- a/src/main/scala/gitbucket/core/controller/DashboardController.scala +++ b/src/main/scala/gitbucket/core/controller/DashboardController.scala @@ -6,6 +6,7 @@ import gitbucket.core.util.{Keys, UsersAuthenticator} import gitbucket.core.util.Implicits._ import gitbucket.core.service.IssuesService._ +import gitbucket.core.service.ActivityService._ class DashboardController extends DashboardControllerBase @@ -42,7 +43,7 @@ withoutPhysicalInfo = true, limit = context.settings.basicBehavior.limitVisibleRepositories ) - html.repos(getGroupNames(loginAccount.userName), repos, repos) + html.repos(getGroupNames(loginAccount.userName), repos, repos, isNewsFeedEnabled()) } }) @@ -130,7 +131,8 @@ None, withoutPhysicalInfo = true, limit = context.settings.basicBehavior.limitVisibleRepositories - ) + ), + isNewsFeedEnabled() ) } @@ -172,7 +174,8 @@ None, withoutPhysicalInfo = true, limit = context.settings.basicBehavior.limitVisibleRepositories - ) + ), + isNewsFeedEnabled() ) } diff --git a/src/main/scala/gitbucket/core/controller/IndexController.scala b/src/main/scala/gitbucket/core/controller/IndexController.scala index c29d059..a3ccf4e 100644 --- a/src/main/scala/gitbucket/core/controller/IndexController.scala +++ b/src/main/scala/gitbucket/core/controller/IndexController.scala @@ -14,6 +14,8 @@ import org.scalatra.Ok import org.scalatra.forms._ +import gitbucket.core.service.ActivityService._ + class IndexController extends IndexControllerBase with RepositoryService @@ -65,24 +67,30 @@ context.loginAccount .map { account => val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName) - gitbucket.core.html.index( - getRecentActivitiesByOwners(visibleOwnerSet), - getVisibleRepositories( - Some(account), - None, - withoutPhysicalInfo = true, - limit = context.settings.basicBehavior.limitVisibleRepositories - ), - showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken( - account.userName + if (!isNewsFeedEnabled()) { + redirect("/dashboard/repos") + } else { + gitbucket.core.html.index( + activities = getRecentActivitiesByOwners(visibleOwnerSet), + recentRepositories = getVisibleRepositories( + Some(account), + None, + withoutPhysicalInfo = true, + limit = context.settings.basicBehavior.limitVisibleRepositories + ), + showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken( + account.userName + ), + enableNewsFeed = isNewsFeedEnabled() ) - ) + } } .getOrElse { gitbucket.core.html.index( - getRecentPublicActivities(), - getVisibleRepositories(None, withoutPhysicalInfo = true), - showBannerToCreatePersonalAccessToken = false + activities = getRecentPublicActivities(), + recentRepositories = getVisibleRepositories(None, withoutPhysicalInfo = true), + showBannerToCreatePersonalAccessToken = false, + enableNewsFeed = isNewsFeedEnabled() ) } } diff --git a/src/main/scala/gitbucket/core/service/ActivityService.scala b/src/main/scala/gitbucket/core/service/ActivityService.scala index 0508b9d..58243d4 100644 --- a/src/main/scala/gitbucket/core/service/ActivityService.scala +++ b/src/main/scala/gitbucket/core/service/ActivityService.scala @@ -9,10 +9,12 @@ import scala.util.Using import java.io.FileOutputStream import java.nio.charset.StandardCharsets - import gitbucket.core.controller.Context +import gitbucket.core.util.ConfigUtil import org.apache.commons.io.input.ReversedLinesFileReader +import ActivityService._ + import scala.collection.mutable.ListBuffer trait ActivityService { @@ -27,7 +29,7 @@ } def getActivitiesByUser(activityUserName: String, isPublic: Boolean)(implicit context: Context): List[Activity] = { - if (!ActivityLog.exists()) { + if (!isNewsFeedEnabled() || !ActivityLog.exists()) { List.empty } else { val list = new ListBuffer[Activity] @@ -51,7 +53,7 @@ } def getRecentPublicActivities()(implicit context: Context): List[Activity] = { - if (!ActivityLog.exists()) { + if (!isNewsFeedEnabled() || !ActivityLog.exists()) { List.empty } else { val list = new ListBuffer[Activity] @@ -69,7 +71,7 @@ } def getRecentActivitiesByOwners(owners: Set[String])(implicit context: Context): List[Activity] = { - if (!ActivityLog.exists()) { + if (!isNewsFeedEnabled() || !ActivityLog.exists()) { List.empty } else { val list = new ListBuffer[Activity] @@ -93,3 +95,8 @@ writeLog(info.toActivity) } } + +object ActivityService { + def isNewsFeedEnabled(): Boolean = + !ConfigUtil.getConfigValue[Boolean]("gitbucket.disableNewsFeed").getOrElse(false) +} diff --git a/src/main/scala/gitbucket/core/util/JGitUtil.scala b/src/main/scala/gitbucket/core/util/JGitUtil.scala index f5a9539..d4333f7 100644 --- a/src/main/scala/gitbucket/core/util/JGitUtil.scala +++ b/src/main/scala/gitbucket/core/util/JGitUtil.scala @@ -40,7 +40,7 @@ _.close() private def isCacheEnabled(): Boolean = - ConfigUtil.getConfigValue[Boolean]("gitbucket.disableCache").getOrElse(false) + !ConfigUtil.getConfigValue[Boolean]("gitbucket.disableCache").getOrElse(false) /** * The repository data. diff --git a/src/main/twirl/gitbucket/core/dashboard/issues.scala.html b/src/main/twirl/gitbucket/core/dashboard/issues.scala.html index 33d9a18..e134913 100644 --- a/src/main/twirl/gitbucket/core/dashboard/issues.scala.html +++ b/src/main/twirl/gitbucket/core/dashboard/issues.scala.html @@ -5,10 +5,11 @@ condition: gitbucket.core.service.IssuesService.IssueSearchCondition, filter: String, groups: List[String], - recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context) + recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo], + enableNewsFeed: Boolean)(implicit context: gitbucket.core.controller.Context) @gitbucket.core.html.main("Issues"){ @gitbucket.core.dashboard.html.sidebar(recentRepositories){ - @gitbucket.core.dashboard.html.tab("issues") + @gitbucket.core.dashboard.html.tab(enableNewsFeed, "issues")
@gitbucket.core.dashboard.html.issuesnavi("issues", filter, openCount, closedCount, condition) @gitbucket.core.dashboard.html.issueslist(issues, page, openCount, closedCount, condition, filter, groups) diff --git a/src/main/twirl/gitbucket/core/dashboard/pulls.scala.html b/src/main/twirl/gitbucket/core/dashboard/pulls.scala.html index 18c8a4d..b3a91a7 100644 --- a/src/main/twirl/gitbucket/core/dashboard/pulls.scala.html +++ b/src/main/twirl/gitbucket/core/dashboard/pulls.scala.html @@ -5,10 +5,11 @@ condition: gitbucket.core.service.IssuesService.IssueSearchCondition, filter: String, groups: List[String], - recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context) + recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo], + enableNewsFeed: Boolean)(implicit context: gitbucket.core.controller.Context) @gitbucket.core.html.main("Pull requests"){ @gitbucket.core.dashboard.html.sidebar(recentRepositories){ - @gitbucket.core.dashboard.html.tab("pulls") + @gitbucket.core.dashboard.html.tab(enableNewsFeed, "pulls")
@gitbucket.core.dashboard.html.issuesnavi("pulls", filter, openCount, closedCount, condition) @gitbucket.core.dashboard.html.issueslist(issues, page, openCount, closedCount, condition, filter, groups) diff --git a/src/main/twirl/gitbucket/core/dashboard/repos.scala.html b/src/main/twirl/gitbucket/core/dashboard/repos.scala.html index 3e268d9..b5c453f 100644 --- a/src/main/twirl/gitbucket/core/dashboard/repos.scala.html +++ b/src/main/twirl/gitbucket/core/dashboard/repos.scala.html @@ -1,10 +1,11 @@ @(groups: List[String], visibleRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo], - recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context) + recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo], + enableNewsFeed: Boolean)(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers @gitbucket.core.html.main("Repositories"){ @gitbucket.core.dashboard.html.sidebar(recentRepositories){ - @gitbucket.core.dashboard.html.tab("repos") + @gitbucket.core.dashboard.html.tab(enableNewsFeed, "repos")
} - @gitbucket.core.dashboard.html.tab() + @gitbucket.core.dashboard.html.tab(enableNewsFeed)
-
- activities -
- @gitbucket.core.helper.html.activities(activities) + @if(enableNewsFeed) { +
+ activities +
+ @gitbucket.core.helper.html.activities(activities) + } else { + + }
} }