Permalink
Browse files

Add opensearch

  • Loading branch information...
1 parent 5f26bba commit 8d263b767f998387f8c64ebc2d85c332b68c7f50 @sanpii sanpii committed with May 16, 2012
Showing with 18 additions and 0 deletions.
  1. +9 −0 app.rb
  2. +1 −0 views/layout.erb
  3. +8 −0 views/opensearch.erb
View
@@ -89,6 +89,10 @@ def page_title title = nil
@page_title
end
end
+
+ def base_url
+ @base_url ||= "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}"
+ end
end
require_relative 'lib/auto_last_modified'
@@ -125,6 +129,11 @@ def page_title title = nil
erb :search
end
+get "/opensearch.xml" do
+ content_type 'application/xml'
+ erb :opensearch, :layout => false
+end
+
get "/url/*" do
rfc = RfcDocument.resolve_url(params[:splat].first) { not_found }
target = url(rfc.id)
View
@@ -8,6 +8,7 @@
<%#= javascript_includes %>
<link rel=stylesheet type="text/css" href=/style.css>
<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>
<body>
@@ -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.