Added search wiki feature
This commit is contained in:
parent
3a971ca9ef
commit
d93b046c4c
4 changed files with 31 additions and 2 deletions
|
@ -9,7 +9,7 @@ class SearchController < ApplicationController
|
||||||
@search_results = if @project
|
@search_results = if @project
|
||||||
return access_denied! unless can?(current_user, :download_code, @project)
|
return access_denied! unless can?(current_user, :download_code, @project)
|
||||||
|
|
||||||
unless %w(blobs notes issues merge_requests).include?(@scope)
|
unless %w(blobs notes issues merge_requests wiki_blobs).include?(@scope)
|
||||||
@scope = 'blobs'
|
@scope = 'blobs'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,3 +23,9 @@
|
||||||
Comments
|
Comments
|
||||||
.pull-right
|
.pull-right
|
||||||
= @search_results.notes_count
|
= @search_results.notes_count
|
||||||
|
%li{class: ("active" if @scope == 'wiki_blobs')}
|
||||||
|
= link_to search_filter_path(scope: 'wiki_blobs') do
|
||||||
|
Wiki
|
||||||
|
.pull-right
|
||||||
|
= @search_results.wiki_blobs_count
|
||||||
|
|
||||||
|
|
9
app/views/search/results/_wiki_blob.html.haml
Normal file
9
app/views/search/results/_wiki_blob.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.blob-result
|
||||||
|
.file-holder
|
||||||
|
.file-title
|
||||||
|
= link_to project_wiki_path(@project, wiki_blob.filename) do
|
||||||
|
%i.icon-file
|
||||||
|
%strong
|
||||||
|
= wiki_blob.filename
|
||||||
|
.file-content.code.term
|
||||||
|
= render 'shared/file_hljs', blob: wiki_blob, first_line_number: wiki_blob.startline
|
|
@ -14,13 +14,15 @@ module Gitlab
|
||||||
notes.page(page).per(per_page)
|
notes.page(page).per(per_page)
|
||||||
when 'blobs'
|
when 'blobs'
|
||||||
Kaminari.paginate_array(blobs).page(page).per(per_page)
|
Kaminari.paginate_array(blobs).page(page).per(per_page)
|
||||||
|
when 'wiki_blobs'
|
||||||
|
Kaminari.paginate_array(wiki_blobs).page(page).per(per_page)
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_count
|
def total_count
|
||||||
@total_count ||= issues_count + merge_requests_count + blobs_count + notes_count
|
@total_count ||= issues_count + merge_requests_count + blobs_count + notes_count + wiki_blobs_count
|
||||||
end
|
end
|
||||||
|
|
||||||
def blobs_count
|
def blobs_count
|
||||||
|
@ -31,6 +33,10 @@ module Gitlab
|
||||||
@notes_count ||= notes.count
|
@notes_count ||= notes.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wiki_blobs_count
|
||||||
|
@wiki_blobs_count ||= wiki_blobs.count
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def blobs
|
def blobs
|
||||||
|
@ -41,6 +47,14 @@ module Gitlab
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wiki_blobs
|
||||||
|
if !project.wiki_enabled?
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
Repository.new(ProjectWiki.new(project).path_with_namespace).search_files(query)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def notes
|
def notes
|
||||||
Note.where(project_id: limit_project_ids).search(query).order('updated_at DESC')
|
Note.where(project_id: limit_project_ids).search(query).order('updated_at DESC')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue