Delicious Tag

 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. Active link by ronnie 2 months, 1 week ago
  2. Generic CSV Export by zbyte64 3 years, 8 months ago
  3. Tags & filters for rendering search results by exogen 3 years, 10 months ago
  4. Recurse template tag for Django by Zarin 4 years ago
  5. custom template tag sample by shinyzhu 1 year, 12 months ago

Comments

(Forgotten your password?)