changeset 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 5be850a66dfc
children 287d79be663e
files smiley/__init__.py smiley/models.py
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/smiley/__init__.py	Sun Aug 12 09:34:56 2012 -0500
+++ b/smiley/__init__.py	Sat Sep 01 15:17:40 2012 -0500
@@ -1,8 +1,7 @@
 """
 Smiley classes and functions.
+
 """
-import re
-
 from django.utils.safestring import SafeData
 from django.utils.html import conditional_escape
 
--- 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''