Mercurial > public > sg101
diff gpp/news/models.py @ 486:7854d75427af
For #233, add a meta description field for news stories. This field will get put in the open graph meta tag for better descriptions when shared on social media sites.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 18 Oct 2011 23:23:42 +0000 |
parents | bbbc357ac5f3 |
children |
line wrap: on
line diff
--- a/gpp/news/models.py Tue Oct 18 00:14:34 2011 +0000 +++ b/gpp/news/models.py Tue Oct 18 23:23:42 2011 +0000 @@ -38,6 +38,7 @@ front_page_expiration = models.DateField(null=True, blank=True) update_date = models.DateTimeField(db_index=True, blank=True) priority = models.IntegerField(db_index=True, default=0, blank=True) + meta_description = models.TextField(blank=True) class Meta: abstract = True @@ -104,10 +105,16 @@ Returns a dict of Open Graph Protocol meta tags. """ + desc = self.meta_description.strip() + if not desc: + desc = 'News article submitted by %s on %s.' % ( + self.submitter.username, + self.date_submitted.strftime('%B %d, %Y')) + return { 'og:title': self.title, 'og:type': 'article', 'og:url': self.get_absolute_url(), 'og:image': self.category.icon.url, - 'og:description': self.title, + 'og:description': desc, }