No project description provided
Project description
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:
-
Activate your CKAN virtual environment:
pip install ckanext-theming
-
Add
themingto theckan.pluginssetting in your CKAN config file:ckan.plugins = ... theming
-
Specify theme using
ckan.ui.themeconfig option. Check available themes usingckan theme listCLI commandckan.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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ckanext_theming-0.0.3.tar.gz.
File metadata
- Download URL: ckanext_theming-0.0.3.tar.gz
- Upload date:
- Size: 814.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e2434be224bede72526d91366e225e67fd4c7757d7e5375050983961e60f089
|
|
| MD5 |
4faad9b6d7d197292ca30a50588aa7b5
|
|
| BLAKE2b-256 |
bb21032ef1ed8043a3d344cb85fd33ca2da9ecc8a430dd702b889a217d97bbcb
|
File details
Details for the file ckanext_theming-0.0.3-py3-none-any.whl.
File metadata
- Download URL: ckanext_theming-0.0.3-py3-none-any.whl
- Upload date:
- Size: 996.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77327e852fda8b2cd3df2dd50f9f4c89042eff1b396568bdd38a8ae975a7b9cb
|
|
| MD5 |
708ec6d2cee205fb8f7884fae48c6fa3
|
|
| BLAKE2b-256 |
b230bd50c92db86ef7304803b514eaa84c1d4c088a2b595c42d1bade2c618816
|