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:
parent
f2c0763fed
commit
b9879ad28d
|
@ -81,7 +81,7 @@ Installation
|
||||||
5. Finally, there are some optional configuration settings (shown here
|
5. Finally, there are some optional configuration settings (shown here
|
||||||
with their default settings)::
|
with their default settings)::
|
||||||
|
|
||||||
googleanalytics.resource_prefix = /downloads/
|
googleanalytics_resource_prefix = /downloads/
|
||||||
googleanalytics.domain = auto
|
googleanalytics.domain = auto
|
||||||
googleanalytics.track_events = false
|
googleanalytics.track_events = false
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class LoadAnalytics(CkanCommand):
|
||||||
self.CONFIG = pylonsconfig
|
self.CONFIG = pylonsconfig
|
||||||
|
|
||||||
self.resource_url_tag = self.CONFIG.get(
|
self.resource_url_tag = self.CONFIG.get(
|
||||||
'googleanalytics.resource_prefix',
|
'googleanalytics_resource_prefix',
|
||||||
DEFAULT_RESOURCE_URL_TAG)
|
DEFAULT_RESOURCE_URL_TAG)
|
||||||
|
|
||||||
# funny dance we need to do to make sure we've got a
|
# funny dance we need to do to make sure we've got a
|
||||||
|
|
|
@ -41,11 +41,11 @@ class GoogleAnalyticsPlugin(p.SingletonPlugin):
|
||||||
# If resource_prefix is not in config file then write the default value
|
# 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
|
# to the config dict, otherwise templates seem to get 'true' when they
|
||||||
# try to read resource_prefix from config.
|
# try to read resource_prefix from config.
|
||||||
if 'googleanalytics.resource_prefix' not in config:
|
if 'googleanalytics_resource_prefix' not in config:
|
||||||
config['googleanalytics.resource_prefix'] = (
|
config['googleanalytics_resource_prefix'] = (
|
||||||
commands.DEFAULT_RESOURCE_URL_TAG)
|
commands.DEFAULT_RESOURCE_URL_TAG)
|
||||||
self.googleanalytics_resource_prefix = config[
|
self.googleanalytics_resource_prefix = config[
|
||||||
'googleanalytics.resource_prefix']
|
'googleanalytics_resource_prefix']
|
||||||
|
|
||||||
self.show_downloads = converters.asbool(
|
self.show_downloads = converters.asbool(
|
||||||
config.get('googleanalytics.show_downloads', True))
|
config.get('googleanalytics.show_downloads', True))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{% block googleanalytics_event_tracking %}
|
{% block googleanalytics_event_tracking %}
|
||||||
{% resource 'ckanext-googleanalytics/googleanalytics_event_tracking.js' %}
|
{% resource 'ckanext-googleanalytics/googleanalytics_event_tracking.js' %}
|
||||||
<div class="js-hide" data-module="google-analytics"
|
<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>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue