urlize twitter feed

This commit is contained in:
Sanj 2011-10-24 16:37:01 +01:00
parent 8a67c196d8
commit d7afdc59f5
2 changed files with 4 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import twitter
from django.template import RequestContext from django.template import RequestContext
from django import forms from django import forms
from django.forms.widgets import Textarea from django.forms.widgets import Textarea
from django.utils.html import urlize
class ContactForm(forms.Form): class ContactForm(forms.Form):
email = forms.EmailField() email = forms.EmailField()
@ -22,12 +23,12 @@ class ContactForm(forms.Form):
def index(request): def index(request):
try: try:
tApi = twitter.Api() tApi = twitter.Api()
statuses = tApi.GetUserTimeline(TWITTER_ID) statuses = tApi.GetUserTimeline(TWITTER_ID)[0:3]
except: except:
statuses = [] statuses = []
boxes = SliderBox.objects.all() boxes = SliderBox.objects.all()
return render_to_response("noel/index.html", RequestContext(request, { return render_to_response("noel/index.html", RequestContext(request, {
'tweets': statuses[0:5], 'tweets': [urlize(s.text) for s in statuses],
'boxes': boxes 'boxes': boxes
})) }))

View File

@ -40,7 +40,7 @@
<div id="contentTab"> <div id="contentTab">
<ul> <ul>
{% for t in tweets %} {% for t in tweets %}
<li>{{ t.text }}</li> <li>{{ t|safe }}</li>
{% endfor %} {% endfor %}
<!-- <!--
<li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li> <li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li>