Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added modified date as comment to template, changed common params method

  • Loading branch information...
commit d471d3e4b50305ddbe90d3e7e10e3466c0875eda 1 parent 5c3c033
Simon Bächler sbaechler authored
11 README.rst
View
@@ -17,11 +17,12 @@ It's stunningly simple to use:
TYPE_CHOICES=[
- ('default', _('Default presentation'), {'maxwidth': 500, 'maxheight': 300, 'wmode': 'opaque'}),
- ('transparent, _('Transparent'), {'maxwidth': 500, 'maxheight': 300, 'wmode': 'transparent'}),
+ ('large', _('large'), {'maxwidth': 640, 'maxheight': 376 }),
+ ('small, _('small'), {'maxwidth': 360, 'maxheight': 240 }),
])
- Page.create_content_type(OembedContent, TYPE_CHOICES=TYPE_CHOICES)
+ Page.create_content_type(OembedContent, TYPE_CHOICES=TYPE_CHOICES,
+ PARAMS={'wmode': 'opaque', key:settings.EMBEDLY_KEY })
If you want to customize the Embedly_ request or use another OEmbed provider,
@@ -40,6 +41,10 @@ callable::
.. _Embedly: http://embed.ly/
+If you don't want any surprises with blocked access to embedly I suggest registering for
+a free API key: https://app.embed.ly/pricing/free
+
+
Using the ``FeedContent``
=========================
4 feincms_oembed/contents.py
View
@@ -27,14 +27,16 @@ class Meta:
verbose_name_plural = _('External contents')
@classmethod
- def initialize_type(cls, TYPE_CHOICES):
+ def initialize_type(cls, TYPE_CHOICES, PARAMS={}):
choices = [row[0:2] for row in TYPE_CHOICES]
cls.add_to_class('type', models.CharField(_('type'), max_length=20,
choices=choices, default=choices[0][0]))
cls._type_config = dict((row[0], row[2]) for row in TYPE_CHOICES)
+ cls._params = PARAMS
def get_html_from_json(self, fail_silently=False):
params = self._type_config.get(self.type, {})
+ params.update(self._params)
if 'parameters' in dir(self) and self.parameters:
params.update(json.loads(self.parameters))
7 feincms_oembed/models.py
View
@@ -44,7 +44,12 @@ def oembed(self, url, max_age=DEFAULT_MAX_AGE, **kwargs):
lookup = self.get_by_url(
oembed_provider(url, kwargs),
max_age=max_age)
- return simplejson.loads(lookup.response)
+ response = simplejson.loads(lookup.response)
+ try:
+ response['updated'] = lookup.modified
+ except AttributeError:
+ pass
+ return response
class CachedLookup(models.Model):
2  feincms_oembed/templates/external/default.html
View
@@ -1,3 +1,3 @@
<p>
{{ response.html|safe }}
-</p>
+</p><!-- last update: {{ response.updated }} -->
Please sign in to comment.
Something went wrong with that request. Please try again.