Changeset 15

Show
Ignore:
Timestamp:
11/05/07 19:38:53 (10 months ago)
Author:
simon
Message:

Added an Atom feed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bitstructures/trunk/css/bitstructures.css

    r14 r15  
    8484} 
    8585 
     86a.subscribe { 
     87        color: #da5800; 
     88} 
     89 
    8690a:hover { 
    8791        text-decoration: underline; 
  • bitstructures/trunk/substructure/urls.py

    r7 r15  
    55    (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[a-z0-9-]+)$', 
    66        'bitstructures.substructure.views.entry_page'), 
    7     (r'^drafts/(?P<slug>[a-z0-9-]+)$', 'bitstructures.substructure.views.draft_page') 
     7    (r'^drafts/(?P<slug>[a-z0-9-]+)$', 'bitstructures.substructure.views.draft_page'), 
     8    (r'^atom.xml$', 'bitstructures.substructure.views.atom_feed') 
    89) 
  • bitstructures/trunk/substructure/views.py

    r7 r15  
    1 from django.http import Http404 
     1from django.http import Http404, HttpResponse 
    22from django.shortcuts import get_object_or_404, render_to_response 
     3from django.template import Context, loader 
     4from django.contrib.sites.models import Site 
    35from bitstructures.substructure.models import Entry 
    46import bitstructures.settings 
     
    3133    return render_to_response('substructure/entry_page.html', data) 
    3234 
     35def atom_feed(request): 
     36    t = loader.get_template('substructure/atom_feed.xml') 
     37    current_site = Site.objects.get_current() 
     38    entry_list = Entry.objects.filter(date_published__isnull=False).order_by('-date_published') 
     39    c = Context({ 
     40        'site_name': current_site.name, 
     41        'site_domain': current_site.domain, 
     42        'entry_list': entry_list 
     43    }) 
     44    if len(entry_list) > 0: 
     45        c['most_recent_date_published'] = entry_list[0].date_published 
     46    return HttpResponse(t.render(c), mimetype='application/atom+xml') 
     47 
    3348def get_context_data(request): 
    3449    data = { 'MEDIA_URL': bitstructures.settings.MEDIA_URL } 
  • bitstructures/trunk/templates/substructure/base.html

    r14 r15  
    66<head> 
    77<title>{% block title %}Bitstructures{% endblock %}</title> 
    8 <link rel="stylesheet" href="{{ MEDIA_URL }}css/bitstructures.css" type="text/css"> 
     8<link rel="alternate" type="application/atom+xml" href="/atom.xml"> 
     9<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/bitstructures.css"> 
    910</head> 
    1011 
     
    3435the <a href="http://dojotoolkit.org/">Dojo</a> JavaScript toolkit.</p> 
    3536<p><a href="http://del.icio.us/simonbates">del.icio.us/simonbates</a></p> 
     37<p><a class="subscribe" href="/atom.xml">Subscribe <img src="{{ MEDIA_URL }}images/feed-icon-14x14.png" alt="Subscribe"></a></p> 
    3638</div> 
    3739