Permalink
Browse files

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

  • Loading branch information...
1 parent 5c3c033 commit d471d3e4b50305ddbe90d3e7e10e3466c0875eda Simon Bächler committed Mar 23, 2012
Showing with 18 additions and 6 deletions.
  1. +8 −3 README.rst
  2. +3 −1 feincms_oembed/contents.py
  3. +6 −1 feincms_oembed/models.py
  4. +1 −1 feincms_oembed/templates/external/default.html
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``
=========================
@@ -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))
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):
@@ -1,3 +1,3 @@
<p>
{{ response.html|safe }}
-</p>
+</p><!-- last update: {{ response.updated }} -->

0 comments on commit d471d3e

Please sign in to comment.