Commit 9d9b7882 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix paginate of blobs, fixed preserve in dev mode for blob results

parent 46daf01a
...@@ -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)
......
...@@ -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
...@@ -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 } )
%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|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment