开发者

Referencing javascript from trac wiki

开发者 https://www.devze.com 2023-02-02 17:58 出处:网络
I h开发者_运维技巧ave a problem running javascripts from trac. I know there are security issues around this, but my trac installation is only used as an intranet.

I h开发者_运维技巧ave a problem running javascripts from trac. I know there are security issues around this, but my trac installation is only used as an intranet.

I have got the following code to work (requires setting rendering_unsafe_content = true under [wiki] in trac.ini):

{{{
#!html

<script type="text/javascript" >
document.write("This is a test")

</script>

}}}

However, replacing this with the javascript in a seperate file will fail:

{{{
#!html

<script type="text/javascript" src="/tracproject/htdocs/test.js" >

</script>


}}}

where tracproject is the root folder of trac and test.js contains document.write("This is a test").

Any clues?


Have you tried the 'Add Headers Plugin' (http://trac-hacks.org/wiki/AddHeadersPlugin) ? It looks like it allows you to do include custom javascript like you want but in a more straightforward way than having to modify templates directly.


The option is [wiki] render_unsafe_content (see documentation). You can reference the file in your site htdocs directory on the path /tracproject/chrome/site/test.js. I tried your example just now and it work correctly once the src path is changed.

See the TracInterfaceCustomization page for more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消