| 10 | | class UserbaseModule(Component): |
|---|
| 11 | | implements(INavigationContributor, IRequestHandler, ITemplateProvider) |
|---|
| 12 | | |
|---|
| 13 | | # INavigationContributor methods |
|---|
| 14 | | def get_active_navigation_item(self, req): |
|---|
| 15 | | return 'wikiwyg' |
|---|
| 16 | | |
|---|
| 17 | | def get_navigation_items(self, req): |
|---|
| 18 | | add_stylesheet(req, 'twyg/wikiwyg.css') |
|---|
| 19 | | add_javascript(req, 'twyg/Wikiwyg.js') |
|---|
| 20 | | add_javascript(req, 'twyg/Toolbar.js') |
|---|
| 21 | | add_javascript(req, 'twyg/Wysiwyg.js') |
|---|
| 22 | | add_javascript(req, 'twyg/Wikitext.js') |
|---|
| 23 | | add_javascript(req, 'twyg/Preview.js') |
|---|
| 24 | | add_javascript(req, 'twyg/Trac.js') |
|---|
| 25 | | yield 'mainnav', 'prepare-wikiwyg', Markup('<a href="%s">prepare wikiwyg</a>', self.env.href.wikiwyg()) |
|---|
| 26 | | |
|---|
| 27 | | # IRequestHandler methods |
|---|
| 28 | | def match_request(self, req): |
|---|
| 29 | | return req.path_info == '/wikiwyg' |
|---|
| | 9 | class TracWikiwygModule(Component): |
|---|
| | 10 | implements(ITemplateProvider, IRequestFilter) |
|---|
| | 15 | return [] |
|---|
| | 16 | |
|---|
| | 17 | def get_htdocs_dirs(self): |
|---|
| | 18 | """Provide the static JavaScript files, CSS, etc.""" |
|---|
| | 19 | yield ('', resource_filename(__name__, 'htdocs')) |
|---|
| | 20 | |
|---|
| | 21 | |
|---|
| | 22 | # IRequestFilter methods |
|---|
| | 23 | |
|---|
| | 24 | def pre_process_request(self, req, handler): |
|---|
| | 25 | """Load Wikiwyg libs on every page. |
|---|
| | 26 | |
|---|
| | 27 | (We might want to get more selective eventually.) |
|---|
| 37 | | Return the absolute path of the directory containing the provided |
|---|
| 38 | | ClearSilver templates. |
|---|
| 39 | | """ |
|---|
| 40 | | from pkg_resources import resource_filename |
|---|
| 41 | | return [resource_filename(__name__, 'templates')] |
|---|
| 42 | | |
|---|
| 43 | | def get_htdocs_dirs(self): |
|---|
| 44 | | """ |
|---|
| 45 | | Return a list of directories with static resources (such as style |
|---|
| 46 | | sheets, images, etc.) |
|---|
| 47 | | |
|---|
| 48 | | Each item in the list must be a `(prefix, abspath)` tuple. The |
|---|
| 49 | | `prefix` part defines the path in the URL that requests to these |
|---|
| 50 | | resources are prefixed with. |
|---|
| 51 | | |
|---|
| 52 | | The `abspath` is the absolute path to the directory containing the |
|---|
| 53 | | resources on the local file system. |
|---|
| 54 | | """ |
|---|
| 55 | | from pkg_resources import resource_filename |
|---|
| 56 | | return [('twyg', resource_filename(__name__, 'htdocs'))] |
|---|
| | 29 | for curScript in ['Wikiwyg', 'Toolbar', 'Wysiwyg', 'Wikitext', 'Preview', 'ClientServer']: |
|---|
| | 30 | add_script(req, 'wikiwyg/%s.js' % curScript) |
|---|
| | 31 | return handler |
|---|
| | 32 | |
|---|
| | 33 | # for Genshi templates |
|---|
| | 34 | def post_process_request(self, req, template, data, content_type): |
|---|
| | 35 | return template, data, content_type |
|---|