Commit 221b14b1 authored by Dylan Griffith's avatar Dylan Griffith

Render wiki like issues in search results

Previously we used to render these exactly the same as code results and
only show a few lines of code. Since the wiki is more like human
readable text then it makes more sense to just render it as text in
paragraph form than lines of code. This also allows highlighting to pick
up single words being matched.

Basically this is done by using the same styling we do on issue search
results. It does come with the downside that we truncate the text so
highlighting matching words later in the wiki won't be visible in the
snippet anymore.
parent cf36f02d
- project = wiki_blob.project
- wiki_blob_link = project_wiki_path(project, wiki_blob.basename)
= render partial: 'search/results/blob_data', locals: { blob: wiki_blob, project: project, path: wiki_blob.path, blob_link: wiki_blob_link }
%div{ class: 'search-result-row gl-pb-3! gl-mt-5 gl-mb-0!' }
%span.gl-display-flex.gl-align-items-center
= link_to wiki_blob_link, data: { track_event: 'click_text', track_label: "wiki_title", track_property: 'search_result' }, class: 'gl-w-full' do
%span.term.str-truncated.gl-font-weight-bold= ::Gitlab::Git::Wiki::GollumSlug.canonicalize_filename(wiki_blob.path)
.description.term.col-sm-10.gl-px-0
= simple_search_highlight_and_truncate(wiki_blob.data, @search_term)
---
title: Improve the look of wikis in search results
merge_request: 47470
author:
type: changed
......@@ -164,15 +164,14 @@ RSpec.describe 'Global elastic search', :elastic, :sidekiq_inline do
ensure_elasticsearch_index!
end
it "finds files" do
it "finds wiki pages" do
visit dashboard_projects_path
submit_search('term')
select_search_scope('Wiki')
expect(page).to have_selector('.file-content .code')
expect(page).to have_selector("span.line[lang='markdown']")
expect(page).to have_selector('.search-result-row .description', text: '# term')
expect(page).to have_link('test')
end
end
......
......@@ -71,12 +71,12 @@ RSpec.describe 'Group elastic search', :js, :elastic, :sidekiq_might_not_need_in
ensure_elasticsearch_index!
end
it 'finds pages' do
it 'finds wiki pages' do
submit_search('term')
select_search_scope('Wiki')
expect(page).to have_selector('.file-content .code')
expect(page).to have_selector('span.line[lang="markdown"]')
expect(page).to have_selector('.search-result-row .description', text: '# term')
expect(page).to have_link('test')
end
end
......
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