Changeset 1118
- Timestamp:
- 08/14/06 02:50:10 (1 year ago)
- Files:
-
- syscssplugin/0.10/dist (deleted)
- syscssplugin/0.10/setup.py (modified) (2 diffs)
- syscssplugin/0.10/syscss/syscss.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
syscssplugin/0.10/setup.py
r537 r1118 5 5 6 6 setup( 7 name = ' SysCss',8 version = ' 0.1',7 name = 'TracSysCss', 8 version = '1.0', 9 9 packages = ['syscss'], 10 10 … … 13 13 description = "Provides a system-wide CSS file for Trac", 14 14 license = "BSD", 15 keywords = "trac system css",16 url = "http://trac-hacks.org ",15 keywords = "trac plugin system css", 16 url = "http://trac-hacks.org/wiki/SysCssPlugin", 17 17 18 18 entry_points = { syscssplugin/0.10/syscss/syscss.py
r494 r1118 1 1 from trac.core import * 2 from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet 2 from trac.config import Option 3 from trac.web.chrome import ITemplateProvider, add_stylesheet, add_link 4 from trac.web.main import IRequestFilter 3 5 import os 4 6 5 try: 6 import syscss_file 7 user_file = syscss_file.file 8 except ImportError: 9 user_file = '/usr/share/trac/templates/sys_css.css' 10 11 class SysCssPlugin(Component): 7 class SysCssModule(Component): 12 8 """A system-wide CSS provider.""" 13 9 14 implements(INavigationContributor, ITemplateProvider) 10 css_path = Option('syscss', 'path', default='/usr/shart/trac/sys_css.css', 11 doc='Path to the CSS file') 12 path_type = Option('syscss', 'type', default='file', 13 doc='Type of path given. Choices are file and url.') 15 14 16 def __init__(self): 17 self.css = self.config.get('trac','syscss',default=None) 18 if not self.css: 19 self.css = user_file 20 self.css = self.css.strip() 21 15 implements(ITemplateProvider, IRequestFilter) 16 22 17 # INavigationContributor methods 23 18 def get_navigation_items(self, req): 24 19 add_stylesheet(req, 'syscss/'+os.path.basename(self.css)) 25 20 return [] 21 22 # IRequestFilter methods 23 def pre_process_request(self, req, handler): 24 return handler 25 26 def post_process_request(self, req, template, content_type): 27 if self.path_type == 'file': 28 add_stylesheet(req, 'syscss/'+os.path.basename(self.css_path)) 29 elif self.path_type == 'url': 30 add_link(req, 'stylesheet', req.href(self.css_path), mimetype='text/css') 31 return (template, content_type) 26 32 27 33 # ITemplateProvider methods … … 30 36 31 37 def get_htdocs_dirs(self): 32 return [('syscss',os.path.dirname(self.css))] 38 if self.path_type == 'file': 39 yield ('syscss',os.path.dirname(self.css_path))