source: timingandestimationplugin/branches/trac0.11/timingandestimationplugin/stopwatch.py

Last change on this file was 7435, checked in by Russ Tyndall, 14 years ago

Merged in stopwatch changes to trac0.11 branch re #6469

File size: 1.0 KB
RevLine 
[7435]1"""
2Copyright (C) 2010, Tay Ray Chuan
3"""
4
5from trac.core import *
6
7from pkg_resources import resource_filename
8from trac.web.api import IRequestFilter
9from trac.web.chrome import ITemplateProvider, add_script, add_stylesheet
10
11class TicketStopwatch(Component):
12    implements(IRequestFilter, ITemplateProvider)
13
14    # IRequestFilter
15    def pre_process_request(self, req, handler):
16        return handler
17
18    def post_process_request(self, req, template, data, content_type):
19        if req.path_info.startswith('/ticket/'):
20            add_stylesheet(req, 'stopwatch/stopwatch.css')
21            add_script(req, 'stopwatch/StopwatchDisplay.js')
22            add_script(req, 'stopwatch/StopwatchControls.js')
23            add_script(req, 'stopwatch/Toggler.js')
24            add_script(req, 'stopwatch/stopwatch.js')
25
26        return template, data, content_type
27
28    # ITemplateProvider
29    def get_htdocs_dirs(self):
30        return [('stopwatch', resource_filename(__name__, 'htdocs'))]
31
32    def get_templates_dirs(self):
33        return []
Note: See TracBrowser for help on using the repository browser.