Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
OpenSearch integration
Browse files Browse the repository at this point in the history
* Add a new endpoint /packages/opensearch that serves fedora_packages.xml
* Add a new opensearch template
* Add opensearch description link to chrome and search templates so the
  provider is visible in these two pages.
  • Loading branch information
aymanbagabas committed Oct 6, 2019
1 parent f8c9f38 commit 200d7ae
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fedoracommunity/controllers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def s(self, *args, **kwds):
'filters':{'search':search_str}}
}

@expose('mako:fedoracommunity.templates.opensearch', content_type='text/xml')
def opensearch(self, *args, **kwds):
'''OpenSearch provider'''
if len(args) > 0 and args[0] == 'fedora_packages.xml':
return {'title': 'Fedora Packages'}
else:
redirect('/')

@expose('mako:fedoracommunity.widgets.templates.widget_loader')
def _w(self, widget_name, *args, **kwds):
'''generic widget controller - loads a widget from our widget list
Expand Down
3 changes: 3 additions & 0 deletions fedoracommunity/templates/chrome.mak
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
type="image/vnd.microsoft.icon" rel="shortcut icon" />
<link href="//fedoraproject.org/favicon.ico"
type="image/x-icon" rel="shortcut icon"/>
<link title="${title}"
rel="search" type="application/opensearchdescription+xml"
href="${tg.url('/opensearch')}/fedora_packages.xml" />

<!--[if lt IE 7]>
<style type="text/css">
Expand Down
11 changes: 11 additions & 0 deletions fedoracommunity/templates/opensearch.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>${title}</ShortName>
<Description>Search ${title}</Description>
<Tags>${title}</Tags>
<Url type="text/html"
template="${request.host_url}${tg.url('/s')}/{searchTerms}"/>
<Url type="application/opensearchdescription+xml"
template="${request.host_url}${tg.url('/opensearch')}/fedora_packages.xml"/>
<SearchForm>http://127.0.0.1${tg.url('/s')}</SearchForm>
</OpenSearchDescription>
3 changes: 3 additions & 0 deletions fedoracommunity/templates/search.mak
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
type="image/vnd.microsoft.icon" rel="shortcut icon" />
<link href="//fedoraproject.org/favicon.ico"
type="image/x-icon" rel="shortcut icon"/>
<link title="${title}"
rel="search" type="application/opensearchdescription+xml"
href="${tg.url('/opensearch')}/fedora_packages.xml" />

<!--[if lt IE 7]>
<style type="text/css">
Expand Down

0 comments on commit 200d7ae

Please sign in to comment.