This repository has been archived by the owner on Jul 15, 2021. It is now read-only.
forked from orientation/orientation
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module OpenSearch | ||
class DescriptionsController < ApplicationController | ||
respond_to :osd_xml | ||
# Serves the OpenSearch Description document so that you can use the omnibox | ||
# and similar to search on Orientation. | ||
def show | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module OpenSearch | ||
module DescriptionsHelper | ||
def open_search_description_link_tag | ||
content_tag( | ||
:link, | ||
nil, | ||
rel: 'search', | ||
type: 'application/opensearchdescription+xml', | ||
title: ENV.fetch('APP_NAME', 'Orientation'), | ||
href: open_search_description_path | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
xml.instruct! | ||
xml.OpenSearchDescription xmlns: 'http://a9.com/-/spec/opensearch/1.1/', 'xmlns:moz': 'http://www.mozilla.org/2006/browser/search/', 'xmlns:suggestions': 'http://www.opensearch.org/specifications/opensearch/extensions/suggestions/1.1' do | ||
xml.AdultContent false | ||
xml.Description "Search on #{ENV.fetch('APP_NAME', 'Orientation')}" | ||
if ENV['ORIENTATION_FAVICON'].present? | ||
xml.Image ENV['ORIENTATION_FAVICON'], width: 16, height: 16, type: 'image/x-icon' | ||
end | ||
if ENV['ORIENTATION_LOGO'].present? | ||
xml.Image ENV['ORIENTATION_LOGO'], width: 64, height: 64, type: 'image/png' | ||
end | ||
xml.InputEncoding 'UTF-8' | ||
xml.Language 'en-US' | ||
xml.Language '*' | ||
xml.LongName "#{ENV.fetch('APP_NAME', 'Orientation')} Search" | ||
xml.OutputEncoding 'UTF-8' | ||
xml.Query role: 'example', searchTerms: 'john smith' | ||
xml.ShortName ENV.fetch('APP_NAME', 'Orientation') | ||
xml.SyndicationRight 'limited' | ||
xml.tag! 'moz:SearchForm', articles_url | ||
# rels: results (default), suggestions, self, collection | ||
# parameters: searchTerms (required), count, startIndex, startPage, language, inputEncoding, outputEncoding | ||
xml.Url type: 'application/opensearchdescription+xml', rel: 'self', template: open_search_description_url | ||
xml.Url type: 'text/html', template: "#{articles_url}?search={searchTerms}&utm_source=opensearch&utm_medium=search&utm_campaign=opensearch" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
spec/controllers/open_search/descriptions_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe OpenSearch::DescriptionsController, type: :controller do | ||
describe 'GET #show' do | ||
it 'returns http success' do | ||
get :show, format: :osd_xml | ||
expect(response).to have_http_status(:success) | ||
end | ||
end | ||
end |