--- a/ckanext/example/plugin.py +++ b/ckanext/example/plugin.py @@ -1,6 +1,8 @@ import os from logging import getLogger +from pylons import request +from genshi.input import HTML from genshi.filters.transform import Transformer from ckan.plugins import implements, SingletonPlugin @@ -70,9 +72,26 @@ This example filter renames 'frob' to 'foobar' (this string is found in the custom ``home/index.html`` template provided as part of the package). + + It also adds the chosen JQuery plugin to the page if viewing the + dataset edit page (provides a better UX for working with tags with vocabularies) """ stream = stream | Transformer('//p[@id="examplething"]/text()')\ .substitute(r'frob', r'foobar') + + routes = request.environ.get('pylons.routes_dict') + if routes.get('controller') == 'package' \ + and routes.get('action') == 'edit': + stream = stream | Transformer('head').append(HTML( + '' + )) + stream = stream | Transformer('body').append(HTML( + ''' + ' + + ''' + )) + return stream def before_map(self, map):