Plone消费者和提供者的oEmbed集成
项目描述
简介
此插件将oembed集成到Plone中。您可以在http://youtu.be/kHikGIWrvCs找到演示。
oEmbed官方文档:http://oembed.com/
您需要知道此插件试图超越已支持的网站,尽可能多地集成提供者,而不使用第三方服务。
如何安装
此插件可以像其他插件一样安装。请遵循官方文档。
oembed提供者
您的网站将使用@@oembed视图作为端点成为oembed提供者
URL Scheme: http://mysite.com/* API endpoint: http://mysite.com/@@oembed Supports discovery via <link> tags
此插件使用archetypes getPrimaryField获取您内容类型的最具代表性的字段,然后构建嵌入此内容的详细信息
要更改此行为,您可以覆盖特定上下文中的视图
<browser:page name="oembed" for="my.specific.context.IMYContent" class="my.specific.provider.OEmbedProvider" permission="zope2.View" layer="my.specific.layer.Layer" /> from collective.oembed.provider. class OEmbedProvider(OEmbedProvider): def add_context_info(self, ob, site): self.embed['type'] = 'rich' ...
oembed客户端
此插件提供jquery.oembed插件的集成。由于存在许多分支,您必须选择您要使用的一个。官方插件已通过插件collective.js.oembed集成到plone中。
oembed客户端是通过一个默认未激活的viewlet集成的。您需要通过控制面板来激活它。它就是这样配置的
<script type="text/javascript"> jqueryOmebedSettings = {...} //extracted from the controlpanel </script> <script type="text/javascript"> $(document).ready(function() { $(".oembed").oembed(null,jqueryOmebedSettings); }); </script>
消费者
消费者可以通过一个实用工具获得
>>> url = "http://www.youtube.com/watch?v=it1hMtZKle8" >>> consumer = component.getUtility(collective.oembed.interfaces.IConsumer) >>> consumer.get_data(url, maxwidth=300, maxheight=None, format='json') {...}
还有一个@@collective.oembed.consumer视图,它可以通过属性传递参数
>>> consumer_view = component.queryMultiAdapter((self.context,self.request), ... name=u'collective.oembed.consumer') >>> consumer_view._url = url >>> consumer_view.embed_auto() <div class="oembed-wrapper oembed-video">...</div>
OEmbed链接视图
此插件将oembed视图注册到链接内容类型。它显示来自远程URL提供的内容,不设置最大宽度和最大高度。这应由集成商实现。
链接视图存储3个不同的组件列表
oembed
api2embed
url2embed
oembed
包含已注册的oembed_view类型的视图,能够从目标提供者的oembed API获取HTML嵌入模板(下表列出了目前支持的服务提供者)。
api2embed
如果您为目标网站有API密钥,您应该能够通过这些视图使用它。一旦此功能实现,您应该能够选择是否激活它。
url2embed
包含已注册的url2embed_view类型的视图,它直接从目标的URL获取嵌入模板。用作不支持oEmbed格式的网站的备用方案。
注意
While the returned data will be sufficient to embed the target widget in your view, you won't be able to access the metadata which could have been associated with it in a straight oEmbed format.
这三个列表按照此处显示的顺序进行检查,并使用找到的第一个有效组件来获取嵌入代码。如果没有找到任何匹配项,则不会显示任何内容。
检查endpoint.csv,以查看每个服务当前支持哪些视图。
Embed.ly
此插件可以使用embed.ly服务。您可以在控制面板中设置embed.ly API密钥,或安装和配置collective.embedly,此插件将使用此提供的配置。
提供者
只有当您添加了api_key或配置了collective.embedly时,embed.ly才会被激活。插件为以下服务提供原生支持
外部提供者
Embedly (http://embed.ly)
视频提供者
5min (http://www.5min.com/)
Youtube (http://www.youtube.com/)
Qik (http://qik.com/)
Revision3 (http://revision3.com/)
Hulu (http://www.hulu.com/)
Vimeo (http://vimeo.com/)
CollegeHumor (http://www.collegehumor.com/)
Kinomap (http://wwww.kinomap.com/)
Dailymotion (http://www.dailymotion.com/)
Clikthrough (http://clikthrough.com)
Dotsub (http://dotsub.com/)
Vhx.tv (http://vhx.tv) 注意:仅适用于分享的专用URL
Nfb.ca (http://http://www.nfb.ca/)
Wordpress TV (http://wordpress.tv/)
Screenr (http://screenr.com/)
照片提供者
23hq (http://www.23hq.com/)
Flickr (http://www.flickr.com/)
SmugMug (http://www.smugmug.com/)
Photobucket (http://photobucket.com)
Instagr (http://instagr.am/)
Picasa (https://picasa.google.com/)
丰富提供者
Occipital (http://360.io)
iFixit (http://www.iFixit.com)
Apple (http://itunes.apple.com)
Poll Everywhere (http://www.polleverywhere.com/)
SlideShare (http://www.slideshare.net/)
WordPress (http://wordpress.com/)
Official.FM (http://official.fm)
Gist Github (https://gist.github.com)
Google Calendar (https://www.google.com/calendar)
谷歌文档 (https://docs.google.com/)
谷歌地图 (http://maps.google.com)
Issuu (http://issuu.com)
Scribd (http://www.scribd.com)
SoundCloud (http://soundcloud.com/)
Spotify (http://open.spotify.com/)
代理OEmbed端点
此插件提供消费者和提供者。两者可以在代理OEmbed端点同时使用。这意味着你可以询问你的网站如何显示URL,无论它是来自网站本身还是来自外部。
其他Plone插件
插件设计(针对2.0版本)
2.0版本完全重写了内部代码
目标
代码更容易理解
组件更少
性能优化
提供的集成仅通过ajax请求使用json。
我们有一个主要视图实现这一功能:@@proxy-oembed-provider
该视图使用基于以下内容的ram缓存和缓存键:* url + 最大宽度 + 最大高度 * 1小时(如果远程HTML已更改)
存在一个结构键/值,以主机名作为键,以低级别消费者名称作为值。这些值在需要时实例化(懒加载),因此它使用更少的内存。
待办事项
使全局结构可配置
通过portal_registry黑名单一些主机名
通过portal_registry添加新的键/值主机名/消费者名称
通过portal_registry覆盖现有值
致谢
公司
作者
JeanMichel FRANCOIS(又名toutpt)<toutpt@gmail.com>
贡献者
Raphael Gaziano(又名raphigaziano)<r.gaziano@gmail.com>
Alejandro Pereira(又名aleGpereira)<alepereira86@gmail.com>
Sylvain Bouchard(又名bouchardsyl)<sylvain.bouchard@savoirfairelinux.com>
变更日志
2.0.1 (2013-12-09)
修复JS:未捕获的类型错误:无法调用未定义的方法'match'
修复vimeo https端点
修复twitter用户端点
2.0 (2013-11-21)
修复(js):替换ie不支持的使用dataset为getAttribute [toutpt]
如果结果是链接,则不要替换链接 [toutpt]
修复kinomap端点(不再支持oembed -> url2embed) [toutpt]
修复内部提供者以与dexterity内容类型一起工作 [toutpt]
2.0a4(2013-05-17)
测试了与Plone 4.3的兼容性 [hvelarde]
修复了关于最大高度的JavaScript类型错误 [bouchardsyl]
2.0a3(2013-04-02)
修复tiles zcml条件检查。
使用模板进行瓷砖渲染
为oembed瓷砖添加响应式选项
2.0a2(2013-01-31)
修复Plone4.0兼容性
2.0a1(2013-01-29)
现在可以在div.oembed内部使用链接,因为tinymce没有很好地应用样式到“a” [djay]
重构代码以使用具有hostname/[lazy_endpoints]的结构
测试覆盖率高达94%
添加spotify端点(open.spotify.com)
1.2.5 (2013-01-07)
修复soundcloud提供者,可以使用https
如果已安装plone.app.tiles,则添加oembed瓷砖
添加screenr提供者
添加测试视图endpoints_test_view,仅在提供的buildout中可用
重构测试以使用assertX代替failUnless
为img、embed和object标签添加响应式行为
添加itunes.apple.com支持(iPhone应用)
添加360.io支持(occipital)
添加issuu.com支持
1.2.4 (2013-01-02)
添加“proxy-oembed-provider”,使您的Plone成为oembed代理消费者和提供者
添加twitteruser(api2embed)并在所有地方激活api2embed
改进使用主字段进行本地oembed支持的archetypes
更新HTML代码使其响应式(来自fitVids.js)
1.2.3 (2012-08-24)
添加对Soundcloud的支持。[aleGpereira]
1.2.2 (2012-07-10)
使GoogleMaps与地图和我的地图都兼容
PEP8
1.2.1 (2012-04-25)
修复离线模式(在没有互联网的情况下工作)
1.2 (2012-03-15)
添加对Plone 4.0.x的支持
1.1 (2012-02-22)
添加collective.oembed.url2embed浏览器视图组件
添加collective.oembed.superconsumer浏览器视图组件
添加GoogleMaps、gist.github.com、Google日历、Google文档、Scribd支持
支持缩短的URL,包括tinyurl.com、goo.gl、bit.ly、t.co、youtub.be、vbly.us
1.0 (2012-01-13)
修复5min端点的正则表达式。
处理更多错误:HTTPError、OEmbedError
添加url2embed支持
为instagr.am、Vhx.tv、Official.FM、Nfb.ca添加oembed支持[raphigaziano]
为picasaweb添加url2embed支持[raphigaziano]
1.0a (2012-01-02)
初始版本
项目详情
collective.oembed-2.0.1.zip的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | 3e726e2cd2500cead770aa405533e63bd92f985dce31acc1832b7563b998bdfe |
|
MD5 | a3d907eb2770db026b4c0ad7d2a88442 |
|
BLAKE2b-256 | 816db7f1274b60814c4e178341dd509e5e4b412239556050feb88da6d70c0757 |