Skip to content

Commit

Permalink
Add ISearchFacets interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Nov 26, 2012
1 parent 0b15c36 commit a4e5549
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 9 additions & 4 deletions ckan/controllers/package.py
Expand Up @@ -241,10 +241,15 @@ def pager_url(q=None, page=None):
for facet in c.search_facets.keys():
limit = int(request.params.get('_%s_limit' % facet, 10))
c.search_facets_limits[facet] = limit
c.facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
'license': _('Licence'), }

# Facet titles
facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
'license': _('Licence'), }
for plugin in p.PluginImplementations(p.ISearchFacets):
facet_titles = plugin.search_facet_titles(facet_titles)
c.facet_titles = facet_titles

maintain.deprecate_context_item(
'facets',
Expand Down
16 changes: 15 additions & 1 deletion ckan/plugins/interfaces.py
Expand Up @@ -16,6 +16,7 @@
'IGroupForm',
'ITagController',
'ITemplateHelpers',
'ISearchFacets',
]

from inspect import isclass
Expand Down Expand Up @@ -677,4 +678,17 @@ def setup_template_variables(self, context, data_dict):
Add variables to c just prior to the template being rendered.
"""

##### End of hooks #####

class ISearchFacets(Interface):
'''
Allow adding new facets to search interface.
Plugins should add new facets should be added to the `search.facets`
config via the IConfigurer interface.
'''

def search_facet_titles(self, titles_dict):
'''
Should update and return a dictionary from facet name to facets
titles (latter get displayed on the search page).
'''
return titles_dict

0 comments on commit a4e5549

Please sign in to comment.