Changeset 2059

Show
Ignore:
Timestamp:
02/27/07 23:03:22 (1 year ago)
Author:
ErikRose
Message:

WikiWygPlugin:

  • We now wikiwyg-ify wiki pages on page load. To edit, don't click Edit this page; double-click a wiki page's body text. Saving etc. aren't implemented yet.
  • Trac.js is a template now, as it needs the base URL of the environment subbed into it.
  • Implemented IRequestHandler to serve the new Trac.js template.
  • Included Util.js on every page. addEvent() is in there, and we need it for registering the onload handler.
Files:

Legend:

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

    r2052 r2059  
    88    version = '1.0', 
    99    packages = ['wikiwyg'], 
    10     package_data = {'wikiwyg': ['htdocs/*.js', 'htdocs/*.css', 'htdocs/*.gif', 'htdocs/*.htc']},  # 'templates/*.html' can go back in here if we need it 
     10    package_data = {'wikiwyg': ['htdocs/*.js', 'htdocs/*.css', 'htdocs/*.gif', 'htdocs/*.htc', 'templates/*.js']}, 
    1111     
    1212    author = "soloturn, Erik Rose, and Frank Wierzbicki", 
  • wikiwygplugin/0.11/wikiwyg/templates/Trac.js

    r2038 r2059  
    22// onload should wikify the html. search for a better possibility 
    33// 
    4 onload = function() { 
    5   alert("wikifying start ..."); 
    6   var wiki = document.getElementById('wikipage'); 
    7   Wikiwyg.Trac.setup_wikiwyg_section(wiki, '<?cs var:htdocs_location ?>'); 
    8   } 
     4addEvent("onload", ( 
     5  function() { 
     6    var div = $(".wikipage")[0];  // uses JQuery 
     7    Wikiwyg.Trac.setup_wikiwyg_section(div, '${href()}/chrome/');  //should be something like '/my-env/chrome/' 
     8  }) 
     9); 
    910 
    1011 
  • wikiwygplugin/0.11/wikiwyg/wikiwyg.py

    r2053 r2059  
    11# vim: expandtab tabstop=4 
     2import re 
    23 
    34from trac.core import * 
    45from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script 
    5 from trac.web.api import IRequestFilter 
     6from trac.web.api import IRequestFilter, IRequestHandler 
    67 
    78from pkg_resources import resource_filename 
    89 
    910class TracWikiwygModule(Component): 
    10     implements(ITemplateProvider, IRequestFilter
     11    implements(ITemplateProvider, IRequestFilter, IRequestHandler
    1112     
    1213    # ITemplateProvider methods 
    1314     
    1415    def get_templates_dirs(self): 
    15         return [] 
     16        yield resource_filename(__name__, 'templates') 
    1617     
    1718    def get_htdocs_dirs(self): 
     
    2021     
    2122     
     23    # IRequestHandler methods 
     24     
     25    def match_request(self, req): 
     26        """Return whether the handler wants to process the given request.""" 
     27        return re.match(r'^/wikiwyg(?:/(.*)|$)', req.path_info) is not None 
     28 
     29    def process_request(self, req): 
     30        """For now, just always return Trac.js, as it's the only template we have.""" 
     31        return 'Trac.js', {}, 'text/plain'  # TODO: Should be text/javascript, of course, but there's a bug in 0.11 trunk (#4855) that invokes Genshi's XHTML mode for that. 
     32     
     33     
    2234    # IRequestFilter methods 
    2335     
    2436    def pre_process_request(self, req, handler): 
    25         """Load Wikiwyg libs pages that make use of them.""" 
     37        """Load Wikiwyg libs on pages that make use of them.""" 
    2638        def uses_wikiwyg(req): 
    2739            """Return whether the page referenced by req can make use of Wikiwyg.""" 
     
    2941         
    3042        if uses_wikiwyg(req): 
    31             for curScript in ['Wikiwyg', 'Toolbar', 'Wysiwyg', 'Wikitext', 'Preview', 'Trac']:  # 'ClientServer' (put this back in when you implement async save) 
     43            for curScript in ['Util', 'Wikiwyg', 'Toolbar', 'Wysiwyg', 'Wikitext', 'Preview']:  # 'ClientServer' (put this back in when you implement async save) 
    3244                add_script(req, 'wikiwyg/%s.js' % curScript) 
     45            add_script(req, '/wikiwyg/Trac.js') 
    3346        return handler 
    3447