Commits

Carl Meyer committed cdc9bd3

Added support for djangoembed.

Comments (0)

Files changed (4)

 ``django-adminfiles`` requires `Django`_ 1.1 or later,
 `sorl-thumbnail`_ and the `Python Imaging Library`_.
 
-`django-oembed`_ is required for OEmbed functionality. `flickrapi`_ is
-required for browsing Flickr photos, `gdata`_ for Youtube videos.
+`djangoembed`_ or `django-oembed`_ is required for OEmbed
+functionality. `flickrapi`_ is required for browsing Flickr photos, `gdata`_
+for Youtube videos.
 
 .. _Django: http://www.djangoproject.com/
 .. _sorl-thumbnail: http://pypi.python.org/pypi/sorl-thumbnail
 .. _Python Imaging Library: http://www.pythonware.com/products/pil/
 .. _django-oembed: http://pypi.python.org/pypi/django-oembed
+.. _djangoembed: http://pypi.python.org/pypi/djangoembed
 .. _gdata: http://pypi.python.org/pypi/gdata
 .. _flickrapi: http://pypi.python.org/pypi/flickrapi
 
 Embedding media from other sites
 ================================
 
-``django-adminfiles`` allows embedding media from any site that
-supports the OEmbed protocol. OEmbed support is provided via
-`django-oembed`_, which must be installed for embedding to work.
+``django-adminfiles`` allows embedding media from any site that supports the
+OEmbed protocol. OEmbed support is provided via `djangoembed`_ or
+`django-oembed`_, one of which must be installed for embedding to work.
 
-If `django-oembed`_ is installed, the `render_uploads template
-filter`_ will also automatically replace any OEmbed-capable URLs with
-the appropriate embed markup (so URLs from any site supported by
-`django-oembed`_ can simply be pasted in to the content manually).
+If a supported OEmbed application is installed, the `render_uploads template
+filter`_ will also automatically replace any OEmbed-capable URLs with the
+appropriate embed markup (so URLs from any site supported by the installed
+OEmbed application can simply be pasted in to the content manually).
 
 In addition, ``django-adminfiles`` provides views in its filepicker to
 browse Flickr photos, Youtube videos, and Vimeo videos and insert
 ``adminfiles_browser_views`` management command, which you can run
 with ``./manage.py adminfiles_browser_views``.
 
-.. _django-oembed: http://pypi.python.org/pypi/django-oembed
-
 Settings
 ========
 
 from django.conf import settings
 
 if 'oembed' in settings.INSTALLED_APPS:
-    from oembed.core import replace as oembed_replace
+    try:
+        # djangoembed
+        from oembed.consumer import OEmbedConsumer
+        def oembed_replace(text):
+            consumer = OEmbedConsumer()
+            return consumer.parse(text)
+    except ImportError:
+        # django-oembed
+        from oembed.core import replace as oembed_replace
 else:
     oembed_replace = lambda s: s
 
     If the given slug is not found, the reference is replaced with the
     empty string.
 
-    If ``django-oembed`` is installed, also replaces OEmbed URLs with
-    the appropriate embed markup.
+    If ``djangoembed`` or ``django-oembed`` is installed, also replaces OEmbed
+    URLs with the appropriate embed markup.
     
     """
     def _replace(match):
 class OEmbedView(BaseView):
     def check(self):
         if 'oembed' not in django_settings.INSTALLED_APPS:
-            raise DisableView('OEmbed views require django-oembed. '
-                              '(http://pypi.python.org/pypi/django-oembed)')
+            raise DisableView('OEmbed views require django-oembed or djangoembed. '
+                              '(http://pypi.python.org/pypi/django-oembed, '
+                              'http://pypi.python.org/pypi/djangoembed)')
 
 class YouTubeView(OEmbedView):
     template_name = 'adminfiles/uploader/video.html'

test_project/settings.py

 
 DEBUG = True
 
+SITE_ID = 1
+
 DATABASE_ENGINE = 'sqlite3'
 DATABASE_NAME = os.path.join(BASE, 'adminfiles-test.db')
 
     'adminfiles',
     'sorl.thumbnail',
     'testapp',
+    'oembed',
 )