From 3b51e2a78eb6467c7c2f639f12e14c1db5f5163e Mon Sep 17 00:00:00 2001 From: Marc Dutoo Date: Thu, 9 Dec 2021 17:19:25 +0100 Subject: [PATCH] complete migration #8 --- ckanext/ozwillo_theme/plugin.py | 5 ++--- ckanext/ozwillo_theme/templates/base.html | 2 +- ckanext/ozwillo_theme/templates/base.html.orig | 16 ++++++++++++++++ .../templates/home/snippets/dataset_bloc.html | 6 +++--- .../package/snippets/package_basic_fields.html | 4 ++-- .../templates/package/snippets/package_form.html | 2 +- ckanext/ozwillo_theme/templates/page.html | 9 ++++----- .../templates/snippets/package_item.html | 4 ++-- 8 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 ckanext/ozwillo_theme/templates/base.html.orig diff --git a/ckanext/ozwillo_theme/plugin.py b/ckanext/ozwillo_theme/plugin.py index f6b43e6..8dbff14 100644 --- a/ckanext/ozwillo_theme/plugin.py +++ b/ckanext/ozwillo_theme/plugin.py @@ -1,7 +1,6 @@ -from pylons import config as pconfig - import ckan.plugins as plugins import ckan.plugins.toolkit as toolkit +pconfig = toolkit.config from ckan.common import config from ckan.lib.app_globals import set_app_global from ckan.lib.plugins import DefaultTranslation @@ -25,7 +24,7 @@ def update_config(self, config_): toolkit.add_template_directory(config_, 'templates') toolkit.add_public_directory(config_, 'public') - toolkit.add_resource('fanstatic', 'theme') + toolkit.add_resource('assets', 'theme') # ITemplateHelpers def get_helpers(self): diff --git a/ckanext/ozwillo_theme/templates/base.html b/ckanext/ozwillo_theme/templates/base.html index d5add68..3c42259 100644 --- a/ckanext/ozwillo_theme/templates/base.html +++ b/ckanext/ozwillo_theme/templates/base.html @@ -2,7 +2,7 @@ {% block styles %} {{ super() }} - {% resource 'theme/ozwillo.css' %} + {% asset 'theme/ozwillo-css' %} {% endblock %} diff --git a/ckanext/ozwillo_theme/templates/base.html.orig b/ckanext/ozwillo_theme/templates/base.html.orig new file mode 100644 index 0000000..d5add68 --- /dev/null +++ b/ckanext/ozwillo_theme/templates/base.html.orig @@ -0,0 +1,16 @@ +{% ckan_extends %} + +{% block styles %} + {{ super() }} + {% resource 'theme/ozwillo.css' %} + +{% endblock %} + +{% block links %} + +{% endblock %} + + +{% block body_extras %} + {{ super() }} +{% endblock %} diff --git a/ckanext/ozwillo_theme/templates/home/snippets/dataset_bloc.html b/ckanext/ozwillo_theme/templates/home/snippets/dataset_bloc.html index eea41e9..bedafc5 100644 --- a/ckanext/ozwillo_theme/templates/home/snippets/dataset_bloc.html +++ b/ckanext/ozwillo_theme/templates/home/snippets/dataset_bloc.html @@ -8,7 +8,7 @@
-

{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='package', action='read', +

{{ h.link_to(h.truncate(title, truncate_title), h.url_for('%s.read' % package.type, id=package.name)) }}

{% if notes %} @@ -22,7 +22,7 @@

{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='packag
    {% for resource in h.dict_list_reduce(package.resources, 'format') %}
  • - {{ resource }}
  • {% endfor %} @@ -30,4 +30,4 @@

    {{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='packag

- \ No newline at end of file + diff --git a/ckanext/ozwillo_theme/templates/package/snippets/package_basic_fields.html b/ckanext/ozwillo_theme/templates/package/snippets/package_basic_fields.html index 7603384..5ab5b58 100644 --- a/ckanext/ozwillo_theme/templates/package/snippets/package_basic_fields.html +++ b/ckanext/ozwillo_theme/templates/package/snippets/package_basic_fields.html @@ -5,8 +5,8 @@ {% endblock %} {% block package_basic_fields_url %} - {% set prefix = h.url_for(controller='package', action='read', id='') %} - {% set domain = h.url_for(controller='package', action='read', id='', qualified=true) %} + {% set prefix = h.url_for('dataset.read', id='') %} + {% set domain = h.url_for('dataset.read', id='', qualified=true) %} {% set domain = domain|replace("http://", "")|replace("https://", "") %} {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': ''} %} diff --git a/ckanext/ozwillo_theme/templates/package/snippets/package_form.html b/ckanext/ozwillo_theme/templates/package/snippets/package_form.html index ce53eca..8753092 100644 --- a/ckanext/ozwillo_theme/templates/package/snippets/package_form.html +++ b/ckanext/ozwillo_theme/templates/package/snippets/package_form.html @@ -36,7 +36,7 @@ {% endblock %} {% block delete_button %} {% if h.check_access('package_delete', {'id': data.id}) and not data.state == 'deleted' %} - {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} {% endif %} {% endblock %} {% block save_button %} diff --git a/ckanext/ozwillo_theme/templates/page.html b/ckanext/ozwillo_theme/templates/page.html index 528ad84..3bd572b 100644 --- a/ckanext/ozwillo_theme/templates/page.html +++ b/ckanext/ozwillo_theme/templates/page.html @@ -132,12 +132,11 @@

A sidebar item

{%- block scripts %} - {% resource 'theme/ozwillo.js' %} - {% resource 'theme/particles-loading.js' %} - {% resource 'base/main' %} - {% resource 'base/ckan' %} + {% asset 'theme/ozwillo' %} + {# % asset 'base/main' % rather in webassets.yml #} + {# % asset 'base/ckan' % rather in webassets.yml #} {% if g.tracking_enabled %} - {% resource 'base/tracking.js' %} + {% asset 'base/tracking' %} {% endif %} {{ super() }} {% endblock -%} diff --git a/ckanext/ozwillo_theme/templates/snippets/package_item.html b/ckanext/ozwillo_theme/templates/snippets/package_item.html index b0acb23..96c3e3d 100644 --- a/ckanext/ozwillo_theme/templates/snippets/package_item.html +++ b/ckanext/ozwillo_theme/templates/snippets/package_item.html @@ -34,7 +34,7 @@

{% endif %} {% endblock %} {% block heading_title %} - {{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='package', action='read', id=package.name)) }} + {{ h.link_to(h.truncate(title, truncate_title), h.url_for('%s.read' % package.type, id=package.name)) }} {% endblock %} {% block heading_meta %} {% if package.get('state', '').startswith('draft') %} @@ -66,7 +66,7 @@

{% block resources_inner %} {% for resource in h.dict_list_reduce(package.resources, 'format') %}
  • - {{ resource }} + {{ resource }}
  • {% endfor %} {% endblock %}