From b5971ff47fa286ae0206da3714d402bb731f70f7 Mon Sep 17 00:00:00 2001 From: Oleksandr Cherniavskyi Date: Wed, 30 Aug 2023 16:19:29 +0300 Subject: [PATCH] fix: set default theme --- ckanext/pygments/helpers.py | 2 +- ckanext/pygments/templates/pygment_form.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/pygments/helpers.py b/ckanext/pygments/helpers.py index 28e3dc4..9f2f6fb 100644 --- a/ckanext/pygments/helpers.py +++ b/ckanext/pygments/helpers.py @@ -40,7 +40,7 @@ def pygment_preview(resource: dict[str, Any], theme: str) -> tuple[str, str]: else: data = resp.text - css_styles = HtmlFormatter(style=theme).get_style_defs(".highlight") + css_styles = HtmlFormatter(style=theme or "default").get_style_defs(".highlight") return ( highlight( diff --git a/ckanext/pygments/templates/pygment_form.html b/ckanext/pygments/templates/pygment_form.html index ea2eecd..aa14a7e 100644 --- a/ckanext/pygments/templates/pygment_form.html +++ b/ckanext/pygments/templates/pygment_form.html @@ -2,4 +2,4 @@ {{ form.input('file_url', id='field-file_url', label=_('File URL'), placeholder=_('eg. http://example.com/test.sql (if blank uses resource url)'), value=data.file_url, error=errors.file_url) }} -{{ form.select('theme', id='field-theme', label=_('Preview theme'), options=h.get_preview_theme_options(), selected=data.theme, error=errors.theme) }} +{{ form.select('theme', id='field-theme', label=_('Preview theme'), options=h.get_preview_theme_options(), selected=data.theme or "default", error=errors.theme) }}