Login

Delicious Tag

Author:
alcides
Posted:
June 23, 2008
Language:
Python
Version:
.96
Tags:
tag delicious
Score:
-5 (after 5 ratings)

Just add it in templatetags/delicious.py

In your template:

<h3>Del.icio.us</h3>

<ul class="list"> {% load delicious %} {% load_delicious_links %} {% for link in delicious_links %} <li><a href="{{link.link}}">{{link.title|safe}}</a></li> {% endfor %} </ul>

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from django.template import Library,Node

register = Library()

def load_delicious_links(parser, token):
    """
    {% get_user_profile %}
    """
    return DeliciousObject()

class DeliciousObject(Node):
    def render(self, context):
		
		try:
			import feedparser
			d = feedparser.parse('http://del.icio.us/rss/alcidesfonseca')
			delicious=[]
			for entry in d['entries'][:min(8,len(d['entries']))]:
				title=str(entry['title'].encode('ascii', 'xmlcharrefreplace'))
				delicious.append({'title':title,'link':str(entry['links'][0]['href'])})
		except:
			delicious=[]
	
		context['delicious_links'] = delicious
		return ""

register.tag('load_delicious_links', load_delicious_links)

More like this

  1. Tags & filters for rendering search results by exogen 7 years, 3 months ago
  2. Generic CSV Export by zbyte64 7 years ago
  3. Template filter that divides a list into exact columns by davmuz 3 years, 5 months ago
  4. IfValueTag by adurdin 8 years, 3 months ago
  5. Active page class for selected menu items by kunitoki 2 years, 9 months ago

Comments

Please login first before commenting.