changeset 556:70722b7d10af

For bitbucket issue #1, add open graph meta tags to forum topics.
author Brian Neal <bgneal@gmail.com>
date Sun, 29 Jan 2012 14:42:42 -0600
parents abc4be5a82e5
children 7247a406f92b
files gpp/forums/models.py gpp/templates/forums/topic.html
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/forums/models.py	Thu Jan 26 20:24:15 2012 -0600
+++ b/gpp/forums/models.py	Sun Jan 29 14:42:42 2012 -0600
@@ -256,6 +256,22 @@
     def search_summary(self):
         return u''
 
+    def ogp_tags(self):
+        """
+        Returns a dict of Open Graph Protocol meta tags.
+
+        """
+        desc = 'Forum topic created by %s on %s.' % (
+            self.user.username,
+            self.creation_date.strftime('%B %d, %Y'))
+
+        return {
+            'og:title': self.name,
+            'og:type': 'article',
+            'og:url': self.get_absolute_url(),
+            'og:description': desc,
+        }
+
 
 class Post(models.Model):
     """
--- a/gpp/templates/forums/topic.html	Thu Jan 26 20:24:15 2012 -0600
+++ b/gpp/templates/forums/topic.html	Sun Jan 29 14:42:42 2012 -0600
@@ -1,7 +1,11 @@
 {% extends 'base.html' %}
 {% load url from future %}
 {% load forum_tags %}
+{% load core_tags %}
 {% block title %}Forums: {{ topic.name }}{% endblock %}
+{% block custom_meta %}
+   {% open_graph_meta_tags topic %}
+{% endblock %}
 {% block custom_js %}
    {{ form.media }}
    {% include "forums/jump_box.js" %}