From 6e8b62d8c38f6ca366f240ea45ad738ebfd62943 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 27 Jan 2020 20:37:10 -0500 Subject: abstracted breadcrumbs into seperate template --- app/posts/templates/posts/essay_detail.html | 2 +- app/posts/templates/posts/essay_list.html | 12 ++++-------- app/posts/views.py | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'app/posts') diff --git a/app/posts/templates/posts/essay_detail.html b/app/posts/templates/posts/essay_detail.html index 8ffcfe5..23619d0 100644 --- a/app/posts/templates/posts/essay_detail.html +++ b/app/posts/templates/posts/essay_detail.html @@ -29,7 +29,7 @@ {%endblock%} {%block bodyid %}{% if object.get_post_type_display == 'tools' %}class="src"{% endif %}{%endblock%} - +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} {% block primary %}
diff --git a/app/posts/templates/posts/essay_list.html b/app/posts/templates/posts/essay_list.html index 271f83f..8a35225 100644 --- a/app/posts/templates/posts/essay_list.html +++ b/app/posts/templates/posts/essay_list.html @@ -3,16 +3,12 @@ {% block pagetitle %}Collected Essays of Scott Gilbertson {% endblock %} {% block metadescription %}Collected writing: essays, articles and stories on travel, photography, tools, walking, the natural world and other ephemera.{% endblock %} - -{% block primary %} -
+{% block breadcrumbs %}{% if breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{%endif%}{% endblock %} +{% block primary %}
-

My various articles and essays collected in one spot.

+

Essays & Articles

Topics include travel, writing, photography, free software, culture, and once, Del Taco.

-

Many essays below were previously published in: WIRED, Budget Travel, Ars Technica, Longshot Magazine, The Cost of Paper and elsewhere.

+

Some essays below were previously published in: WIRED, Budget Travel, Ars Technica, Epicurious, Longshot Magazine, The Cost of Paper and elsewhere.

Essays

    {% for object in object_list %} diff --git a/app/posts/views.py b/app/posts/views.py index fc85fa7..47c8c86 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -4,7 +4,7 @@ from django.contrib.syndication.views import Feed from django.apps import apps from django.conf import settings -from utils.views import PaginatedListView +from utils.views import PaginatedListView, LuxDetailView from .models import Post from taxonomy.models import Category @@ -40,8 +40,17 @@ class EssayListView(PostList): queryset = super(EssayListView, self).get_queryset() return queryset.filter(post_type__in=[2,]).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') + def get_context_data(self, **kwargs): + ''' + override for custom breadcrumb path + ''' + # Call the base implementation first to get a context + context = super(EssayListView, self).get_context_data(**kwargs) + context['breadcrumbs'] = ('Essays',) + return context -class PostDetailView(DetailView): + +class PostDetailView(LuxDetailView): model = Post slug_field = "slug" @@ -62,6 +71,7 @@ class PostDetailView(DetailView): obj = self.get_object() return ["posts/%s_detail.html" % obj.get_post_type_display(), 'posts/post_detail.html'] + class PostDetailViewTXT(PostDetailView): template_name = "posts/entry_detail.txt" -- cgit v1.2.3