-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CKAN 2.10 replace controllers & IRoutes with blueprints #54
Changes from all commits
cb48a10
9d6a088
196c22f
8476a33
d4e7111
229a52d
984c535
af01627
5249822
331ad80
b4ef7fe
63b4108
1d52438
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from flask import Blueprint | ||
from ckan.plugins.toolkit import render | ||
|
||
openafrica = Blueprint("openafrica", __name__) | ||
|
||
def static_path(path): | ||
def render_path(): | ||
return render(path) | ||
|
||
return render_path | ||
|
||
rules = [ | ||
("/about/terms-and-conditions", "toc", static_path("home/about/toc.html")), | ||
("/about/accessibility", "accessibility", static_path("home/about/accessibility.html")), | ||
("/about/code-of-conduct", "coc", static_path("home/about/coc.html")), | ||
("/about/moderation-policy", "moderation", static_path("home/about/moderation.html")), | ||
("/about/faq", "faq", static_path("home/about/faq.html")), | ||
("/about/privacy", "privacy", static_path("home/about/privacy.html")), | ||
("/about/contact-us", "contact", static_path("home/about/contact.html")) | ||
] | ||
|
||
for rule in rules: | ||
openafrica.add_url_rule(*rule) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,16 @@ | |
|
||
import ckan.plugins as plugins | ||
import ckan.plugins.toolkit as toolkit | ||
from . import blueprint | ||
|
||
|
||
class OpenAfricaPlugin(plugins.SingletonPlugin): | ||
u""" | ||
openAFRICA templating plugin. | ||
""" | ||
plugins.implements(plugins.IConfigurer) | ||
plugins.implements(plugins.IRoutes, inherit=True) | ||
plugins.implements(plugins.ITemplateHelpers) | ||
plugins.implements(plugins.IConfigurer, inherit=True) | ||
plugins.implements(plugins.ITemplateHelpers, inherit=True) | ||
plugins.implements(plugins.IBlueprint) | ||
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do some plugins use inherit and others don't? (This is for just my understanding). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the blueprint, we only need custom routes to handle our |
||
|
||
def update_config(self, config): | ||
u""" | ||
|
@@ -42,45 +43,16 @@ def update_config(self, config): | |
""" | ||
toolkit.add_template_directory(config, 'templates') | ||
toolkit.add_public_directory(config, 'public') | ||
# 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): | ||
""" | ||
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 | ||
CKAN uses Flask Blueprints to extend urls | ||
:return: | ||
""" | ||
return blueprint.openafrica | ||
|
||
|
||
def get_helpers(self): | ||
u""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer absolute imports.