diff smiley/models.py @ 613:0729c73d5761

For issue #18, use absolute URLs to the smilies for RSS readers.
author Brian Neal <bgneal@gmail.com>
date Sat, 01 Sep 2012 15:17:40 -0500
parents ee87ea74d46b
children 7429c98c8ece
line wrap: on
line diff
--- a/smiley/models.py	Sun Aug 12 09:34:56 2012 -0500
+++ b/smiley/models.py	Sat Sep 01 15:17:40 2012 -0500
@@ -5,6 +5,7 @@
 
 from django.db import models
 from django.core.cache import cache
+from django.contrib.sites.models import Site
 
 CACHE_TIMEOUT = 60 * 60      # seconds
 
@@ -75,14 +76,16 @@
     def html(self):
         """Returns a HTML img tag representation of the smiley."""
         if self.image:
-            return (u'<img src="%s" alt="%s" title="%s" />' %
-                    (self.get_absolute_url(), self.title, self.title))
+            site = Site.objects.get_current()
+            return (u'<img src="http://%s%s" alt="%s" title="%s" />' %
+                    (site.domain, self.get_absolute_url(), self.title, self.title))
         return u''
     html.allow_tags = True
 
     def markdown(self):
         """Returns a markdown representation of the smiley."""
         if self.image:
-            return (u'![%s](%s "%s")' % 
-                    (self.title, self.get_absolute_url(), self.title))
+            site = Site.objects.get_current()
+            return (u'![%s](http://%s%s "%s")' % 
+                    (self.title, site.domain, self.get_absolute_url(), self.title))
         return u''