Edgewall Software

Ticket #7774 (new enhancement)

Opened 2 months ago

Allow to set script charset in add_script

Reported by: martin@… Owned by:
Priority: normal Milestone:
Component: web frontend Version: none
Severity: normal Keywords: add_script javascript chrome
Cc:

Description

The function add_script in trac.web.chrome should allow the programmer to set a charset attribute for the script he/she is adding.

I wrote a small path for this:

  • trac/templates/layout.html

    diff -Naur Trac-0.11.1-py2.5.egg/trac/templates/layout.html Trac-0.11.1-py2.5.egg.new/trac/templates/layout.html
    old new  
    2020      <link type="application/opensearchdescription+xml" rel="search" 
    2121            href="${href.search('opensearch')}" title="Search $project.name"/> 
    2222    </py:if> 
    23     <script py:for="script in chrome.scripts" 
     23    <script py:for="script in chrome.scripts" charset="${script.charset}" 
    2424            type="${script.type}" src="${script.href}"></script> 
    2525    ${Markup('&lt;!--[if lt IE 7]&gt;')} 
    2626    <script type="text/javascript" src="${chrome.htdocs_location}js/ie_pre7_hacks.js"></script> 
  • Trac-0.11.1-py2.5.egg

    diff -Naur Trac-0.11.1-py2.5.egg/trac/web/chrome.py Trac-0.11.1-py2.5.egg.new/trac/web/chrome.py
    old new  
    8282            href = href.chrome 
    8383    add_link(req, 'stylesheet', href(filename), mimetype=mimetype) 
    8484 
    85 def add_script(req, filename, mimetype='text/javascript'): 
     85def add_script(req, filename, mimetype='text/javascript', charset='UTF-8'): 
    8686    """Add a reference to an external javascript file to the template. 
    8787     
    8888    If the filename is absolute (i.e. starts with a slash), the generated link 
     
    101101        if not filename.startswith('/'): 
    102102            href = href.chrome 
    103103        path = filename 
    104     script = {'href': href(path), 'type': mimetype} 
     104    script = {'href': href(path), 'type': mimetype, 'charset': charset } 
    105105 
    106106    req.chrome.setdefault('scripts', []).append(script) 
    107107    scriptset.add(filename) 

Attachments

Add/Change #7774 (Allow to set script charset in add_script)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from (none). Next status will be 'new'
The owner will change from (none) to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.