From 7ad223f43cca71fedc7a62e9c239e42a358c3f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Tue, 12 Sep 2023 17:11:41 +0200 Subject: [PATCH] ref: migrate templates to CKAN 2.10 --- CHANGELOG | 1 + ckanext/dcor_theme/templates/home/about.html | 13 ------------- ckanext/dcor_theme/templates/home/index.html | 3 --- .../templates/home/snippets/promoted.html | 4 ++-- .../dcor_theme/templates/package/read_base.html | 4 ++-- .../templates/package/resource_read.html | 5 ++--- setup.py | 14 ++++++++++++++ 7 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 ckanext/dcor_theme/templates/home/about.html delete mode 100644 ckanext/dcor_theme/templates/home/index.html diff --git a/CHANGELOG b/CHANGELOG index e532e08..7d9ad55 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 0.7.0 - ref: use proper theming in CKAN 2.10 + - ref: migrate templates to CKAN 2.10 0.6.1 - maintenance release 0.6.0 diff --git a/ckanext/dcor_theme/templates/home/about.html b/ckanext/dcor_theme/templates/home/about.html deleted file mode 100644 index 66cc552..0000000 --- a/ckanext/dcor_theme/templates/home/about.html +++ /dev/null @@ -1,13 +0,0 @@ -{% ckan_extends %} - -{% block primary %} -
-
- {% block about %} - DCOR is the deformability cytometry open repository. - {% endblock %} -
-
-{% endblock %} - -{% block secondary %}{% endblock %} \ No newline at end of file diff --git a/ckanext/dcor_theme/templates/home/index.html b/ckanext/dcor_theme/templates/home/index.html deleted file mode 100644 index 92a3e8a..0000000 --- a/ckanext/dcor_theme/templates/home/index.html +++ /dev/null @@ -1,3 +0,0 @@ -{% ckan_extends %} - -{% block title %} {{ g.site_title }} {% endblock %} diff --git a/ckanext/dcor_theme/templates/home/snippets/promoted.html b/ckanext/dcor_theme/templates/home/snippets/promoted.html index 3ae3fd5..6423cd9 100644 --- a/ckanext/dcor_theme/templates/home/snippets/promoted.html +++ b/ckanext/dcor_theme/templates/home/snippets/promoted.html @@ -1,6 +1,6 @@ {% set intro = g.site_intro_text %} -
+
{% if intro %} {{ h.render_markdown(intro) }} @@ -20,7 +20,7 @@

{{ _("Welcome to DCOR") }}

diff --git a/ckanext/dcor_theme/templates/package/read_base.html b/ckanext/dcor_theme/templates/package/read_base.html index 614a305..3eedeb5 100644 --- a/ckanext/dcor_theme/templates/package/read_base.html +++ b/ckanext/dcor_theme/templates/package/read_base.html @@ -3,6 +3,6 @@ {# Just replace "users" icon by "group" icon for groups #} {% block content_primary_nav %} - {{ h.build_nav_icon(dataset_type ~ '.read', _('Dataset'), id=pkg.id if is_activity_archive else pkg.name, icon='sitemap') }} - {{ h.build_nav_icon(dataset_type ~ '.groups', _('Groups'), id=pkg.id if is_activity_archive else pkg.name, icon='group') }} + {{ h.build_nav_icon(dataset_type ~ '.read', _('Dataset'), id=pkg.name, icon='sitemap') }} + {{ h.build_nav_icon(dataset_type ~ '.groups', h.humanize_entity_type('group', default_group_type, 'content tab') or _('Groups'), id=pkg.name, icon='group') }} {% endblock %} \ No newline at end of file diff --git a/ckanext/dcor_theme/templates/package/resource_read.html b/ckanext/dcor_theme/templates/package/resource_read.html index 4038cff..efbe8e2 100644 --- a/ckanext/dcor_theme/templates/package/resource_read.html +++ b/ckanext/dcor_theme/templates/package/resource_read.html @@ -10,9 +10,8 @@ {% block package_archive_notice %} {% endblock %} - {% block resource_read_title %}

{{ h.resource_display_name(res) | truncate(50) }}

- {% endblock %} - + {% block resource_read_title %}

{{ h.resource_display_name(res) | truncate(50) }}

{% endblock %} + {% block resource_read_url %} {% endblock %} diff --git a/setup.py b/setup.py index 720cbd4..24a4d42 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ from setuptools import setup, find_packages from codecs import open # To use a consistent encoding import sys +import warnings author = "Paul Müller" authors = [author] @@ -12,6 +13,19 @@ sys.path.insert(0, realpath(dirname(__file__))+"/" + "/".join(name.split("-"))) from _version import version # noqa: E402 +try: + # Make sure this fails for old CKAN versions + import ckan + ckan_version = [int(v) for v in ckan.__version__.split(".")] + if ckan_version < [2, 10, 1]: + raise ValueError( + f"Your CKAN version {ckan_version} is not supported! If you " + f"are still on CKAN 2.9.5, then the following package versions " + f"are supported:" + f"\n ckanext-dcor_theme<=0.7.0" + ) +except ImportError: + warnings.warn("CKAN not installed, supported version check skipped.") setup( name=name,