mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-25 00:54:52 +00:00
Changed EMBEDLY_KEY to WAGTAILEMBEDS_EMBEDY_KEY
This commit is contained in:
parent
1aac0d6f44
commit
5915ec1f0e
2 changed files with 17 additions and 4 deletions
|
|
@ -184,7 +184,7 @@ Use a custom embed finder function, which takes a URL and returns a dict with me
|
|||
.. code-block:: python
|
||||
|
||||
# not a working key, get your own!
|
||||
EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830'
|
||||
WAGTAILEMBEDS_EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830'
|
||||
|
||||
Providing an API key for the Embedly service will use that as a embed backend, with a more extensive list of providers, as well as analytics and other features. For more information, see `Embedly`_.
|
||||
|
||||
|
|
@ -515,7 +515,7 @@ These two files should reside in your project directory (``myproject/myproject/`
|
|||
|
||||
# If you want to use Embedly for embeds, supply a key
|
||||
# (this key doesn't work, get your own!)
|
||||
# EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830'
|
||||
# WAGTAILEMBEDS_EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830'
|
||||
|
||||
|
||||
``urls.py``
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from datetime import datetime
|
||||
import json
|
||||
import warnings
|
||||
|
||||
# Needs to be imported like this to allow @patch to work in tests
|
||||
from django.utils.six.moves.urllib import request as urllib_request
|
||||
|
|
@ -11,6 +12,7 @@ from django.conf import settings
|
|||
|
||||
from wagtail.wagtailembeds.oembed_providers import get_oembed_provider
|
||||
from wagtail.wagtailembeds.models import Embed
|
||||
from wagtail.utils.deprecation import RemovedInWagtail14Warning
|
||||
|
||||
|
||||
class EmbedException(Exception):
|
||||
|
|
@ -31,7 +33,13 @@ def embedly(url, max_width=None, key=None):
|
|||
|
||||
# Get embedly key
|
||||
if key is None:
|
||||
key = settings.EMBEDLY_KEY
|
||||
try:
|
||||
key = settings.WAGTAILEMBEDS_EMBEDLY_KEY
|
||||
except AttributeError:
|
||||
key = settings.EMBEDLY_KEY
|
||||
warnings.warn(
|
||||
"EMBEDLY_KEY is now deprecated. Use WAGTAILEMBEDS_EMBEDLY_KEY instead",
|
||||
RemovedInWagtail14Warning)
|
||||
|
||||
# Get embedly client
|
||||
client = Embedly(key=key)
|
||||
|
|
@ -115,7 +123,12 @@ def get_default_finder():
|
|||
return import_string(settings.WAGTAILEMBEDS_EMBED_FINDER)
|
||||
|
||||
# Use embedly if the embedly key is set
|
||||
if hasattr(settings, 'EMBEDLY_KEY'):
|
||||
if hasattr(settings, 'WAGTAILEMBEDS_EMBEDLY_KEY'):
|
||||
return embedly
|
||||
elif hasattr(settings, 'EMBEDLY_KEY'):
|
||||
warnings.warn(
|
||||
"use WAGTAILEMBEDS_EMBEDLY_KEY instead.",
|
||||
RemovedInWagtail14Warning)
|
||||
return embedly
|
||||
|
||||
# Fall back to oembed
|
||||
|
|
|
|||
Loading…
Reference in a new issue