Changeset 2051

Show
Ignore:
Timestamp:
02/27/07 14:30:57 (1 year ago)
Author:
ErikRose
Message:

WikiWygPlugin:

setup.py:

  • Added *.htc to package_data, because we have one of those.

wikiwyg.py:

  • Now loads the Wikiwyg JS libs on every page Trac serves.
  • Replaced the deprecated add_javascript() with add_script().
  • Quit implementing INavigationController. I think TraciWyg? was doing that just to publish a test page at /wikiwyg.
  • Emptied get_templates_dirs(), because we don't have any templates anymore, because we're not doing that test page.
  • Other more minor changes

ClientServer?.js:

  • Added this as an example of how to do async wiki saving. It's verbatim from the Wikiwyg demo.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wikiwygplugin/0.11/setup.py

    r2048 r2051  
    88    version = '1.0', 
    99    packages = ['wikiwyg'], 
    10     package_data = {'wikiwyg': ['templates/*.html', 'htdocs/*.js', 'htdocs/*.css', 'htdocs/*.gif']}, 
     10    package_data = {'wikiwyg': ['templates/*.html', 'htdocs/*.js', 'htdocs/*.css', 'htdocs/*.gif', 'htdocs/*.htc']}, 
    1111     
    1212    author = "soloturn, Erik Rose, and Frank Wierzbicki", 
  • wikiwygplugin/0.11/wikiwyg/wikiwyg.py

    r2043 r2051  
    11# vim: expandtab tabstop=4 
    22 
    3 # wikiwyg plugin 
     3from trac.core import * 
     4from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script 
     5from trac.web.api import IRequestFilter 
    46 
    5 from trac.core import * 
    6 from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet, add_javascript 
    7 from trac.web.main import IRequestHandler 
    8 from trac.util import escape, Markup 
     7from pkg_resources import resource_filename 
    98 
    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' 
     9class TracWikiwygModule(Component): 
     10    implements(ITemplateProvider, IRequestFilter) 
    3011     
    31     def process_request(self, req): 
    32         return 'wikiwyg.cs', None 
    33  
    3412    # ITemplateProvider methods 
     13     
    3514    def get_templates_dirs(self): 
     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.) 
    3628        """ 
    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