Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
742d9d3d
Commit
742d9d3d
authored
Jan 28, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add OpenSearch support for GitLab
parent
932156cd
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
1 deletion
+36
-1
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+3
-0
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+3
-0
app/views/search/opensearch.xml.erb
app/views/search/opensearch.xml.erb
+9
-0
changelogs/unreleased/298975-search-autodiscovery.yml
changelogs/unreleased/298975-search-autodiscovery.yml
+5
-0
config/routes.rb
config/routes.rb
+2
-1
spec/controllers/search_controller_spec.rb
spec/controllers/search_controller_spec.rb
+14
-0
No files found.
app/controllers/search_controller.rb
View file @
742d9d3d
...
...
@@ -67,6 +67,9 @@ class SearchController < ApplicationController
end
# rubocop: enable CodeReuse/ActiveRecord
def
opensearch
end
private
# overridden in EE
...
...
app/views/layouts/_head.html.haml
View file @
742d9d3d
...
...
@@ -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'
}
...
...
app/views/search/opensearch.xml.erb
0 → 100644
View file @
742d9d3d
<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
changelogs/unreleased/298975-search-autodiscovery.yml
0 → 100644
View file @
742d9d3d
---
title
:
Add OpenSearch support
merge_request
:
52583
author
:
type
:
added
config/routes.rb
View file @
742d9d3d
...
...
@@ -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'
...
...
spec/controllers/search_controller_spec.rb
View file @
742d9d3d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment