Browse Source

Add cache on view.
Fix rendering.

Fabs 10 years ago
parent
commit
36276d27d7
2 changed files with 4 additions and 1 deletions
  1. 1 1
      coin/templates/fragments/feed.html
  2. 3 0
      coin/views.py

+ 1 - 1
coin/templates/fragments/feed.html

@@ -4,7 +4,7 @@
         <div class="date">{{ entry.published_parsed.tm_mday }}/{{ entry.published_parsed.tm_mon }}/{{ entry.published_parsed.tm_year }}</div>
         <h5><a href="{{ entry.link }}" target="_blank">{{ entry.title }}</a></h5>
         <div class="intro">
-            {{ entry.summary|striptags|slice:":255" }}
+            {{ entry.summary|striptags|safe|truncatewords:50 }}
         </div>
     </div>
 {% endfor %}

+ 3 - 0
coin/views.py

@@ -1,5 +1,7 @@
 import feedparser
+import HTMLParser
 
+from django.views.decorators.cache import cache_page
 from django.template import RequestContext
 from django.shortcuts import render_to_response
 from django.http import HttpResponse
@@ -34,6 +36,7 @@ def feed_ffdn(request):
     return feed(request, feed_url, limit)
 
 
+@cache_page(60 * 60 * 24) # Cache 24h
 def feed(request, feed_url, limit):
     try:
         if feed_url: