提供一个模块化接口来设计trac

TracThemeEngine的Python项目详细描述


注释

添加用于打包和配置trac主题的简单api和gui。

配置

trac.ini

所有配置选项都位于[theme]部分。

theme可选,默认值:“default”
要使用的主题名称。名称不区分大小写。
enable_css可选,默认值:false
启用或禁用CSS自定义设置。
color.*可选
用于简单CSS覆盖的存储值请注意,更改此选项将 在您将它们保存到“管理”面板中之前不会生效。

网络接口

主题

使用箭头从已安装的选项中选择主题,然后单击 激活它的按钮。

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

自定义

在这里你可以通过改变颜色来进一步定制你的主题 用户界面的片段“方案”下拉列表允许您加载预先配置的 配色方案。请注意,并非所有主题都支持这一点,或者支持 同样的选择。

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

自定义:高级

在这里您可以进一步定制css。如文件所述,如果你 手动编辑此文件,不应使用简单的自定义程序系统或 您将丢失更改。

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

示例

要启用pydotorg主题:

[theme]
theme = pydotorg

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

创建主题

简单方式

创建新主题的最简单方法是从ThemeBase继承一个 基本示例主题如下:

from trac.core import *

from themeengine.api import ThemeBase

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

    template = htdocs = css = screenshot = True

将从类名(在本例中为“example”)和 docstring将用作描述。有几个类变量 可以设置为配置主题。默认情况下,所有这些都设置为 False和so被禁用。如果设置为True,则每个选项将使用 通常是理智的违约如果设置为除这些值以外的任何值,则该值将 直接使用

可用选项如下(所有选项都是可选的):

template默认值:$name_theme.html
替换模板的文件名。
css默认值:$name.css
要包含的样式表的文件名。
htdocs默认值:htdocs
包含静态内容的子文件夹。
screenshot默认值:htdocs/screenshot.png
包到屏幕截图文件的相对路径。文件应为640x400或 使用相同的纵横比。
colors
简单颜色自定义系统的说明符。这应该是一个 形式为(name, property, selector)的元组的iterablename 将显示在该项的自定义用户界面中。property将 一般是colorbackground-colorselector应该是 要应用颜色规则的CSS选择器字符串。
schemes
预先构建的颜色方案这应该是形式的元组的iterable (name, color_dict)color_dict应该是字典映射 颜色名称到十六进制颜色字符串(格式为#00AAFF)。

高级API

对于更高级的控件,可以从 themeengine.api。接口定义为:

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

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

    def get_template_overrides(name):
        """(Optional) local changes to specific templates

        Return a sequence of tuples (old_html, new_html, function) where

         old_html::
           The name of the template overriden by this theme.
         new_html::
           The name of the template file replacing the former.
         function::
           Optional callback (or None) to add further data . Signature:
                   req::
                       Request object
                   template::
                       The value of `old_html` above
                   data::
                       Template data, may be modified
                   content_type::
                       Reported MIME type

        since 2.2.0
        """

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

         description::
           A brief description of the theme.
         template::
           The name of the theme template file.
         css::
           The filename of the CSS file.
         htdocs::
           The folder containing 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.
         scripts::
           A list of (filename, mimetype, charset, ie_if) respectively for
           script (relative | absolute) URI (mandatory),
           script MIME type (optional , defaults to 'text/javascript'),
           script charset encoding (optional, defaults to 'utf-8'),
           and a bool flag for MSIE-only shims (optional, defaults to False)
           @since 2.2.2
        """

除了^{tt25}之外,大多数都与上面的简单api相同$ 是明确的。

自定义特定视图

由于版本2.2.0,可以通过实现 (可选)get_template_overrides方法例如 下面的示例代码将使用 自定义Genshi模板:

class CustomTheme(...):

    #------8<------ Code omitted ------8<------

    def get_template_overrides(self, name):
        """Override ticket and wiki templates using custom templates
        """
        yield ('ticket.html', 'custom_ticket.html', None)
        yield ('wiki.html', 'custom_wiki.html', self._modify_wiki)

    def _modify_wiki(self, req, template, data, content_type):
        data['var'] = 'value'

注意,在样本公司de,将添加新数据以呈现wiki页面。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java optaplanner如何动态添加或编辑规则   java使用“public”是什么情况   java在selenium框架中,上下转换背后的逻辑是什么?   在Oracle ADF中使用EAR文件的java安装应用程序   java在Gradle中对现有的未签名apk进行签名   java spring事务超时不起作用   java是类级注释的定义类加载器始终是该类的初始类加载器的父级?   java在mysql中使用LIKE查询获取带撇号的记录   java CallableOrg。postgresql。util。日期参数未知的PSQLException   java我无法向jframe添加多个swing组件   java如何用数学在卡片对象中洗牌。随机的   java JavaFX 8将图形添加到右侧的标题窗格中   java NoClassDefFoundError。为什么?我该怎么修?   java重构Windows、UNIX、URI路径混合   关于java的服务。util。同时发生的ScheduledExecutorService。scheduleAtFixedRate:它执行任务的频率是多少?   TLS连接中ServerHelloDone之后的java SocketTimeoutException   java将多个图像上载到firebase并检索到viewpage   java有没有一种方法可以在不使用AWS SDK for 安卓的情况下在安卓应用程序上多部分上传到我的S3存储桶?