diff gpp/potd/models.py @ 491:7dbdbb08e68c

For #233; add social media sharing buttons to the photo of the day app.
author Brian Neal <bgneal@gmail.com>
date Thu, 20 Oct 2011 01:00:19 +0000
parents 3c951521e0ec
children ae89ba801e8b
line wrap: on
line diff
--- 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):