Skip to main content

Tests

ckanext-theming

This is a prototype of CKAN theming proposal. It defines a standard way to customize the look and feel of a CKAN instance. It allows developers and designers to create and apply themes without modifying core CKAN code, ensuring easier upgrades and maintenance.

Theme implementations:

Theme Description
Midnight blue portable CKAN's built-in theme(v2.12) rewritten with macros
NSW Design system Mapping of NSW DS components to CKAN theme

Requirements

Compatibility with core CKAN versions:

CKAN version Compatible?
2.11 not tested
2.12 yes

Overview

The CKAN Theming Extension introduces a modern theming system that provides a structured approach to UI customization. The system is built around a macro-based UI framework that allows themes to provide consistent, reusable components across CKAN instances.

Traditional CKAN Theme Implementation

  • Uses snippets for complex widgets
  • Majority of UI elements is implemented directly as template code with HTML
  • Contains framework-specific HTML with CSS classes directly in templates
  • Example: Input macros are called with Bootstrap classes as parameters

Suggested macro-based approach

  • Creates a collection of UI macros that abstract the underlying CSS framework
  • Developers use semantic calls like {{ ui.button("Click Me", style="primary") }} instead of writing HTML
  • Different themes can implement the same macros with different CSS frameworks (Bootstrap 5, Tailwind, Bulma, Pico CSS, etc.)
  • The theme system allows switching between completely different CSS frameworks by changing one configuration setting
  • Each theme provides its own implementation of the same set of macros using its specific CSS framework classes
  • Provides a consistent API regardless of the underlying CSS framework

Core Philosophy

ckanext-theming is designed to be optional and non-intrusive. You don't have to rewrite your existing code to use it. You can adopt it incrementally, using it only for new features or specific components where you want to benefit from theme portability.

For a deeper dive into what this project is (and isn't), check out the Philosophy & Goals page in our documentation.

Installation

To install ckanext-theming:

  1. Activate your CKAN virtual environment:

    pip install ckanext-theming
    
  2. Add theming to the ckan.plugins setting in your CKAN config file:

    ckan.plugins = ... theming
    
  3. Specify theme using ckan.ui.theme config option. Check available themes using ckan theme list CLI command

    ckan.ui.theme = classic-polyfill
    

Usage

Registering Themes

Extensions can register themes by implementing the ITheme interface in their plugin class:

import ckan.plugins as p
from ckanext.theming.interfaces import ITheme
from ckanext.theming.lib import Theme

class MyThemePlugin(ITheme, p.SingletonPlugin):

    def register_themes(self):
        return [
            Theme("my_theme", "/path/to/my_theme/root"),
            Theme("extended_my_theme", "/path/to/extended_my_theme/root", parent="my_theme"),
        ]

Using UI Macros

Once a theme is active, UI macros can be used in templates:

{{ ui.button("Click Me", style="primary", type="button") }}
{{ ui.card("Card content here", title="My Card") }}
{{ ui.alert("Success message", style="success") }}

Creating Custom Themes

For detailed instructions on creating custom themes, see theming guide.

Metadata

Release files for ckanext-theming 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckanext-theming 0.0.6
File Size Uploaded
ckanext_theming-0.0.6.tar.gz 829.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ckanext-theming 0.0.6
File Interpreter ABI Platform
ckanext_theming-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 1.9 MB

Release files / ckanext_theming-0.0.6.tar.gz

Download URL ckanext_theming-0.0.6.tar.gz
Size 829.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6cd246b201734f8514259907a27116035bdeb5dc6e6705725ee7eecb3f1e8717
BLAKE2b-256 checksum
How to use checksums
39875d7ac0bb67620b993194e317423f29ac1ef8e2a433c1396f010d049fcb42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ckanext_theming-0.0.6-py3-none-any.whl

Download URL ckanext_theming-0.0.6-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
479707d0ef86181b7d1f06bde46fbfea5c06994dabd30bbfb5c38f51a4fe1de5
BLAKE2b-256 checksum
How to use checksums
0f094bc0c483a937384fafd6efa29cc23a8426b9e348db7859398be305b6c463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page