diff options
author | luxagraf <sng@luxagraf.net> | 2022-12-30 10:16:59 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2022-12-30 10:16:59 -0600 |
commit | 35ac29dfe6d563f99664976d9c6897799d2dadde (patch) | |
tree | 868616a0bbba799f501129885e0a6d1f3f8e2beb | |
parent | 60bf1a8b71750b4423f36730a8e1d2c6093cd06a (diff) |
posts: reverted to calling them essays and redid a few things to make it
easier to see what's going on
-rw-r--r-- | app/posts/build.py | 4 | ||||
-rw-r--r-- | app/posts/models.py | 6 | ||||
-rw-r--r-- | app/posts/templates/posts/essay_detail.html (renamed from app/posts/templates/posts/note_detail.html) | 0 | ||||
-rw-r--r-- | app/posts/templates/posts/essay_list.html (renamed from app/posts/templates/posts/note_list.html) | 8 | ||||
-rw-r--r-- | app/posts/urls/essay_urls.py (renamed from app/posts/urls/notes_urls.py) | 12 | ||||
-rw-r--r-- | app/posts/views/essay_views.py | 54 | ||||
-rw-r--r-- | app/posts/views/guide_views.py | 42 | ||||
-rw-r--r-- | config/base_urls.py | 18 | ||||
-rw-r--r-- | templates/base.html | 2 |
9 files changed, 79 insertions, 67 deletions
diff --git a/app/posts/build.py b/app/posts/build.py index 8b4cee2..b49b925 100644 --- a/app/posts/build.py +++ b/app/posts/build.py @@ -114,11 +114,11 @@ class BuildJrnl(BuildNew): class BuildEssays(BuildNew): def get_model_queryset(self): - return self.model.objects.filter(post_type=PostType.NOTE).filter(status__exact=1).order_by('-pub_date') + return self.model.objects.filter(post_type=PostType.ESSAY).filter(status__exact=1).order_by('-pub_date') def build(self): self.build_list_view( - base_path=reverse("notes:list"), + base_path=reverse("essay-list:list"), paginate_by=50 ) self.build_detail_view() diff --git a/app/posts/models.py b/app/posts/models.py index 2cf17b7..9697f27 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -41,7 +41,7 @@ def get_upload_path(self, filename): class PostType(models.IntegerChoices): RANGE = 0, ('range') REVIEW = 1, ('review') - NOTE = 2, ('note') + ESSAY = 2, ('essay') SRC = 3, ('src') JRNL = 4, ('jrnl') FIELD_NOTE = 5, ('field note') @@ -104,8 +104,8 @@ class Post(models.Model): return self.title def get_absolute_url(self): - if self.post_type == PostType.NOTE: - return reverse('notes:detail', kwargs={"slug": self.slug}) + if self.post_type == PostType.ESSAY: + return reverse('essays:detail', kwargs={"slug": self.slug}) if self.post_type == PostType.RANGE: m = NewsletterMailing.objects.get(post__id=self.pk) return reverse('range:range-detail', kwargs={"issue": m.get_issue_str(), "slug": self.slug}) diff --git a/app/posts/templates/posts/note_detail.html b/app/posts/templates/posts/essay_detail.html index 455a024..455a024 100644 --- a/app/posts/templates/posts/note_detail.html +++ b/app/posts/templates/posts/essay_detail.html diff --git a/app/posts/templates/posts/note_list.html b/app/posts/templates/posts/essay_list.html index 559933c..6c9820d 100644 --- a/app/posts/templates/posts/note_list.html +++ b/app/posts/templates/posts/essay_list.html @@ -1,13 +1,13 @@ {% extends 'base.html' %} {% load typogrify_tags %} -{% block pagetitle %}Notes On Living - By Scott Gilbertson {% endblock %} -{% block metadescription %}Musings and stories on self-reliance, DIY ethics, repair, living well, Gods, stoicism, tools, walking and other ephemera.{% endblock %} +{% block pagetitle %}Notes and Essays On Living - By Scott Gilbertson {% endblock %} +{% block metadescription %}Essays and stories on self-reliance, DIY, repair, tools, birding, walking, living well, and other ephemera.{% endblock %} {% block breadcrumbs %}{% if breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{%endif%}{% endblock %} {% block primary %}<main class="archive-wrapper"> <div class="archive-intro"> - <h1 class="archive-sans">Notes</h1> + <h1 class="archive-sans">Notes & Essays</h1> <p><em>Être fort pour être utile</em></p> - <p>Some of the essays below have appeared elsewhere, but they live here now, along with all the newer stuff. Please feel free to email me or leave a comment, I'd love to hear your thoughts on the ideas explored here. Otherwise, please enjoy.</p> + <p>Essays and stories on self-reliance, DIY, repair, tools, birding, walking, living well, and other bric-à-brac. Please, enjoy.</p> </div> <ul class="archive-list">{% for object in object_list %} <li class="h-entry hentry archive-list-card archive-list-card-sm" itemscope itemType="http://schema.org/Article"> diff --git a/app/posts/urls/notes_urls.py b/app/posts/urls/essay_urls.py index 6fb9fa1..7eb872d 100644 --- a/app/posts/urls/notes_urls.py +++ b/app/posts/urls/essay_urls.py @@ -1,28 +1,28 @@ from django.urls import path, re_path -from ..views import guide_views as views +from ..views import essay_views as views -app_name = "notes" +app_name = "essays" urlpatterns = [ path( r'<str:slug>', - views.PostDetailView.as_view(), + views.EssayDetailView.as_view(), name="detail" ), path( r'<str:slug>.txt', - views.PostDetailViewTXT.as_view(), + views.EssayDetailViewTXT.as_view(), name="detail-txt" ), path( r'<int:page>/', - views.NotesListView.as_view(), + views.EssayListView.as_view(), name="list" ), path( r'', - views.NotesListView.as_view(), + views.EssayListView.as_view(), {'page':1}, name="list" ), diff --git a/app/posts/views/essay_views.py b/app/posts/views/essay_views.py new file mode 100644 index 0000000..ca1697f --- /dev/null +++ b/app/posts/views/essay_views.py @@ -0,0 +1,54 @@ +from django.views.generic import ListView +from django.views.generic.detail import DetailView +from django.contrib.syndication.views import Feed +from django.apps import apps +from django.conf import settings + +from utils.views import PaginatedListView, LuxDetailView + +from ..models import Post, PostType +from taxonomy.models import Category + + +class EssayListView(PaginatedListView): + model = Post + template_name = "posts/essay_list.html" + + def get_queryset(self): + queryset = super(EssayListView, self).get_queryset() + return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.ESSAY]).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'] = ('Essay',) + return context + + +class EssayDetailView(LuxDetailView): + model = Post + slug_field = "slug" + + def get_queryset(self): + queryset = super(EssayDetailView, self).get_queryset() + return queryset.select_related('location').prefetch_related('field_notes') + + def get_context_data(self, **kwargs): + context = super(EssayDetailView, self).get_context_data(**kwargs) + related = [] + for obj in self.object.related.all(): + model = apps.get_model(obj.model_name.app_label, obj.model_name.model) + related.append(model.objects.get(slug=obj.slug, pub_date=obj.pub_date)) + context['related'] = related + return context + + def get_template_names(self): + obj = self.get_object() + return ["posts/essay_detail.html"] + + +class EssayDetailViewTXT(EssayDetailView): + template_name = "posts/entry_detail.txt" diff --git a/app/posts/views/guide_views.py b/app/posts/views/guide_views.py index c5fdd55..346fcc7 100644 --- a/app/posts/views/guide_views.py +++ b/app/posts/views/guide_views.py @@ -58,48 +58,6 @@ class ReviewsListView(GuideListView): return context -class NotesListView(PaginatedListView): - model = Post - template_name = "posts/note_list.html" - - def get_queryset(self): - queryset = super(NotesListView, self).get_queryset() - return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.NOTE]).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(NotesListView, self).get_context_data(**kwargs) - context['breadcrumbs'] = ('Notes',) - return context - - - -class NoteDetailView(LuxDetailView): - model = Post - slug_field = "slug" - - def get_queryset(self): - queryset = super(EssayDetailView, self).get_queryset() - return queryset.select_related('location').prefetch_related('field_notes') - - def get_context_data(self, **kwargs): - context = super(EssayDetailView, self).get_context_data(**kwargs) - related = [] - for obj in self.object.related.all(): - model = apps.get_model(obj.model_name.app_label, obj.model_name.model) - related.append(model.objects.get(slug=obj.slug, pub_date=obj.pub_date)) - context['related'] = related - return context - - def get_template_names(self): - obj = self.get_object() - return ["posts/%s_detail.html" % obj.get_post_type_display(), 'posts/post_detail.html'] - - - class PostDetailView(LuxDetailView): model = Post slug_field = "slug" diff --git a/config/base_urls.py b/config/base_urls.py index ebe878e..610d245 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -49,15 +49,15 @@ urlpatterns = [ #path(r'expenses/', include('expenses.urls', namespace='expenses')), path(r'newsletter/', include('lttr.urls')), path(r'photos/', include('media.urls')), - path(r'review/', include('posts.urls.review_urls')), - re_path(r'^review/$', RedirectView.as_view(url='/reviews/')), - path(r'reviews/', include('posts.urls.review_urls', namespace='review-list')), - path(r'guide/', include('posts.urls.guide_urls')), - re_path(r'^guide/$', RedirectView.as_view(url='/guides/')), - path(r'guides/', include('posts.urls.guide_urls', namespace='guide-list')), - path(r'notes/', include('posts.urls.notes_urls')), - re_path(r'^note/$', RedirectView.as_view(url='/notes/')), - path(r'notes/', include('posts.urls.notes_urls', namespace='notes-list')), + #path(r'review/', include('posts.urls.review_urls')), + #re_path(r'^review/$', RedirectView.as_view(url='/reviews/')), + #path(r'reviews/', include('posts.urls.review_urls', namespace='review-list')), + #path(r'guide/', include('posts.urls.guide_urls')), + #re_path(r'^guide/$', RedirectView.as_view(url='/guides/')), + #path(r'guides/', include('posts.urls.guide_urls', namespace='guide-list')), + path(r'essay/', include('posts.urls.essay_urls')), + re_path(r'^essay/$', RedirectView.as_view(url='/essays/')), + path(r'essays/', include('posts.urls.essay_urls', namespace='essay-list')), path(r'range/', include('posts.urls.range_urls', namespace='range')), path(r'friends/', include('posts.urls.friends_urls', namespace='friends')), path(r'book-notes/', include('books.urls')), diff --git a/templates/base.html b/templates/base.html index 1a1fa9a..6816c84 100644 --- a/templates/base.html +++ b/templates/base.html @@ -29,7 +29,7 @@ </div> <nav> <a class="nav-item smcaps" href="{% url "jrnl:list" %}" title="Stories of life on the road.">Jrnl</a> - <a class="nav-item smcaps" href="/notes/" title="Notes">Notes</a> + <a class="nav-item smcaps" href="/essays/" title="Essays">Essays</a> <a class="nav-item smcaps" href="/friends/" title="Join the 'friends of a long year' newsletter">Friends</a> <a class="nav-item smcaps" href="/range/" title="Join the 'Range' newsletter">Range</a> <a class="nav-item smcaps" href="/about" title="About Scott">About</a> |