# HG changeset patch
# User Brian Neal
# Date 1319072419 0
# Node ID 7dbdbb08e68c197d41b62069ca6eaebac2e7e8d5
# Parent f0f3966ea44fdb4ee8a133c05ed3f07f484b8d92
For #233; add social media sharing buttons to the photo of the day app.
diff -r f0f3966ea44f -r 7dbdbb08e68c gpp/potd/models.py
--- a/gpp/potd/models.py Thu Oct 20 00:36:37 2011 +0000
+++ b/gpp/potd/models.py Thu Oct 20 01:00:19 2011 +0000
@@ -73,6 +73,20 @@
thumb_name = os.path.basename(self.photo.path)
self.thumb.save(thumb_name, ContentFile(s.getvalue()), save=False)
+ def ogp_tags(self):
+ """
+ Returns a dict of Open Graph Protocol meta tags.
+
+ """
+ desc = "Photo of the day: %s." % self.caption
+ return {
+ 'og:title': self.caption,
+ 'og:type': 'article',
+ 'og:url': self.get_absolute_url(),
+ 'og:image': self.photo.url,
+ 'og:description': desc,
+ }
+
class CurrentManager(models.Manager):
def get_current_photo(self):
diff -r f0f3966ea44f -r 7dbdbb08e68c gpp/templates/core/social_sharing_begin.html
--- a/gpp/templates/core/social_sharing_begin.html Thu Oct 20 00:36:37 2011 +0000
+++ b/gpp/templates/core/social_sharing_begin.html Thu Oct 20 01:00:19 2011 +0000
@@ -1,5 +1,5 @@
-
{% endblock %}
+{% block begin_body %}{% include 'core/social_sharing_begin.html' %}{% endblock %}
{% block content %}
{% if is_current %}
Photo Of The Day
@@ -28,11 +33,12 @@
on {{ potd.date_added|date:"d F Y" }}.
This photo has been Photo of the Day {{ potd.potd_count }} time{{ potd.potd_count|pluralize }}.
-{{ potd.description|safe }}
+{{ potd.description|safe }}
If you would like us to feature your photo, send it along with your username, a title, and
short description to admin@surfguitar101.com.
+{% social_sharing potd.caption potd.get_absolute_url %}
{% get_comment_count for potd as comment_count %}
This photo has comment{{ comment_count|pluralize }}.
@@ -50,3 +56,4 @@
We're sorry, there doesn't seem to be a photo of the day right now.
{% endif %}
{% endblock %}
+{% block end_body %}{% include 'core/social_sharing_end.html' %}{% endblock %}