Referencing javascript from trac wiki

本小妞迷上赌 提交于 2019-12-11 07:03:27

问题


I have 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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4580827/referencing-javascript-from-trac-wiki

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!