Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9487c370
Commit
9487c370
authored
Jan 21, 2015
by
Hannes Rosenögger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only trigger actual search if a search string is present
parent
6c1074e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+23
-23
No files found.
app/controllers/search_controller.rb
View file @
9487c370
...
@@ -2,34 +2,34 @@ class SearchController < ApplicationController
...
@@ -2,34 +2,34 @@ class SearchController < ApplicationController
include
SearchHelper
include
SearchHelper
def
show
def
show
return
if
params
[
:search
].
nil?
||
params
[
:search
].
blank?
@project
=
Project
.
find_by
(
id:
params
[
:project_id
])
if
params
[
:project_id
].
present?
@project
=
Project
.
find_by
(
id:
params
[
:project_id
])
if
params
[
:project_id
].
present?
@group
=
Group
.
find_by
(
id:
params
[
:group_id
])
if
params
[
:group_id
].
present?
@group
=
Group
.
find_by
(
id:
params
[
:group_id
])
if
params
[
:group_id
].
present?
@scope
=
params
[
:scope
]
@scope
=
params
[
:scope
]
@show_snippets
=
params
[
:snippets
].
eql?
'true'
@show_snippets
=
params
[
:snippets
].
eql?
'true'
@search_results
=
if
@project
@search_results
=
return
access_denied!
unless
can?
(
current_user
,
:download_code
,
@project
)
if
@project
return
access_denied!
unless
can?
(
current_user
,
:download_code
,
@project
)
unless
%w(blobs notes issues merge_requests wiki_blobs)
.
include?
(
@scope
)
unless
%w(blobs notes issues merge_requests wiki_blobs)
.
@scope
=
'blobs'
include?
(
@scope
)
end
@scope
=
'blobs'
end
Search
::
ProjectService
.
new
(
@project
,
current_user
,
params
).
execute
elsif
@show_snippets
Search
::
ProjectService
.
new
(
@project
,
current_user
,
params
).
execute
unless
%w(snippet_blobs snippet_titles)
.
include?
(
@scope
)
elsif
@show_snippets
@scope
=
'snippet_blobs'
unless
%w(snippet_blobs snippet_titles)
.
include?
(
@scope
)
end
@scope
=
'snippet_blobs'
end
Search
::
SnippetService
.
new
(
current_user
,
params
).
execute
else
Search
::
SnippetService
.
new
(
current_user
,
params
).
execute
unless
%w(projects issues merge_requests)
.
include?
(
@scope
)
else
@scope
=
'projects'
unless
%w(projects issues merge_requests)
.
include?
(
@scope
)
end
@scope
=
'projects'
end
Search
::
GlobalService
.
new
(
current_user
,
params
).
execute
Search
::
GlobalService
.
new
(
current_user
,
params
).
execute
end
end
@objects
=
@search_results
.
objects
(
@scope
,
params
[
:page
])
@objects
=
@search_results
.
objects
(
@scope
,
params
[
:page
])
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment