Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed tweet rendering finally

  • Loading branch information...
commit 40b1b08ac156bb97802f6be3e9d130ba6f5fff5e 1 parent 668f519
Brian Rosner authored August 22, 2009
6  microblogging/feeds.py
@@ -6,8 +6,8 @@
6 6
 from django.contrib.contenttypes.models import ContentType
7 7
 from django.shortcuts import get_object_or_404
8 8
 from microblogging.models import Tweet, TweetInstance
9  
-from microblogging.templatetags.microblogging_tags import fmt_user
10  
-from django.template.defaultfilters import linebreaks, escape, capfirst
  9
+from microblogging.templatetags.microblogging_tags import render_tweet_text
  10
+from django.template.defaultfilters import linebreaks, capfirst
11 11
 from datetime import datetime
12 12
 
13 13
 ITEMS_PER_FEED = getattr(settings, 'PINAX_ITEMS_PER_FEED', 20)
@@ -31,7 +31,7 @@ def item_published(self, tweet):
31 31
         return tweet.sent
32 32
     
33 33
     def item_content(self, tweet):
34  
-        return {"type" : "html", }, linebreaks(escape(fmt_user(tweet.text)))
  34
+        return {"type" : "html", }, linebreaks(render_tweet_text(tweet))
35 35
     
36 36
     def item_links(self, tweet):
37 37
         return [{"href" : self.item_id(tweet)}]
1  microblogging/models.py
@@ -3,7 +3,6 @@
3 3
 from django.db import models
4 4
 from django.db.models.signals import post_save
5 5
 from django.core.urlresolvers import reverse
6  
-from django.utils.html import escape
7 6
 from django.utils.translation import ugettext_lazy as _
8 7
 
9 8
 from django.contrib.auth.models import User
17  microblogging/templatetags/microblogging_tags.py
... ...
@@ -1,8 +1,10 @@
1 1
 import re
2 2
 
3 3
 from django import template
4  
-from django.template.defaultfilters import stringfilter
5 4
 from django.core.urlresolvers import reverse
  5
+from django.template.defaultfilters import stringfilter
  6
+from django.utils.html import escape
  7
+from django.utils.safestring import mark_safe
6 8
 
7 9
 from django.contrib.contenttypes.models import ContentType
8 10
 
@@ -18,6 +20,13 @@ def make_user_link(text):
18 20
     return """@<a href="%s">%s</a>""" % (reverse("profile_detail", args=[username]), username)
19 21
 
20 22
 
  23
+@register.simple_tag
  24
+def render_tweet_text(tweet):
  25
+    text = escape(tweet.text)
  26
+    text = user_ref_re.sub(make_user_link, text)
  27
+    return mark_safe(text)
  28
+
  29
+
21 30
 @register.inclusion_tag('microblogging/listing.html', takes_context=True)
22 31
 def tweet_listing(context, tweets, prefix_sender, are_mine):
23 32
     request = context.get('request', None)
@@ -37,12 +46,6 @@ def sent_tweet_listing(context, user, prefix_sender, are_mine):
37 46
     return tweet_listing(context, tweets, prefix_sender, are_mine)
38 47
 
39 48
 
40  
-@register.filter
41  
-@stringfilter
42  
-def fmt_user(value):
43  
-    return user_ref_re.sub(make_user_link, value)
44  
-
45  
-
46 49
 @register.simple_tag
47 50
 def follower_count(user):
48 51
     followers = Following.objects.filter(

0 notes on commit 40b1b08

Please sign in to comment.
Something went wrong with that request. Please try again.