我需要在我的 Rails 应用程序中嵌入 vimeo 或其他一些 html
有人可以给我指明方向,以便我可以在 Rails 中使用嵌入代码吗?有时我需要嵌入幻灯片专业文件,有时我需要在同一区域嵌入 youtube 文件,有时需要为不同条目嵌入 vimeo 文件,使用嵌入代码是最简单的,但它会不断剥离嵌入代码。
使用 santize 插件吗?有人可以给我指点教程或者给我一些帮助来帮助我入门吗?
谢谢
Can someone point me in a direction so that I can use embed code in Rails? Sometimes I need to embed a slideshow pro file and sometimes I need to embed a youtube file and sometimes a vimeo file in the same area for different entries, it would be easiest to use embed code but it keeps stripping the embed code.
Do use a santize plugin? Can someone point me to a tutorial or give me some help to get me started?
thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的,所以这个插件不是我问题的答案 -
我想简单地将嵌入代码添加到我的 Rails 应用程序中 - 基本上在我网站的同一区域 - 有时我想添加 youtube,有时,vimeo,有时一些东西来自幻灯片专业导演 - 由 XML 提要提供的 .swf。
因此,在对该网站和许多其他网站进行了大量研究之后,我发现有一个简单的解决方案。
在 RAILS 中转义 html。
xss_terminate
http://www.railslodge.com/plugins/910-xss-terminate
xss_terminate 是一个插件,可以使 HTML 的剥离和清理变得非常简单。安装后就忘记了。并且忘记忘记 h() 你的输出,因为你不再需要了。
但 xss_terminate 也很灵活。默认情况下,它会从用户输入中去除所有 HTML 标签。这通常是您想要的,但有时您需要用户能够输入 HTML。该插件允许您通过选择两个基于白名单的清理程序来删除不良 HTML,或者完全跳过基于每个字段的 HTML 清理。
这个插件的作用就像一个魅力——只需记住从
<%=h @article.body %> 中删除 h 即可。到 <%= @article.body %>
Ok, so the plugin was not the answer to my question --
I wanted to simply add embed code to my rails application -- basically in the same area of my site -- sometimes I wanted to add youtube, sometimes, vimeo and sometimes something coming out of slideshow pro director -- a .swf that is fed by an XML feed.
So after a ton of research on this site and many others -- I found there was a simple solution.
escaping html in RAILS.
xss_terminate
http://www.railslodge.com/plugins/910-xss-terminate
xss_terminate is a plugin in that makes stripping and sanitizing HTML stupid-simple. Install and forget. And forget about forgetting to h() your output, because you won't need to anymore.
But xss_terminate is also flexible. By default, it will strip all HTML tags from user input. This is usually what you want, but sometimes you need users to be able to enter HTML. The plugin allows you remove bad HTML with your choice of two whitelist-based sanitizers, or to skip HTML sanitization entirely on a per-field basis.
This plugin did it like a charm -- just remember to remove the h from
<%=h @article.body %> to <%= @article.body %>
这是与 vimeo 集成的示例 Rails 应用。看起来它利用了这个很棒的 vimeo 插件。来自自述文件:
听起来可能只是门票!
Here's a sample rails app with vimeo integration. It looks like it makes use of this great vimeo plugin. From the README:
Sounds like it might be just the ticket!
我通常只是使用 RedCloth 创建一个主体区域输入,这允许简单地将嵌入代码以及文本图像等放入其中。
I normally just create a body area_input with RedCloth, this allows for simply drop embedment code inas well as text image etc.