This is a small extension to Demo how to integrate HTMX and an Hypermedia approach to CKAN.
After adding it to the plugins, navigate to /htmx/search
for a faceted search implemented with HTMX.
Note: You can still navigate to /dataset/
to have a comparison with current CKAN search implementation.
So far, this is an unstable for-demo purposes extension. If you encounter errors when trying to parse request.endpoint
you can comment the code
in CKAN's core flask_app.py
. (I'll fix this later):
# Disable CSRF protection if user was logged in via the Authorization
# header
if g.get("login_via_auth_header"):
# Get the actual view function, as it might not match the endpoint,
# eg "organization.edit" -> "group.edit", or custom dataset types
endpoint = request.endpoint or ""
#view = current_app.view_functions.get(endpoint)
#dest = f"{view.__module__}.{view.__name__}" # type: ignore
#csrf.exempt(dest)
# Set the csrf_field_name so we can use it in our templates
g.csrf_field_name = config.get("WTF_CSRF_FIELD_NAME")
# Provide g.controller and g.action for backward compatibility
# with extensions
#set_controller_and_action()
To install ckanext-htmx:
-
Activate your CKAN virtual environment
-
Clone the source and install it on the virtualenv
git clone https://github.com/pdelboca/ckanext-htmx.git cd ckanext-htmx pip install -e .
-
Add
htmx
to theckan.plugins
setting in your CKAN config file