diff options
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/build.py | 4 | ||||
-rw-r--r-- | app/posts/models.py | 6 | ||||
-rw-r--r-- | app/posts/templates/posts/note_detail.html (renamed from app/posts/templates/posts/essay_detail.html) | 1 | ||||
-rw-r--r-- | app/posts/templates/posts/note_list.html (renamed from app/posts/templates/posts/essay_list.html) | 10 | ||||
-rw-r--r-- | app/posts/urls/notes_urls.py (renamed from app/posts/urls/essay_urls.py) | 6 | ||||
-rw-r--r-- | app/posts/views/guide_views.py | 36 |
6 files changed, 43 insertions, 20 deletions
diff --git a/app/posts/build.py b/app/posts/build.py index b49b925..8b4cee2 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.ESSAY).filter(status__exact=1).order_by('-pub_date') + return self.model.objects.filter(post_type=PostType.NOTE).filter(status__exact=1).order_by('-pub_date') def build(self): self.build_list_view( - base_path=reverse("essay-list:list"), + base_path=reverse("notes:list"), paginate_by=50 ) self.build_detail_view() diff --git a/app/posts/models.py b/app/posts/models.py index 9697f27..2cf17b7 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') - ESSAY = 2, ('essay') + NOTE = 2, ('note') 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.ESSAY: - return reverse('essays:detail', kwargs={"slug": self.slug}) + if self.post_type == PostType.NOTE: + return reverse('notes: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/essay_detail.html b/app/posts/templates/posts/note_detail.html index 9edcf45..455a024 100644 --- a/app/posts/templates/posts/essay_detail.html +++ b/app/posts/templates/posts/note_detail.html @@ -8,7 +8,6 @@ <link rel="canonical" href="https://luxagraf.net{{object.get_absolute_url}}" /> {% if object.has_code %} <link rel="stylesheet" href="/media/src/solarized.css" type="text/css" media="screen"/>{%endif %} {%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 %}<main> <article class="h-entry hentry entry-content content" itemscope itemType="http://schema.org/BlogPosting"> diff --git a/app/posts/templates/posts/essay_list.html b/app/posts/templates/posts/note_list.html index 2288e5b..1ad353e 100644 --- a/app/posts/templates/posts/essay_list.html +++ b/app/posts/templates/posts/note_list.html @@ -1,15 +1,15 @@ {% extends 'base.html' %} {% load typogrify_tags %} {% block pagetitle %}Notes to My Children - By Scott Gilbertson {% endblock %} -{% block metadescription %}Collected writing: essays, articles and stories on self-reliance, DIY, repair, living well, gods, magic, tools, walking and other ephemera.{% endblock %} +{% block metadescription %}Musings and stories on self-reliance, DIY ethics, repair, living well, Gods, stoicism, tools, walking 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"> - <h2 class="archive-hed">Note to My Children</h2> - <p>This started off as a place to collect things I was publishing with outlets like <em><a href="https://www.wired.com/author/scott-gilbertson/" rel="me">Wired</a></em>, <em><a href="https://arstechnica.com/">Ars Technica</a></em>, <em><a href="https://www.epicurious.com/contributors/scott-gilbertson" rel="me">Epicurious</a></em>, <em><a href="https://web.archive.org/web/20100904114555/http://one.longshotmag.com/article/going-for-seconds">Longshot Magazine</a></em> and the like. Then I started writing things people weren't as eager to publish. Strange times.</p> - <p>But I thought well, the internet archive is gathering all this up, I will write down things I'd like my kids to know, to be able to read when they're older and trying to figure things out. And here we are. </p> + <h2 class="archive-hed">Notes to My Children</h2> + <p>This started off as a place to collect things I was publishing in various magazines, and there are some of those below. But then the excitement of publishing elsewhere wore off. This is the web after all, why not just publish it myself? So I am.</p> + <p>But I thought, who really is the audience here? Most of what I write about these days I'd like my kids to know when they're older and trying to figure life out. Other people seem to enjoy these as well though. Please feel free to email me regarding them, I'd love to hear your thoughts. Otherwise, please enjoy.</p> </div> - <h1 class="archive-sans">Essays</h1> + <h1 class="archive-sans">Notes</h1> <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"> <span class="date dt-published card-smcaps">{{object.pub_date|date:"F Y"}}</span> diff --git a/app/posts/urls/essay_urls.py b/app/posts/urls/notes_urls.py index 3f0d7d7..6fb9fa1 100644 --- a/app/posts/urls/essay_urls.py +++ b/app/posts/urls/notes_urls.py @@ -2,7 +2,7 @@ from django.urls import path, re_path from ..views import guide_views as views -app_name = "essays" +app_name = "notes" urlpatterns = [ path( @@ -17,12 +17,12 @@ urlpatterns = [ ), path( r'<int:page>/', - views.EssayListView.as_view(), + views.NotesListView.as_view(), name="list" ), path( r'', - views.EssayListView.as_view(), + views.NotesListView.as_view(), {'page':1}, name="list" ), diff --git a/app/posts/views/guide_views.py b/app/posts/views/guide_views.py index aea91dd..c5fdd55 100644 --- a/app/posts/views/guide_views.py +++ b/app/posts/views/guide_views.py @@ -58,24 +58,48 @@ class ReviewsListView(GuideListView): return context -class EssayListView(PaginatedListView): +class NotesListView(PaginatedListView): model = Post - template_name = "posts/essay_list.html" + template_name = "posts/note_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') + 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(EssayListView, self).get_context_data(**kwargs) - context['breadcrumbs'] = ('Essays',) + 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" |