Skip to main content

Provide a modular interface to styling Trac.

Project description

Notes

Adds a simple API and GUI for packaging and configuring Trac themes.

Configuration

trac.ini

All configuration options go in the [theme] section.

themeoptional, default: “default”

Theme name to use. Name is case-insensitive.

enable_cssoptional, default: false

Enable or disable the CSS customizations.

color.*optional

Stored values for simple CSS overrides. Note that changing this will not take effect until you save them in the admin panel.

Web interface

Theme

Use the arrows to select your theme from the installed options and then click the button to activate it.

http://trac-hacks.org/attachment/wiki/ThemeEnginePlugin/admin_theme.png?format=raw

Customize

Here you can further customize your theme by changing colors for certain pieces of the UI. The scheme drop down allows you to load pre-configured color schemes. Note that not all themes will support this, or support the same options.

http://trac-hacks.org/attachment/wiki/ThemeEnginePlugin/admin_customize.png?format=raw

Customize: Advanced

Here you can customize the CSS even further. As mentioned in the file, if you edit this file by hand, you should not use the simple customizer system or you will lose your changes.

http://trac-hacks.org/attachment/wiki/ThemeEnginePlugin/admin_advanced.png?format=raw

Example

To enable the PyDotOrg theme:

[theme]
theme = pydotorg

[components]
themeengine.* = enabled
pydotorgtheme.* = enabled

Creating a theme

Simple way

The easiest way to make a new theme is to inherit from ThemeBase. A basic example theme is as follows:

from trac.core import *

from themeengine.api import ThemeBase

class ExampleTheme(ThemeBase):
    """A example theme."""

    template = htdocs = css = screenshot = True

The name will be inferred from the class name (“Example” in this case) and the docstring will be used as the description. There are several class variables you can set to configure the theme. By default all of these are set to False and so are disabled. If set to True, each option will use a generally sane default. If set to any value other than those, that value will be used directly.

The available options as follows (all are optional):

templatedefault: $name_theme.html

The filename of the replacement template.

cssdefault: $name.css

Filename for a stylesheet to include.

htdocsdefault: htdocs

Subfolder containing static content.

screenshotdefault: htdocs/screenshot.png

Package-relative path to the screenshot file. File should be 640x400 or use the same aspect ratio.

colors :

Specifiers for simple color customization system. This should be an iterable of tuples of the form (name, property, selector). name will be shown in the customization UI for that entry. property will generally be color or background-color. selector should be a CSS selector string to apply the color rule to.

schemes :

Pre-built color schemes. This should be an iterable of tuples of the form (name, color_dict). The color_dict should be a dictionary mapping color name to hex color string (of the form #00AAFF).

Advanced API

For more advanced control you can implement IThemeProvider from themeengine.api. The interface definition is:

class IThemeProvider(Interface):
    """An interface to provide style information."""

    def get_theme_names():
        """Return an iterable of names."""

    def get_theme_info(name):
        """Return a dict containing 0 or more of the following pairs:

         description::
           A breif description of the theme.
         template::
           The name of the theme template file.
         css::
           The filename of the CSS file.
         htdocs::
           The folder containg the static content.
         screenshot::
           The name of the screenshot file.
         colors::
           A list of (name, css-property, selector) tuples.
         schemes::
           A list of (name, {color-name: value, ...}) tuples.
        """

Most of these are the same as the simple API above, except description is explicit.

Project details


Download files

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

Source Distributions

TracThemeEngine-2.1.2.zip (196.0 kB view details)

Uploaded Source

TracThemeEngine-2.1.2.tar.gz (180.7 kB view details)

Uploaded Source

TracThemeEngine-2.1.2.tar.bz2 (181.1 kB view details)

Uploaded Source

File details

Details for the file TracThemeEngine-2.1.2.zip.

File metadata

File hashes

Hashes for TracThemeEngine-2.1.2.zip
Algorithm Hash digest
SHA256 466a8b4a4aaf0d6bc5d912a1046e4bda5728c15b386d547471b9686a4846717e
MD5 00db099ad2c6f5ff116fda018326e400
BLAKE2b-256 bdb0233b57ee7150bb950606c03787dd7f6053875ed81a78049557c556005029

See more details on using hashes here.

File details

Details for the file TracThemeEngine-2.1.2.tar.gz.

File metadata

File hashes

Hashes for TracThemeEngine-2.1.2.tar.gz
Algorithm Hash digest
SHA256 ff2130bfe4058e38e555ab6a91da602f04d1c004e80911e9dc1d07cbf8c797b3
MD5 e15f119224db47c896c6edbeaf85403b
BLAKE2b-256 903f4fac712f87bef74726414617da2c96e11ca570078376519e33759521294f

See more details on using hashes here.

File details

Details for the file TracThemeEngine-2.1.2.tar.bz2.

File metadata

File hashes

Hashes for TracThemeEngine-2.1.2.tar.bz2
Algorithm Hash digest
SHA256 318b4b03222ecfaab654f26d034b66007c509520a2e8521df150b03b77988812
MD5 cace4e827515b83088eb2a349943561f
BLAKE2b-256 9750455eb90d7ec3d6f794f76b5609d5f5e3695d75b45cf2eebe25027ae3d386

See more details on using hashes here.

Supported by

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