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. Cached Del.icio.us API Calls by jeffwheeler 6 years, 2 months ago
  2. load m2m fields objects by dirol 2 years, 11 months ago
  3. Generic CSV Export by zbyte64 4 years, 11 months ago
  4. Tags & filters for rendering search results by exogen 5 years, 1 month ago
  5. Recurse template tag for Django by Zarin 5 years, 3 months ago

Comments

(Forgotten your password?)