Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
Add opensearch
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii authored and mislav committed Mar 17, 2013
1 parent 5f26bba commit 8d263b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app.rb
Expand Up @@ -89,6 +89,10 @@ def page_title title = nil
@page_title @page_title
end end
end end

def base_url
@base_url ||= "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}"
end
end end


require_relative 'lib/auto_last_modified' require_relative 'lib/auto_last_modified'
Expand Down Expand Up @@ -125,6 +129,11 @@ def page_title title = nil
erb :search erb :search
end end


get "/opensearch.xml" do
content_type 'application/xml'
erb :opensearch, :layout => false
end

get "/url/*" do get "/url/*" do
rfc = RfcDocument.resolve_url(params[:splat].first) { not_found } rfc = RfcDocument.resolve_url(params[:splat].first) { not_found }
target = url(rfc.id) target = url(rfc.id)
Expand Down
1 change: 1 addition & 0 deletions views/layout.erb
Expand Up @@ -8,6 +8,7 @@
<%#= javascript_includes %> <%#= javascript_includes %>
<link rel=stylesheet type="text/css" href=/style.css> <link rel=stylesheet type="text/css" href=/style.css>
<meta name=viewport content="width=device-width, initial-scale=1.0"> <meta name=viewport content="width=device-width, initial-scale=1.0">
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="RFC Search" />
</head> </head>


<body> <body>
Expand Down
8 changes: 8 additions & 0 deletions views/opensearch.erb
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName><%= page_title %></ShortName>
<Tags>RFC</Tags>
<InputEncoding>UTF-8</InputEncoding>
<SyndicationRight>open</SyndicationRight>
<Url type="text/html" template="<%= base_url %>/search?q={searchTerms}"/>
</OpenSearchDescription>

0 comments on commit 8d263b7

Please sign in to comment.