def blogroll(request, btype): """ View that handles the generation of blogrolls. """ response, site, cachekey, sfeeds_obj, sfeeds_ids = initview(request) if response: return response # for some reason this isn't working: # #response = render_to_response('feedjack/%s.xml' % btype, \ # fjlib.get_extra_content(site, sfeeds_ids)) #response.mimetype = 'text/xml; charset=utf-8' # # so we must use this: template = loader.get_template('feedjack/%s.xml' % btype) ctx = {} fjlib.get_extra_content(site, sfeeds_ids, ctx) ctx = Context(ctx) response = HttpResponse(template.render(ctx) , \ mimetype='text/xml; charset=utf-8') patch_vary_headers(response, ['Host']) fjcache.cache_set(site, cachekey, response) return response
def buildfeed(request, feedclass, tag=None, user=None): """ View that handles the feeds. """ response, site, cachekey, sfeeds_obj, sfeeds_ids = initview(request) if response: return response object_list = fjlib.get_paginator(site, sfeeds_ids, page=0, tag=tag, \ user=user)[1] feed = feedclass(\ title=site.title, link=site.url, description=site.description, feed_url='%s/%s' % (site.url, '/feed/rss/')) for post in object_list: feed.add_item( \ title = '%s: %s' % (post.feed.name, post.title), \ link = post.link, \ description = post.content, \ author_email = post.author_email, \ author_name = post.author, \ pubdate = post.date_modified, \ unique_id = post.link, \ categories = [tag.name for tag in post.tags.all()]) response = HttpResponse(mimetype=feed.mime_type) # per host caching patch_vary_headers(response, ['Host']) feed.write(response, 'utf-8') if site.use_internal_cache: fjcache.cache_set(site, cachekey, response) return response
def getcloud(site, feed_id=None): """ Returns the tag cloud for a site or a site's subscriber. """ cloudict = fjcache.cache_get(site.id, 'tagclouds') if not cloudict: cloudict = cloudata(site) fjcache.cache_set(site, 'tagclouds', cloudict) # A subscriber's tag cloud has been requested. if feed_id: feed_id = int(feed_id) if feed_id in cloudict: return cloudict[feed_id] return [] # The site tagcloud has been requested. return cloudict[0]
def mainview(request, tag=None, user=None): """ View that handles all page requests. """ response, site, cachekey, sfeeds_obj, sfeeds_ids = initview(request) if response: return response ctx = fjlib.page_context(request, site, tag, user, (sfeeds_obj, \ sfeeds_ids)) response = render_response(request, 'feedjack/%s/post_list.html' % \ (site.template), ctx) # per host caching, in case the cache middleware is enabled patch_vary_headers(response, ['Host']) if site.use_internal_cache: fjcache.cache_set(site, cachekey, response) return response