Commit 4a28ec52 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '298975-search-autodiscovery' into 'master'

Add OpenSearch for GitLab

See merge request gitlab-org/gitlab!52583
parents b9686944 742d9d3d
......@@ -67,6 +67,9 @@ class SearchController < ApplicationController
end
# rubocop: enable CodeReuse/ActiveRecord
def opensearch
end
private
# overridden in EE
......
......@@ -79,6 +79,9 @@
= favicon_link_tag 'touch-icon-ipad-retina.png', rel: 'apple-touch-icon', sizes: '152x152'
%link{ rel: 'mask-icon', href: image_path('logo.svg'), color: 'rgb(226, 67, 41)' }
-# OpenSearch
%link{ href: search_opensearch_path(format: :xml), rel: 'search', title: 'Search GitLab', type: 'application/opensearchdescription+xml' }
-# Windows 8 pinned site tile
%meta{ name: 'msapplication-TileImage', content: image_path('msapplication-tile.png') }
%meta{ name: 'msapplication-TileColor', content: '#30353E' }
......
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>GitLab</ShortName>
<Description>Search GitLab</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon"><%= root_url %>favicon.ico</Image>
<Url type="text/html" method="get" template="<%= search_url %>?search={searchTerms}"/>
<moz:SearchForm><%= search_url %></moz:SearchForm>
</OpenSearchDescription>
\ No newline at end of file
---
title: Add OpenSearch support
merge_request: 52583
author:
type: added
......@@ -60,9 +60,10 @@ Rails.application.routes.draw do
end
# Search
get 'search' => 'search#show'
get 'search' => 'search#show', as: :search
get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
get 'search/count' => 'search#count', as: :search_count
get 'search/opensearch' => 'search#opensearch', as: :search_opensearch
# JSON Web Token
get 'jwt/auth' => 'jwt#auth'
......
......@@ -258,6 +258,20 @@ RSpec.describe SearchController do
it_behaves_like 'with external authorization service enabled', :autocomplete, { term: 'hello' }
end
describe 'GET #opensearch' do
render_views
it 'renders xml' do
get :opensearch, format: :xml
doc = Nokogiri::XML.parse(response.body)
expect(response).to have_gitlab_http_status(:ok)
expect(doc.css('OpenSearchDescription ShortName').text).to eq('GitLab')
expect(doc.css('OpenSearchDescription *').map(&:name)).to eq(%w[ShortName Description InputEncoding Image Url SearchForm])
end
end
describe '#append_info_to_payload' do
it 'appends search metadata for logging' do
last_payload = nil
......
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