从 trac wiki 引用 javascript
我在 trac 运行 javascript 时遇到问题。 我知道这存在安全问题,但我的 trac 安装仅用作 Intranet。
我有以下代码可以工作(需要在trac.ini中的[wiki]下设置rendering_unsafe_content = true):
{{{
#!html
<script type="text/javascript" >
document.write("This is a test")
</script>
}}}
但是,用单独文件中的javascript替换它将会失败:
{{{
#!html
<script type="text/javascript" src="/tracproject/htdocs/test.js" >
</script>
}}}
其中tracproject是trac和test.js的根文件夹包含 document.write("这是一个测试")。
有什么线索吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过“添加标头插件”(http://trac-hacks.org/wiki/AddHeadersPlugin)?看起来它允许您按照需要包含自定义 JavaScript,但比直接修改模板更简单。
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.
该选项是
[wiki] render_unsafe_content
(请参阅文档 )。您可以在路径/tracproject/chrome/site/test.js
上引用站点 htdocs 目录中的文件。我刚才尝试了您的示例,一旦更改 src 路径,它就可以正常工作。有关更多详细信息,请参阅 TracInterfaceCustomization 页面。
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 thesrc
path is changed.See the TracInterfaceCustomization page for more details.