Use g not config in templates

config is no longer available to templates (changed in CKAN core), use g
instead.

This means I have to rename googleanalytics.resource_prefix to
googleanalytics_resource_prefix, because it's now an attribute and can't
have a . in it.

Should probably be using g rather than config to access the setting in
the Python code as well..
This commit is contained in:
Sean Hammond 2012-12-20 21:39:24 +00:00
parent f2c0763fed
commit b9879ad28d
4 changed files with 6 additions and 6 deletions

View File

@ -81,7 +81,7 @@ Installation
5. Finally, there are some optional configuration settings (shown here
with their default settings)::
googleanalytics.resource_prefix = /downloads/
googleanalytics_resource_prefix = /downloads/
googleanalytics.domain = auto
googleanalytics.track_events = false

View File

@ -83,7 +83,7 @@ class LoadAnalytics(CkanCommand):
self.CONFIG = pylonsconfig
self.resource_url_tag = self.CONFIG.get(
'googleanalytics.resource_prefix',
'googleanalytics_resource_prefix',
DEFAULT_RESOURCE_URL_TAG)
# funny dance we need to do to make sure we've got a

View File

@ -41,11 +41,11 @@ class GoogleAnalyticsPlugin(p.SingletonPlugin):
# If resource_prefix is not in config file then write the default value
# to the config dict, otherwise templates seem to get 'true' when they
# try to read resource_prefix from config.
if 'googleanalytics.resource_prefix' not in config:
config['googleanalytics.resource_prefix'] = (
if 'googleanalytics_resource_prefix' not in config:
config['googleanalytics_resource_prefix'] = (
commands.DEFAULT_RESOURCE_URL_TAG)
self.googleanalytics_resource_prefix = config[
'googleanalytics.resource_prefix']
'googleanalytics_resource_prefix']
self.show_downloads = converters.asbool(
config.get('googleanalytics.show_downloads', True))

View File

@ -12,7 +12,7 @@
{% block googleanalytics_event_tracking %}
{% resource 'ckanext-googleanalytics/googleanalytics_event_tracking.js' %}
<div class="js-hide" data-module="google-analytics"
data-module-googleanalytics_resource_prefix="{{ config['googleanalytics.resource_prefix'] }}">
data-module-googleanalytics_resource_prefix="{{ g.googleanalytics_resource_prefix }}">
</div>
{% endblock %}
{% endblock %}