This fixes #26. First of all there is some refactoring: All low level
embed functions have been moved to the wagtail.wagtailembeds.embeds
package. There you will see:
. embed.py (which is more or less a copy of the old embeds.py)
. oembed_api.py which includes some low level code for using embedding
with the help of oembed, without any external dependencies (python-oembed
was not working very well and since oembed is just a URL get to a specific
URL I implemented it with urllib2 and json),
. endpoints.json which is a list of oembed endpoints I got from
https://github.com/panzi/oembedendpoints/blob/master/endpoints-regexp.json
. unittests.py with some tests to check that well known sites like
youtube, vimeo etc work fine with the oembed_api
The code refactoring also includes a number of exceptions. The get_embed
function now is included in try / except blocks and if an exception occurs
then the output will be an emtpy string (this was the behavior before the
refactor). However, in the chooser.py function the type of the exception
will be checked and a nice message will be shown to the editor.
Finally, to choose between embedly and the oembed a check is made to see
if the embedly library has been installed and also check if EMBEDLY_KEY
has been set in the settings. If these two checks are both true then the
get_embed will be assigned to get_embed_embedly -- else it will be
assigned to get_embed_oembed.
Now embeds.py has the infrastructre to select a different get_embed
function depending on if embedly should be used or not.
the different get_embed (get_embed_oembed) function should be written
now...
The _editor_js.html page has been modified in order to get the urls to the
various views through the {% url %} tag and add them to the global window
variable. I believe that this is actually the best solution in our case
and I like it much better than the other available options.
Please see the comments inside tasks.py.
TL;DR: Defines a fake "task" decorator - the fake
decorator was needed to add the delay() attribute
to the send_notification function
The Embedly API was not working at all because the return
value of Embedly (client) offered the attributes in dictionary
style and not as an object. Now everything seems to be fine.