我什么都没做。
feincms-oembed的Python项目详细描述
feincms-oembed从200多个内容转换标准url 提供嵌入视频、图像和丰富文章预览的提供商 让Embedly或另一个OEmbed提供者来完成这项艰苦的工作
使用起来非常简单:
将'feincms_oembed'添加到INSTALLED_APPS。
创建内容类型:
from feincms.module.page.models import Page from feincms_oembed.contents import OembedContent TYPE_CHOICES = [ ('default', _('Default presentation'), { 'maxwidth': 500, 'maxheight': 300, 'wmode': 'opaque'}), ('transparent', _('Transparent'), { 'maxwidth': 500, 'maxheight': 300, 'wmode': 'transparent'}), ] Page.create_content_type(OembedContent, TYPE_CHOICES=TYPE_CHOICES)
还可以指定发送到oembed的其他参数 提供商也:
Page.create_content_type(OembedContent, TYPE_CHOICES=TYPE_CHOICES, PARAMS={'wmode': 'opaque'})
默认情况下,feincms_oembed使用Embedlyoembed提供程序。这个提供者 即使对于免费计划,也需要一个api密钥。settings.EMBEDLY_KEY必须 因此要做好准备。 免费计划是每月5000个网址。
如果要自定义Embedly请求或使用其他oEmbed提供程序, 将settings.OEMBED_PROVIDER设置为接收URL和dict的函数 并返回一个合适的url,该url返回oembed 访问时使用json。OEMBED_PROVIDER必须是点式python路径或 可呼叫:
from feincms_oembed.providers import embedly_oembed_provider def my_provider(url, kwargs): kwargs['wmode'] = 'opaque' return embedly_oembed_provider(url, kwargs) OEMBED_PROVIDER = 'path.to.module.my_provider' # OEMBED_PROVIDER = my_provider # The function can be used too, not only # the dotted python path.
内容正在文件夹中按以下顺序查找模板 content/external/:
- type of the embedded object (e.g. ‘video’) + ^{tt8}$
- type of the content type (e.g. ‘transparent’) + ^{tt8}$
- ^{tt10}$
如果您不想在访问Embedly时遇到任何意外,建议您 您可以register获得一个免费的api密钥。
使用FeedContent
如果要使用FeedContent,请确保在 你的Python之路。