Changeset 3366
- Timestamp:
- 03/14/08 18:00:41 (6 months ago)
- Files:
-
- themeengineplugin/0.11/setup.py (modified) (2 diffs)
- themeengineplugin/0.11/themeengine/api.py (modified) (3 diffs)
- themeengineplugin/0.11/themeengine/web_ui.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
themeengineplugin/0.11/setup.py
r3364 r3366 1 1 #!/usr/bin/env python 2 2 # -*- coding: iso-8859-1 -*- 3 4 if __import__('os').getlogin() != 'coderanger':5 print 'DO NOT USE THIS CODE YET.'6 __import__('sys').exit(1)7 3 8 4 from setuptools import setup … … 24 20 ], 25 21 26 install_requires = [ ],22 install_requires = ['Trac>=0.11dev-r6696,>=0.11'], 27 23 28 24 entry_points = { themeengineplugin/0.11/themeengine/api.py
r3364 r3366 1 1 # Created by Noah Kantrowitz on 2007-07-16. 2 2 # Copyright (c) 2007 Noah Kantrowitz. All rights reserved. 3 import os.path 3 4 import inspect 4 5 … … 17 18 description:: 18 19 A breif description of the theme. 19 t heme::20 The name of the theme file.20 template:: 21 The name of the theme template file. 21 22 css:: 22 23 The filename of the CSS file. … … 88 89 89 90 info['description'] = inspect.getdoc(self.__class__) 90 self._set_info(info, 't heme', 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')) 91 92 self._set_info(info, 'css', self.get_theme_names().next().lower()+'.css') 92 93 self._set_info(info, 'htdocs', 'htdocs') themeengineplugin/0.11/themeengine/web_ui.py
r3364 r3366 1 1 # Created by Noah Kantrowitz on 2007-07-15. 2 2 # Copyright (c) 2007 Noah Kantrowitz. All rights reserved. 3 import os.path 4 3 5 from pkg_resources import resource_filename 4 6 … … 16 18 17 19 def __init__(self): 18 # Force us to the front so we can override other templates19 ComponentMeta._registry[ITemplateProvider].remove(ThemeEngineModule)20 ComponentMeta._registry[ITemplateProvider].insert(0, ThemeEngineModule)21 22 20 self.system = ThemeEngineSystem(self.env) 23 self._last_theme = self.system.theme24 25 def theme(self):26 cur_theme = self.system.theme27 if cur_theme is not self._last_theme:28 # We have changed themes, reset the template loader29 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 = None33 self._last_theme = cur_theme34 return cur_theme35 theme = property(theme)36 21 37 22 # ITemplateProvider methods 38 23 def get_htdocs_dirs(self): 39 theme = self. theme24 theme = self.system.theme 40 25 if theme and 'htdocs' in theme: 41 26 yield 'theme', resource_filename(theme['module'], theme['htdocs']) 42 27 43 28 def get_templates_dirs(self): 44 theme = self. theme45 if theme and 'template s' 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 48 33 # IRequestFilter methods 49 34 def pre_process_request(self, req, handler): 50 35 return handler 51 36 52 37 def post_process_request(self, req, template, data, content_type): 53 theme = self. theme38 theme = self.system.theme 54 39 if theme and 'css' in theme: 55 40 add_stylesheet(req, 'theme/'+theme['css']) 41 if theme and 'template' in theme: 42 req.chrome['theme'] = os.path.basename(theme['template']) 56 43 return template, data, content_type
