mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-10 23:45:50 +01:00
(refs #1370)Update search interface
This commit is contained in:
@@ -130,14 +130,9 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
} getOrElse ""
|
} getOrElse ""
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Move to RepositoryViwerController?
|
|
||||||
post("/search", searchForm){ form =>
|
|
||||||
redirect(s"/${form.owner}/${form.repository}/search?q=${StringUtil.urlEncode(form.query)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Move to RepositoryViwerController?
|
// TODO Move to RepositoryViwerController?
|
||||||
get("/:owner/:repository/search")(referrersOnly { repository =>
|
get("/:owner/:repository/search")(referrersOnly { repository =>
|
||||||
defining(params("q").trim, params.getOrElse("type", "code")){ case (query, target) =>
|
defining(params.getOrElse("q", "").trim, params.getOrElse("type", "code")){ case (query, target) =>
|
||||||
val page = try {
|
val page = try {
|
||||||
val i = params.getOrElse("page", "1").toInt
|
val i = params.getOrElse("page", "1").toInt
|
||||||
if(i <= 0) 1 else i
|
if(i <= 0) 1 else i
|
||||||
@@ -161,8 +156,8 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/searchrepo"){
|
get("/search"){
|
||||||
val query = params("query").trim.toLowerCase
|
val query = params.getOrElse("query", "").trim.toLowerCase
|
||||||
val visibleRepositories = getVisibleRepositories(context.loginAccount, None)
|
val visibleRepositories = getVisibleRepositories(context.loginAccount, None)
|
||||||
val repositories = visibleRepositories.filter { repository =>
|
val repositories = visibleRepositories.filter { repository =>
|
||||||
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
||||||
|
|||||||
@@ -53,21 +53,11 @@
|
|||||||
<span class="sr-only">Toggle navigation</span>
|
<span class="sr-only">Toggle navigation</span>
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
@repository.map { repository =>
|
<form id="search" action="@context.path/search" method="GET" class="pc navbar-form navbar-left" role="search">
|
||||||
<form id="search" action="@context.path/search" method="POST" class="pc navbar-form navbar-left" role="search">
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<input type="text" name="query" id="navbar-search-input" class="form-control" placeholder="Search repository"/>
|
||||||
<input type="text" name="query" id="navbar-search-input" class="form-control" placeholder="Search this repository"/>
|
</div>
|
||||||
<input type="hidden" name="owner" value="@repository.owner"/>
|
</form>
|
||||||
<input type="hidden" name="repository" value="@repository.name"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
}.getOrElse {
|
|
||||||
<form id="search" action="@context.path/searchrepo" method="GET" class="pc navbar-form navbar-left" role="search">
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="text" name="query" id="navbar-search-input" class="form-control" placeholder="Search repository"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
}
|
|
||||||
<ul class="pc nav navbar-nav">
|
<ul class="pc nav navbar-nav">
|
||||||
@if(context.loginAccount.isDefined){
|
@if(context.loginAccount.isDefined){
|
||||||
<li><a href="@context.path/dashboard/pulls">Pull requests</a></li>
|
<li><a href="@context.path/dashboard/pulls">Pull requests</a></li>
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
<div class="head">
|
<div class="head">
|
||||||
@gitbucket.core.helper.html.repositoryicon(repository, true)
|
@gitbucket.core.helper.html.repositoryicon(repository, true)
|
||||||
<a href="@helpers.url(repository.owner)">@repository.owner</a> / <a href="@helpers.url(repository)" class="strong">@repository.name</a>
|
<a href="@helpers.url(repository.owner)">@repository.owner</a> / <a href="@helpers.url(repository)" class="strong">@repository.name</a>
|
||||||
|
<a href="@helpers.url(repository)/search"><i class="octicon octicon-search"></i></a>
|
||||||
|
|
||||||
@defining(repository.repository){ x =>
|
@defining(repository.repository){ x =>
|
||||||
@if(repository.repository.originRepositoryName.isDefined){
|
@if(repository.repository.originRepositoryName.isDefined){
|
||||||
|
|||||||
@@ -86,7 +86,9 @@
|
|||||||
<a href="@helpers.url(repository)/tree/@helpers.encodeRefName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
<a href="@helpers.url(repository)/tree/@helpers.encodeRefName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<a href="@helpers.url(repository)/new/@helpers.encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-sm btn-default pc" title="Create a new file here" @if(!hasWritePermission){disabled}><i class="octicon octicon-plus"></i></a>
|
@if(hasWritePermission){
|
||||||
|
<a href="@helpers.url(repository)/new/@helpers.encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-sm btn-default pc" title="Create a new file here"><i class="octicon octicon-plus"></i></a>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
@*
|
@*
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
@import gitbucket.core.view.helpers
|
@import gitbucket.core.view.helpers
|
||||||
@gitbucket.core.html.main("GitBucket"){
|
@gitbucket.core.html.main("GitBucket"){
|
||||||
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
||||||
<form action="@context.path/searchrepo" method="GET" class="form-inline">
|
<form action="@context.path/search" method="GET" class="form-inline">
|
||||||
<input type="text" name="query" value="@query" class="form-control" style="width: 250px; margin-bottom: 0px;"/>
|
<input type="text" name="query" value="@query" class="form-control" style="width: 250px; margin-bottom: 0px;"/>
|
||||||
<input type="submit" value="Search" class="btn btn-default"/>
|
<input type="submit" value="Search" class="btn btn-default"/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user