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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
9d9b7882
Commit
9d9b7882
authored
May 14, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix paginate of blobs, fixed preserve in dev mode for blob results
parent
46daf01a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
12 deletions
+6
-12
app/contexts/search_context.rb
app/contexts/search_context.rb
+1
-8
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+2
-1
app/views/search/_blob.html.haml
app/views/search/_blob.html.haml
+2
-1
app/views/search/_result.html.haml
app/views/search/_result.html.haml
+1
-2
No files found.
app/contexts/search_context.rb
View file @
9d9b7882
...
@@ -17,14 +17,7 @@ class SearchContext
...
@@ -17,14 +17,7 @@ class SearchContext
project
=
projects
.
first
if
projects
.
length
==
1
project
=
projects
.
first
if
projects
.
length
==
1
if
params
[
:search_code
].
present?
if
params
[
:search_code
].
present?
blobs
=
[]
result
[
:blobs
]
=
project
.
repository
.
search_files
(
query
,
params
[
:repository_ref
])
unless
project
.
empty_repo?
unless
project
.
empty_repo?
blobs
=
project
.
repository
.
search_files
(
query
,
params
[
:repository_ref
])
blobs
=
Kaminari
.
paginate_array
(
blobs
).
page
(
params
[
:page
]).
per
(
20
)
end
result
[
:blobs
]
=
blobs
else
else
result
[
:merge_requests
]
=
MergeRequest
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
result
[
:merge_requests
]
=
MergeRequest
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
result
[
:issues
]
=
Issue
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
result
[
:issues
]
=
Issue
.
where
(
project_id:
project_ids
).
search
(
query
).
limit
(
10
)
...
...
app/controllers/search_controller.rb
View file @
9d9b7882
...
@@ -20,6 +20,7 @@ class SearchController < ApplicationController
...
@@ -20,6 +20,7 @@ class SearchController < ApplicationController
@merge_requests
=
result
[
:merge_requests
]
@merge_requests
=
result
[
:merge_requests
]
@issues
=
result
[
:issues
]
@issues
=
result
[
:issues
]
@wiki_pages
=
result
[
:wiki_pages
]
@wiki_pages
=
result
[
:wiki_pages
]
@blobs
=
result
[
:blobs
]
@blobs
=
Kaminari
.
paginate_array
(
result
[
:blobs
]).
page
(
params
[
:page
]).
per
(
20
)
@total_results
=
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
+
@blobs
.
total_count
end
end
end
end
app/views/search/_blob.html.haml
View file @
9d9b7882
...
@@ -7,4 +7,5 @@
...
@@ -7,4 +7,5 @@
=
blob
.
filename
=
blob
.
filename
.file_content.code.term
.file_content.code.term
%div
{
class:
user_color_scheme_class
}
%div
{
class:
user_color_scheme_class
}
=
preserve
do
=
raw
blob
.
colorize
(
formatter: :gitlab
,
options:
{
first_line_number:
blob
.
startline
}
)
=
raw
blob
.
colorize
(
formatter: :gitlab
,
options:
{
first_line_number:
blob
.
startline
}
)
app/views/search/_result.html.haml
View file @
9d9b7882
%fieldset
%fieldset
%legend
%legend
Search results
Search results
%span
.cgray
(
#{
@
projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
+
@blobs
.
total_count
}
)
%span
.cgray
(
#{
@
total_results
}
)
-
if
@project
-
if
@project
%ul
.nav.nav-pills
%ul
.nav.nav-pills
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
=
link_to
search_path
(
params
.
merge
(
search_code:
nil
))
do
=
link_to
search_path
(
params
.
merge
(
search_code:
nil
))
do
Everything else
Everything else
.search_results
.search_results
%ul
.bordered-list
%ul
.bordered-list
-
@projects
.
each
do
|
project
|
-
@projects
.
each
do
|
project
|
...
...
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