From 56a9b7b0f1c9d59deff8edcec49f21843a1527fa Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Sun, 18 Dec 2016 00:41:18 +0900 Subject: [PATCH] (refs #1370)Search repository by name --- .../core/controller/DashboardController.scala | 4 +- .../core/controller/IndexController.scala | 14 ++++++ .../core/dashboard/sidebar.scala.html | 48 +++++++++---------- src/main/twirl/gitbucket/core/main.scala.html | 6 +++ .../gitbucket/core/search/issues.scala.html | 2 +- .../core/search/repositories.scala.html | 40 ++++++++++++++++ .../gitbucket/core/search/wiki.scala.html | 2 +- 7 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 src/main/twirl/gitbucket/core/search/repositories.scala.html diff --git a/src/main/scala/gitbucket/core/controller/DashboardController.scala b/src/main/scala/gitbucket/core/controller/DashboardController.scala index 9aec00f16..81e3085d7 100644 --- a/src/main/scala/gitbucket/core/controller/DashboardController.scala +++ b/src/main/scala/gitbucket/core/controller/DashboardController.scala @@ -76,7 +76,7 @@ trait DashboardControllerBase extends ControllerBase { }, filter, getGroupNames(userName), - getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true), + Nil, getUserRepositories(userName, withoutPhysicalInfo = true)) } @@ -101,7 +101,7 @@ trait DashboardControllerBase extends ControllerBase { }, filter, getGroupNames(userName), - getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true), + Nil, getUserRepositories(userName, withoutPhysicalInfo = true)) } diff --git a/src/main/scala/gitbucket/core/controller/IndexController.scala b/src/main/scala/gitbucket/core/controller/IndexController.scala index 2ef049086..9f4a950b0 100644 --- a/src/main/scala/gitbucket/core/controller/IndexController.scala +++ b/src/main/scala/gitbucket/core/controller/IndexController.scala @@ -160,4 +160,18 @@ trait IndexControllerBase extends ControllerBase { } } }) + + get("/searchrepo"){ + val query = params("query").trim.toLowerCase + val visibleRepositories = getVisibleRepositories(context.loginAccount, None) + val repositories = visibleRepositories.filter { repository => + repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0 + } + context.loginAccount.map { account => + gitbucket.core.search.html.repositories(query, repositories, Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true)) + }.getOrElse { + gitbucket.core.search.html.repositories(query, repositories, visibleRepositories, Nil) + } + } + } diff --git a/src/main/twirl/gitbucket/core/dashboard/sidebar.scala.html b/src/main/twirl/gitbucket/core/dashboard/sidebar.scala.html index f6db4a0b0..faf5d5a6c 100644 --- a/src/main/twirl/gitbucket/core/dashboard/sidebar.scala.html +++ b/src/main/twirl/gitbucket/core/dashboard/sidebar.scala.html @@ -12,21 +12,15 @@ @if(userRepositories.isEmpty){
  • No repositories
  • } else { - @defining(10){ max => - @userRepositories.zipWithIndex.map { case (repository, i) => -
  • + @userRepositories.zipWithIndex.map { case (repository, i) => + - } - @if(userRepositories.size > max){ -
  • - Show @{userRepositories.size - max} more repositories... -
  • - } + } } } else { @@ -34,17 +28,11 @@ @if(recentRepositories.isEmpty){
  • No repositories
  • } else { - @defining(10){ max => - @recentRepositories.zipWithIndex.map { case (repository, i) => - - } - @if(recentRepositories.size > max){ -
  • - Show @{recentRepositories.size - max} more repositories... -
  • - } +
  • + @recentRepositories.zipWithIndex.map { case (repository, i) => + } } } @@ -58,9 +46,21 @@ diff --git a/src/main/twirl/gitbucket/core/main.scala.html b/src/main/twirl/gitbucket/core/main.scala.html index 5f78e73d9..1dd3150dc 100644 --- a/src/main/twirl/gitbucket/core/main.scala.html +++ b/src/main/twirl/gitbucket/core/main.scala.html @@ -61,6 +61,12 @@ + }.getOrElse { + }