# HG changeset patch # User Brian Neal # Date 1327869762 21600 # Node ID 70722b7d10af2bb36397cbc4304eef0530851c73 # Parent abc4be5a82e597bd034472660f6e302b3710ba22 For bitbucket issue #1, add open graph meta tags to forum topics. diff -r abc4be5a82e5 -r 70722b7d10af gpp/forums/models.py --- 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): """ diff -r abc4be5a82e5 -r 70722b7d10af gpp/templates/forums/topic.html --- 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" %}