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

OpenSearch integration #424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>${request.host_url}${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