Skip to content
Snippets Groups Projects
Commit 4fa082d4 authored by Ralf Seidler's avatar Ralf Seidler
Browse files

Added wiki-page search for 5-2-stable, Fixed issue #4310

parent 6a868a4c
No related branches found
No related tags found
1 merge request!4341Added wiki-page search for 5-2-stable, Fixed issue #4310
This commit is part of merge request !4341. Comments created here will be created in the context of that merge request.
Loading
@@ -21,7 +21,15 @@ class SearchContext
Loading
@@ -21,7 +21,15 @@ class SearchContext
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)
result[:wiki_pages] = [] projects.each do |p|
wiki = GollumWiki.new(p)
# Rails.logger.info wiki
t=wiki.search_i(query)
# Rails.logger.info t[0][:wiki].path
result[:wiki_pages] += t
end
#result[:wiki_pages] = [] #GollumWiki.where(project_id: project_ids).wiki.search(query)
end end
result result
end end
Loading
Loading
class GollumWiki class GollumWiki
   
MARKUPS = { MARKUPS = {
"Markdown" => :markdown, "Markdown" => :markdown,
Loading
@@ -11,6 +11,9 @@ class GollumWiki
Loading
@@ -11,6 +11,9 @@ class GollumWiki
# an operation fails. # an operation fails.
attr_reader :error_message attr_reader :error_message
   
attr_reader :search_i
attr_reader :project
def initialize(project, user = nil) def initialize(project, user = nil)
@project = project @project = project
@user = user @user = user
Loading
@@ -32,6 +35,10 @@ class GollumWiki
Loading
@@ -32,6 +35,10 @@ class GollumWiki
url_to_repo url_to_repo
end end
   
def project_id
@project.project_id
end
def http_url_to_repo def http_url_to_repo
http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('') http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('')
end end
Loading
@@ -44,6 +51,15 @@ class GollumWiki
Loading
@@ -44,6 +51,15 @@ class GollumWiki
create_repo! create_repo!
end end
end end
def search_i(query)
i=[]
wiki.search(query).each do |q|
i.push(find_page(q[:name]))
Rails.logger.info "Accessing:" + find_page(q[:name])[:wiki].path
end
@search_i=i
end
   
# Returns an Array of Gitlab WikiPage instances or an # Returns an Array of Gitlab WikiPage instances or an
# empty Array if this Wiki has no pages. # empty Array if this Wiki has no pages.
Loading
@@ -109,6 +125,10 @@ class GollumWiki
Loading
@@ -109,6 +125,10 @@ class GollumWiki
"#{@user.username} #{action} page: #{title}" "#{@user.username} #{action} page: #{title}"
end end
   
def search_wiki(query)
wiki.search(query)
end
def gitlab_shell def gitlab_shell
@gitlab_shell ||= Gitlab::Shell.new @gitlab_shell ||= Gitlab::Shell.new
end end
Loading
Loading
Loading
@@ -38,10 +38,10 @@
Loading
@@ -38,10 +38,10 @@
- @wiki_pages.each do |wiki_page| - @wiki_pages.each do |wiki_page|
%li %li
wiki: wiki:
= link_to project_wiki_path(wiki_page.project, wiki_page) do = link_to project_wiki_path(wiki_page.wiki.project.path_with_namespace, wiki_page) do
%strong.term %strong.term
= truncate wiki_page.title, length: 50 = truncate wiki_page.title, length: 50
%span.light (#{wiki_page.project.name_with_namespace}) %span.light (#{wiki_page.wiki.path_with_namespace})
   
- @blobs.each do |blob| - @blobs.each do |blob|
= render 'blob', blob: blob = render 'blob', blob: blob
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment