File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ mod file;
44
44
mod builds;
45
45
mod error;
46
46
mod sitemap;
47
+ mod opensearch;
47
48
48
49
use std:: env;
49
50
use std:: error:: Error ;
@@ -99,6 +100,7 @@ impl CratesfyiHandler {
99
100
} ) ;
100
101
router. get ( "/robots.txt" , sitemap:: robots_txt_handler) ;
101
102
router. get ( "/sitemap.xml" , sitemap:: sitemap_handler) ;
103
+ router. get ( "/opensearch.xml" , opensearch:: serve_opensearch) ;
102
104
router. get ( "/releases" , releases:: releases_handler) ;
103
105
router. get ( "/releases/feed" , releases:: releases_feed_handler) ;
104
106
router. get ( "/releases/recent/:page" , releases:: releases_handler) ;
Original file line number Diff line number Diff line change
1
+ use iron:: headers:: ContentType ;
2
+ use iron:: prelude:: * ;
3
+ use iron:: status;
4
+
5
+ const OPENSEARCH_XML : & ' static [ u8 ] = include_bytes ! ( "opensearch.xml" ) ;
6
+
7
+ pub fn serve_opensearch ( _: & mut Request ) -> IronResult < Response > {
8
+ let mut response = Response :: with ( ( status:: Ok , OPENSEARCH_XML ) ) ;
9
+ response. headers . set ( ContentType ( "application/opensearchdescription+xml" . parse ( ) . unwrap ( ) ) ) ;
10
+ Ok ( response)
11
+ }
Original file line number Diff line number Diff line change
1
+ <OpenSearchDescription xmlns =" http://a9.com/-/spec/opensearch/1.1/" >
2
+ <ShortName >Docs.rs</ShortName >
3
+ <Description >Search for crate documentation on docs.rs</Description >
4
+ <Image width =" 16" height =" 16" type =" image/x-icon" >https://docs.rs/favicon.ico</Image >
5
+ <Url type =" text/html" method =" get" template =" https://docs.rs/releases/search?query={searchTerms}" />
6
+ </OpenSearchDescription >
Original file line number Diff line number Diff line change 12
12
<link rel =" stylesheet" href =" /style.css?{{ cratesfyi_version_safe }} " type =" text/css" media =" all" />
13
13
{{ #if varsb.javascript_highlightjs }}
14
14
<link rel =" stylesheet" href =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css" type =" text/css" media =" all" />
15
+ <link rel =" search" href =" /opensearch.xml" type =" application/opensearchdescription+xml" title =" Docs.rs" >
15
16
<script src =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js" type =" text/javascript" charset =" utf-8" ></script >
16
17
<script src =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/rust.min.js" type =" text/javascript" charset =" utf-8" ></script >
17
18
{{ /if }}
You can’t perform that action at this time.
0 commit comments