|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from logging import getLogger import ckan.plugins as p log = getLogger(__name__) class StatsPlugin(p.SingletonPlugin): '''Stats plugin.''' p.implements(p.IRoutes, inherit=True) p.implements(p.IConfigurer, inherit=True) def after_map(self, map): map.connect('stats', '/stats', controller='ckanext.dga_stats.controller:StatsController', action='index') map.connect('stats_action', '/stats/{action}', controller='ckanext.dga_stats.controller:StatsController') return map def update_config(self, config): templates = 'templates' if p.toolkit.asbool(config.get('ckan.legacy_templates', False)): templates = 'templates_legacy' p.toolkit.add_template_directory(config, templates) p.toolkit.add_public_directory(config, 'public') p.toolkit.add_resource('public/ckanext/stats', 'ckanext_dga_stats') |