Skip to main content

No project description provided

Project description

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.

Requirements

Compatibility with core CKAN versions:

CKAN version Compatible?
2.11 no
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

The key benefit is the complete separation of content structure from styling. This means users can completely change the visual appearance of their CKAN instance (from Bootstrap to Tailwind, for example) by just changing the theme configuration, without modifying any templates or code.

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 = bare
    

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ckanext_theming-0.0.2.tar.gz (182.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ckanext_theming-0.0.2-py3-none-any.whl (475.1 kB view details)

Uploaded Python 3

File details

Details for the file ckanext_theming-0.0.2.tar.gz.

File metadata

  • Download URL: ckanext_theming-0.0.2.tar.gz
  • Upload date:
  • Size: 182.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for ckanext_theming-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d06fb823c5b122902a30f02244e11b10870e889989b7b0e9ca334fb35067ad3d
MD5 d65fc48c12aae931c3581b474927223c
BLAKE2b-256 0690ed894b1ab5b85277102e14ea6f543017ee096515ec20f1c8ea63483a8c1d

See more details on using hashes here.

File details

Details for the file ckanext_theming-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ckanext_theming-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 475.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for ckanext_theming-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 089f99fc0df5c1afd8d55873d5ec7075a3f2bdfe960f36cbf031d3eb0f9bf0b0
MD5 f3c270e8fe5e367cbcc0086b562c1177
BLAKE2b-256 177b9e455d2654fc35a72ea700a174e852f93484baaf5d0ffacdab3269967a79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page