| 1 | """ |
|---|
| 2 | Copyright (C) 2010, Tay Ray Chuan |
|---|
| 3 | """ |
|---|
| 4 | |
|---|
| 5 | from trac.core import * |
|---|
| 6 | |
|---|
| 7 | from pkg_resources import resource_filename |
|---|
| 8 | from trac.web.api import IRequestFilter |
|---|
| 9 | from trac.web.chrome import ITemplateProvider, add_script, add_stylesheet |
|---|
| 10 | |
|---|
| 11 | class 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 [] |
|---|