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 ""
|
||||
})
|
||||
|
||||
// TODO Move to RepositoryViwerController?
|
||||
post("/search", searchForm){ form =>
|
||||
redirect(s"/${form.owner}/${form.repository}/search?q=${StringUtil.urlEncode(form.query)}")
|
||||
}
|
||||
|
||||
// TODO Move to RepositoryViwerController?
|
||||
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 i = params.getOrElse("page", "1").toInt
|
||||
if(i <= 0) 1 else i
|
||||
@@ -161,8 +156,8 @@ trait IndexControllerBase extends ControllerBase {
|
||||
}
|
||||
})
|
||||
|
||||
get("/searchrepo"){
|
||||
val query = params("query").trim.toLowerCase
|
||||
get("/search"){
|
||||
val query = params.getOrElse("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
|
||||
|
||||
@@ -53,21 +53,11 @@
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
}
|
||||
@repository.map { repository =>
|
||||
<form id="search" action="@context.path/search" method="POST" 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 this repository"/>
|
||||
<input type="hidden" name="owner" value="@repository.owner"/>
|
||||
<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>
|
||||
}
|
||||
<form id="search" action="@context.path/search" 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">
|
||||
@if(context.loginAccount.isDefined){
|
||||
<li><a href="@context.path/dashboard/pulls">Pull requests</a></li>
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<div class="head">
|
||||
@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)/search"><i class="octicon octicon-search"></i></a>
|
||||
|
||||
@defining(repository.repository){ x =>
|
||||
@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)/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>
|
||||
<table class="table table-hover">
|
||||
@*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main("GitBucket"){
|
||||
@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="submit" value="Search" class="btn btn-default"/>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user