Changeset 3366

Show
Ignore:
Timestamp:
03/14/08 18:00:41 (6 months ago)
Author:
coderanger
Message:

Working on trunk now.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • themeengineplugin/0.11/setup.py

    r3364 r3366  
    11#!/usr/bin/env python 
    22# -*- coding: iso-8859-1 -*- 
    3  
    4 if __import__('os').getlogin() != 'coderanger': 
    5     print 'DO NOT USE THIS CODE YET.' 
    6     __import__('sys').exit(1) 
    73 
    84from setuptools import setup 
     
    2420    ], 
    2521     
    26     install_requires = [], 
     22    install_requires = ['Trac>=0.11dev-r6696,>=0.11'], 
    2723 
    2824    entry_points = { 
  • themeengineplugin/0.11/themeengine/api.py

    r3364 r3366  
    11# Created by Noah Kantrowitz on 2007-07-16. 
    22# Copyright (c) 2007 Noah Kantrowitz. All rights reserved. 
     3import os.path 
    34import inspect 
    45 
     
    1718         description:: 
    1819           A breif description of the theme. 
    19          theme:: 
    20            The name of the theme file.  
     20         template:: 
     21           The name of the theme template file.  
    2122         css:: 
    2223           The filename of the CSS file. 
     
    8889         
    8990        info['description'] = inspect.getdoc(self.__class__) 
    90         self._set_info(info, 'theme', self.get_theme_names().next()+'_theme.html'
     91        self._set_info(info, 'template', os.path.join('templates', self.get_theme_names().next().lower()+'_theme.html')
    9192        self._set_info(info, 'css', self.get_theme_names().next().lower()+'.css') 
    9293        self._set_info(info, 'htdocs', 'htdocs') 
  • themeengineplugin/0.11/themeengine/web_ui.py

    r3364 r3366  
    11# Created by Noah Kantrowitz on 2007-07-15. 
    22# Copyright (c) 2007 Noah Kantrowitz. All rights reserved. 
     3import os.path 
     4 
    35from pkg_resources import resource_filename 
    46 
     
    1618 
    1719    def __init__(self): 
    18         # Force us to the front so we can override other templates 
    19         ComponentMeta._registry[ITemplateProvider].remove(ThemeEngineModule) 
    20         ComponentMeta._registry[ITemplateProvider].insert(0, ThemeEngineModule) 
    21          
    2220        self.system = ThemeEngineSystem(self.env) 
    23         self._last_theme = self.system.theme 
    24          
    25     def theme(self): 
    26         cur_theme = self.system.theme 
    27         if cur_theme is not self._last_theme: 
    28             # We have changed themes, reset the template loader 
    29             self.log.debug('ThemeEngine: Changing theme from %s to %s',  
    30                            (self._last_theme and self._last_theme['name'] or 'default'), 
    31                            (cur_theme and cur_theme['name'] or 'default')) 
    32             Chrome(self.env).templates = None 
    33             self._last_theme = cur_theme 
    34         return cur_theme 
    35     theme = property(theme) 
    3621 
    3722    # ITemplateProvider methods 
    3823    def get_htdocs_dirs(self): 
    39         theme = self.theme 
     24        theme = self.system.theme 
    4025        if theme and 'htdocs' in theme: 
    4126            yield 'theme', resource_filename(theme['module'], theme['htdocs']) 
    42              
     27 
    4328    def get_templates_dirs(self): 
    44         theme = self.theme 
    45         if theme and 'templates' in theme: 
    46             yield resource_filename(theme['module'], theme['templates']
    47          
     29        theme = self.system.theme 
     30        if theme and 'template' in theme: 
     31            yield resource_filename(theme['module'], os.path.dirname(theme['template'])
     32 
    4833    # IRequestFilter methods 
    4934    def pre_process_request(self, req, handler): 
    5035        return handler 
    51              
     36 
    5237    def post_process_request(self, req, template, data, content_type): 
    53         theme = self.theme 
     38        theme = self.system.theme 
    5439        if theme and 'css' in theme: 
    5540            add_stylesheet(req, 'theme/'+theme['css']) 
     41        if theme and 'template' in theme: 
     42            req.chrome['theme'] = os.path.basename(theme['template']) 
    5643        return template, data, content_type