diff --git a/ckanext/openafrica/blueprint.py b/ckanext/openafrica/blueprint.py new file mode 100644 index 0000000..b826665 --- /dev/null +++ b/ckanext/openafrica/blueprint.py @@ -0,0 +1,41 @@ +from flask import Blueprint +from ckan.plugins.toolkit import render + +openafrica = Blueprint('datapusher', __name__) + +def toc(): + return render('home/about/toc.html') + +def accessibility(): + return render('home/about/accessibility.html') + +def coc(): + return render('home/about/coc.html') + +def moderation(): + return render('home/about/moderation.html') + +def faq(): + return render('home/about/faq.html') + +def privacy(): + return render('home/about/privacy.html') + +def contact(): + return render('home/about/contact.html') + +def atlas(): + return render('atlas.html') + +rules = [ + ("/about/terms-and-conditions", "toc", toc), + ("/about/accessibility", "accessibility", accessibility), + ("/about/code-of-conduct", "coc", coc), + ("/about/moderation-policy", "moderation", moderation), + ("/about/faq", "faq", faq), + ("/about/privacy", "privacy", privacy) +] + +for rule in rules: + openafrica.add_url_rule(*rule) + diff --git a/ckanext/openafrica/plugin.py b/ckanext/openafrica/plugin.py index f7bfed8..a5784d7 100644 --- a/ckanext/openafrica/plugin.py +++ b/ckanext/openafrica/plugin.py @@ -23,6 +23,7 @@ import ckan.plugins as plugins import ckan.plugins.toolkit as toolkit +from . import blueprint class OpenAfricaPlugin(plugins.SingletonPlugin): @@ -30,8 +31,8 @@ class OpenAfricaPlugin(plugins.SingletonPlugin): openAFRICA templating plugin. """ plugins.implements(plugins.IConfigurer) - plugins.implements(plugins.IRoutes, inherit=True) plugins.implements(plugins.ITemplateHelpers) + plugins.implements(plugins.IBlueprint) def update_config(self, config): u""" @@ -45,42 +46,50 @@ def update_config(self, config): # toolkit.add_resource('fanstatic', 'openafrica') toolkit.add_resource('assets', 'openafrica') - def before_map(self, map): - u""" - Called before the routes map is generated. ``before_map`` is before any - other mappings are created so can override all other mappings. - - :param map: Routes map object - :returns: Modified version of the map object + # IBlueprint + def get_blueprint(self): + """ + CKAN uses Flask Blueprints in the /ckan/views dir for user and dashboard + :return: """ - map.connect('/about/terms-and-conditions', - controller='ckanext.openafrica.controller:CustomPageController', - action='toc') - map.connect('/about/accessibility', - controller='ckanext.openafrica.controller:CustomPageController', - action='accessibility') - map.connect('/about/code-of-conduct', - controller='ckanext.openafrica.controller:CustomPageController', - action='coc') - map.connect('/about/moderation-policy', - controller='ckanext.openafrica.controller:CustomPageController', - action='moderation') - map.connect('/about/faq', - controller='ckanext.openafrica.controller:CustomPageController', - action='faq') - map.connect('/about/privacy', - controller='ckanext.openafrica.controller:CustomPageController', - action='privacy') - map.connect('/about/contact-us', - controller='ckanext.openafrica.controller:CustomPageController', - action='contact') - map.connect('/about/suggest-a-dataset', - controller='ckanext.openafrica.controller:CustomPageController', - action='suggest_a_dataset') - map.connect('/atlas-for-africa', - controller='ckanext.openafrica.controller:CustomPageController', - action='atlas') - return map + return blueprint.openafrica + + # def before_map(self, map): + # u""" + # Called before the routes map is generated. ``before_map`` is before any + # other mappings are created so can override all other mappings. + + # :param map: Routes map object + # :returns: Modified version of the map object + # """ + # map.connect('/about/terms-and-conditions', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='toc') + # map.connect('/about/accessibility', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='accessibility') + # map.connect('/about/code-of-conduct', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='coc') + # map.connect('/about/moderation-policy', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='moderation') + # map.connect('/about/faq', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='faq') + # map.connect('/about/privacy', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='privacy') + # map.connect('/about/contact-us', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='contact') + # map.connect('/about/suggest-a-dataset', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='suggest_a_dataset') + # map.connect('/atlas-for-africa', + # controller='ckanext.openafrica.controller:CustomPageController', + # action='atlas') + # return map def get_helpers(self): u"""