From 6a11e176a6f6032f2cb3a607dc56851ed29f4b27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Sat, 22 Dec 2012 12:48:44 +0100 Subject: [PATCH] add flattr buttons to podcast, episode pages --- mygpo/core/models.py | 2 ++ mygpo/data/feeddownloader.py | 2 ++ mygpo/web/templates/episode.html | 18 ++++++++++++------ mygpo/web/templates/podcast.html | 6 ++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/mygpo/core/models.py b/mygpo/core/models.py index 76ad88d0..2f02b7e8 100644 --- a/mygpo/core/models.py +++ b/mygpo/core/models.py @@ -55,6 +55,7 @@ class Episode(Document, SlugMixin, OldIdMixin): podcast = StringProperty(required=True) listeners = IntegerProperty() content_types = StringListProperty() + flattr_url = StringProperty() @@ -159,6 +160,7 @@ class Podcast(Document, SlugMixin, OldIdMixin): latest_episode_timestamp = DateTimeProperty() episode_count = IntegerProperty() random_key = FloatProperty(default=random) + flattr_url = StringProperty() diff --git a/mygpo/data/feeddownloader.py b/mygpo/data/feeddownloader.py index 1cc711d6..1c7c4faa 100755 --- a/mygpo/data/feeddownloader.py +++ b/mygpo/data/feeddownloader.py @@ -124,6 +124,7 @@ class PodcastUpdater(object): changed |= update_i(podcast.tags, 'feed', parsed.tags or podcast.tags.get('feed', [])) changed |= update_a(podcast, 'common_episode_title', parsed.common_title or podcast.common_episode_title) changed |= update_a(podcast, 'new_location', parsed.new_location or podcast.new_location) + changed |= update_a(podcast, 'flattr_url', parsed.flattr) if podcast.new_location: @@ -230,6 +231,7 @@ class PodcastUpdater(object): changed |= update_a(episode, 'filesize', parsed_episode.files[0].filesize) changed |= update_a(episode, 'language', parsed_episode.language or episode.language) changed |= update_a(episode, 'mimetypes', list(set(filter(None, [f.mimetype for f in parsed_episode.files])))) + changed |= update_a(episode, 'flattr_url', parsed_episode.flattr) urls = list(chain.from_iterable(f.urls for f in parsed_episode.files)) changed |= update_a(episode, 'urls', sorted(set(episode.urls + urls), key=len)) diff --git a/mygpo/web/templates/episode.html b/mygpo/web/templates/episode.html index a6fd379d..d11a1304 100644 --- a/mygpo/web/templates/episode.html +++ b/mygpo/web/templates/episode.html @@ -138,15 +138,21 @@ {% block sidebar %} -
+
-

Share

+

Share

- {% comment %} add flattr button if the user has his flattr-settings enabled{% endcomment %} + {% google_plus_one_button %} + {% fb_like_episode episode podcast %} - {% google_plus_one_button %} - {% fb_like_episode episode podcast %} -
+ {% if episode.flattr_url %} + + Flattr {{ episode.title|default: + + {% endif %} + +
diff --git a/mygpo/web/templates/podcast.html b/mygpo/web/templates/podcast.html index 5ed15ea1..8b476661 100755 --- a/mygpo/web/templates/podcast.html +++ b/mygpo/web/templates/podcast.html @@ -226,6 +226,12 @@ {% google_plus_one_button %} {{ podcast|fb_like_podcast }} + {% if podcast.flattr_url %} + + Flattr {{ podcast.title|default: + + {% endif %} -- 2.11.4.GIT