1 from django.conf import settings
2 from blog.models import BlogEntry, BlogSection
5 def content_breadcrumb(request):
7 if path[0:len(settings.BLOG_ROOT)] == settings.BLOG_ROOT:
8 breadcrumb = [{'url': u'/', 'title': u'Home'}, {'url': settings.BLOG_ROOT, 'title': u'Blog'},]
10 path = path[len(settings.BLOG_ROOT):]
12 parts = path.split('/')
14 if parts[0] == "section":
15 # Just need to add the section title to the breadcrumb
16 section = BlogSection.objects.get(slug__exact=parts[1])
17 breadcrumb.append({'url': section.get_absolute_url(), 'title': section.title})
19 if len(parts) == 5 and \
20 parts[0].isdigit() and \
21 parts[1].isdigit() and \
23 # try getting the blog entry
25 entry = BlogEntry.objects.get(publish_date__year=int(parts[0]), publish_date__month=int(parts[1]), publish_date__day=int(parts[2]), slug__exact=parts[3])
26 breadcrumb.append({'url': entry.get_absolute_url(), 'title': entry.title})
28 breadcrumb.append({'url': 'nowhere', 'title': 'screwed'})
32 'content_breadcrumb': breadcrumb,