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/books/templates/books/book_detail.html | 62 ++++++ app/books/templates/books/book_list.html | 53 +++++ app/books/views.py | 7 +- .../templates/fieldnotes/fieldnote_detail.html | 11 +- .../templates/fieldnotes/fieldnote_list.html | 9 +- app/fieldnotes/urls.py | 2 +- app/fieldnotes/views.py | 5 +- app/jrnl/models.py | 19 +- app/jrnl/templates/jrnl/entry_detail.html | 240 +++++++++++++++++++++ app/jrnl/templates/jrnl/entry_detail.txt | 8 + app/jrnl/templates/jrnl/entry_list.html | 33 +++ app/jrnl/views.py | 4 + app/locations/admin.py | 3 +- .../migrations/0025_auto_20191230_0738.py | 23 ++ app/locations/migrations/0026_walk_subtitle.py | 18 ++ app/locations/models.py | 11 +- app/locations/templates/locations/walk_detail.html | 76 +++++++ app/locations/templates/locations/walk_list.html | 40 ++++ app/locations/urls.py | 5 + app/locations/views.py | 26 ++- app/locations/walk_urls.py | 24 +++ app/pages/templates/pages/page_detail.html | 37 ++++ app/pages/templates/pages/page_detail.txt | 8 + app/pages/urls.py | 13 ++ app/pages/views.py | 11 +- app/posts/templates/posts/essay_detail.html | 2 +- app/posts/templates/posts/essay_list.html | 12 +- app/posts/views.py | 14 +- app/src/templates/src/srcpost_detail.html | 112 ++++++++++ app/src/templates/src/srcpost_list.html | 30 +++ app/src/templates/src/topic_list.html | 35 +++ app/src/urls.py | 12 +- app/src/views.py | 5 +- app/utils/views.py | 54 ++++- config/base_urls.py | 7 +- design/templates/archives/books.html | 58 ----- design/templates/base.html | 1 + design/templates/details/book.html | 66 ------ design/templates/details/note.html | 22 +- design/templates/details/page.html | 42 ---- design/templates/details/page.txt | 8 - design/templates/jrnl/entry_detail.html | 240 --------------------- design/templates/jrnl/entry_detail.txt | 8 - design/templates/jrnl/entry_list.html | 40 ---- design/templates/lib/breadcrumbs.html | 14 ++ design/templates/src/post_detail.html | 104 --------- design/templates/src/post_list.html | 36 ---- design/templates/src/topic_list.html | 35 --- 48 files changed, 1008 insertions(+), 697 deletions(-) create mode 100644 app/books/templates/books/book_detail.html create mode 100644 app/books/templates/books/book_list.html create mode 100644 app/jrnl/templates/jrnl/entry_detail.html create mode 100644 app/jrnl/templates/jrnl/entry_detail.txt create mode 100644 app/jrnl/templates/jrnl/entry_list.html create mode 100644 app/locations/migrations/0025_auto_20191230_0738.py create mode 100644 app/locations/migrations/0026_walk_subtitle.py create mode 100644 app/locations/templates/locations/walk_detail.html create mode 100644 app/locations/templates/locations/walk_list.html create mode 100644 app/locations/walk_urls.py create mode 100644 app/pages/templates/pages/page_detail.html create mode 100644 app/pages/templates/pages/page_detail.txt create mode 100644 app/pages/urls.py create mode 100644 app/src/templates/src/srcpost_detail.html create mode 100644 app/src/templates/src/srcpost_list.html create mode 100644 app/src/templates/src/topic_list.html delete mode 100644 design/templates/archives/books.html delete mode 100644 design/templates/details/book.html delete mode 100644 design/templates/details/page.html delete mode 100644 design/templates/details/page.txt delete mode 100644 design/templates/jrnl/entry_detail.html delete mode 100644 design/templates/jrnl/entry_detail.txt delete mode 100644 design/templates/jrnl/entry_list.html create mode 100644 design/templates/lib/breadcrumbs.html delete mode 100644 design/templates/src/post_detail.html delete mode 100644 design/templates/src/post_list.html delete mode 100644 design/templates/src/topic_list.html diff --git a/app/books/templates/books/book_detail.html b/app/books/templates/books/book_detail.html new file mode 100644 index 0000000..99d5b9d --- /dev/null +++ b/app/books/templates/books/book_detail.html @@ -0,0 +1,62 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{%block bodyid%}class="detail"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs_detail.html" with breadcrumbs=breadcrumbs %}{% endblock %} + {% block primary %}
+
+

{{object.title|smartypants|widont|safe}}

+ + + +
+
+ {{object.title}} cover +
+
+ +
+ {% if object.isbn %}Borrow{%endif%} + {% if object.afflink %}Buy{%endif%} +
+
{%if object.body_html%} +
+
Notes
+ {{object.rating}} + + +
{{object.body_html|safe|smartypants|widont}}
+
{%endif%} + {% if object.bookhighlight_set.all %} +
+

Highlights:

+ {% for object in object.bookhighlight_set.all %} +
+ +
+ {{object.body_html|safe|amp|smartypants}} +
+

– Page: {{object.page}} {% if object.location %}(Kindle location: {{object.location|cut:"["|cut:"]"}}){%endif%}

+
+ {% endfor %} +
+ {%endif%} +
+{% endblock %} +{% block disclaimer %} +
+

When you buy a book using the link above, I may earn a small affiliate commission.

+
+{% endblock %} diff --git a/app/books/templates/books/book_list.html b/app/books/templates/books/book_list.html new file mode 100644 index 0000000..96d4d1b --- /dev/null +++ b/app/books/templates/books/book_list.html @@ -0,0 +1,53 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %} Books | luxagraf {% endblock %} +{% block metadescription %}Books I've read and thoughts on them. {% endblock %} +{%block bodyid%}class="archive" id="books-archive"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}
{% autopaginate object_list 24 %} +

Books

+
+

I wear glasses because as a child I would stay up late, covers pulled over my head, reading by the dim light of a dying flashlight. At least that's what an eye doctor told me when I was younger. Probably a load of crap, but I still love reading and I still often do it by poor light far later in the night than is reasonable.

+

I've always taken notes while reading, usually with a pen and paper, but sometimes as highlights in the Kindle. And of course since I have all this stuff in text files I thought might as well put it online. So here you have it, books I've read and things I've thought about them.

+
+ +
{% for object in object_list %} +
+ {% if object.image %}
cover art for {{object.title}} by {{object.author_name}}
{%endif%} +

{{object.title|amp|smartypants|widont|safe}}

+ +
+ {% if object.rating %}{% for i in object.ratings_range %}{% if i <= object.get_rating%}★{%else%}☆{%endif%}{%endfor%}{%endif%} + + Read in: {{object.read_date|date:"F Y"}}
+
+ {% endfor %}
+ +
+{% endblock %} + + + title = models.CharField(max_length=200) + author_name = models.CharField(max_length=200) + slug = models.CharField(max_length=50) + year_pub = models.CharField(max_length=4, blank=True, null=True) + read_date = models.DateTimeField() + isbn = models.CharField(max_length=100, blank=True, null=True) + body_html = models.TextField(null=True, blank=True) + url = models.CharField(max_length=200, blank=True, null=True) + tags = TaggableManager() + RATINGS = ( + ('1', "1 Star"), + ('2', "2 Stars"), + ('3', "3 Stars"), + ('4', "4 Stars"), + ('5', "5 Stars"), + ) + rating = models.CharField(max_length=1, choices=RATINGS, null=True) + enable_comments = models.BooleanField(default=False) + image = models.FileField(upload_to='book-covers/', null=True, blank=True) + diff --git a/app/books/views.py b/app/books/views.py index e829476..bf09996 100644 --- a/app/books/views.py +++ b/app/books/views.py @@ -1,17 +1,16 @@ from django.views.generic.detail import DetailView -from utils.views import PaginatedListView +from utils.views import PaginatedListView, LuxDetailView from .models import Book class BookListView(PaginatedListView): - template_name = 'archives/books.html' + model = Book def get_queryset(self): return Book.objects.filter(is_public=True).order_by('-read_date').select_related() -class BookDetailView(DetailView): +class BookDetailView(LuxDetailView): model = Book - template_name = "details/book.html" slug_field = "slug" diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html index dc90e16..0d25108 100644 --- a/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html @@ -13,15 +13,8 @@ {%endblock%} {% block bodyid %}class="notes--permalin detail" id="archive-{% if month %}{{month|month_number_to_name}}{%endif%}{{year}}"{%endblock%} - - -{% block primary %} -
+{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}

{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|safe}}{%endif%}

diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html index c201382..5ee6f06 100644 --- a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html @@ -5,13 +5,8 @@ {% block pagetitle %} Field Notes | luxagraf {% endblock %} {% block metadescription %}Rough notes and sketches from the field {% endblock %} {%block bodyid%}id="field-notes"{%endblock%} - -{% block primary %} - -
+{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}

Field Notes

Quick notes, sketches and images from the road. This is the semi-orgnized brain dump that comes before the more organized journal entries and essays. If I used social media this is the stuff I'd probably put there, but I prefer to put it here, even if it means a lot fewer people read it.

diff --git a/app/fieldnotes/urls.py b/app/fieldnotes/urls.py index f3ef944..85ee710 100644 --- a/app/fieldnotes/urls.py +++ b/app/fieldnotes/urls.py @@ -2,7 +2,7 @@ from django.urls import path, re_path from . import views -app_name = "fieldnotes" +app_name = "field notes" urlpatterns = [ re_path( diff --git a/app/fieldnotes/views.py b/app/fieldnotes/views.py index fefd138..9b49cc0 100644 --- a/app/fieldnotes/views.py +++ b/app/fieldnotes/views.py @@ -1,19 +1,20 @@ from django.views.generic.dates import YearArchiveView, MonthArchiveView from django.views.generic.detail import DetailView -from utils.views import PaginatedListView +from utils.views import PaginatedListView, LuxDetailView from .models import FieldNote class FieldNoteListView(PaginatedListView): + model = FieldNote """ Return a list of Notes in reverse chronological order """ queryset = FieldNote.objects.filter(status=1).order_by('-pub_date') -class FieldNoteDetailView(DetailView): +class FieldNoteDetailView(LuxDetailView): model = FieldNote slug_field = "slug" diff --git a/app/jrnl/models.py b/app/jrnl/models.py index dda9d6d..f3734da 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -273,14 +273,17 @@ def cache_gravatar(sender, comment, **kwargs): urllib.request.urlretrieve(url, local_grav) -#@receiver(post_save, sender=Entry) -#def post_save_events(sender, update_fields, created, instance, **kwargs): -# related, created = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id) -# related.title = instance.title -# related.slug = instance.slug -# post_save.disconnect(post_save_events, sender=Entry) -# instance.save() -# post_save.connect(post_save_events, sender=Entry) +@receiver(post_save, sender=Entry) +def post_save_events(sender, update_fields, created, instance, **kwargs): + """ + Creates a generic related entry when a new post is added + """ + if created: + related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pubdate) + if c: + related.title = instance.title + related.slug = instance.slug + related.save() # from django_comments.signals import comment_will_be_posted # from django_comments import akismet diff --git a/app/jrnl/templates/jrnl/entry_detail.html b/app/jrnl/templates/jrnl/entry_detail.html new file mode 100644 index 0000000..0904178 --- /dev/null +++ b/app/jrnl/templates/jrnl/entry_detail.html @@ -0,0 +1,240 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} + +{% block pagetitle %}{{object.title|title|smartypants|safe}} - by Scott Gilbertson{% endblock %} + +{% block metadescription %}{% autoescape on %}{{object.meta_description|striptags|safe}}{% endautoescape %}{% endblock %} +{%block extrahead%} + + + + + + + + + + + + + + + + + + + + + + +{%endblock%} +{%block htmlclass%}{% with object.template_name as t %} +class="detail {%if t == 1 or t == 3 or t == 5 %}double{%else%}single{%endif%}{%if t == 2 or t == 3 %} dark{%endif%}{%if t == 4 or t == 5 %} black{%endif%}"{%endwith%}{%endblock%} + + {% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %} +
+
+
+

{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|safe}}{%endif%}

+ {% if object.subtitle %}

{{object.subtitle|smartypants|safe}}

{%endif%} +
+ {% if object.location %}
+

{% if object.location.country_name == "United States" %}{{object.location.name|smartypants|safe}}, {{object.location.state_name|safe}}, U.S.{%else%}{{object.location.name|smartypants|safe}}, {{object.location.country_name|safe}}{%endif%}

+ – Map +
{%endif%} + + +
+
+
+ {{object.body_html|safe|smartypants}} +
+ {%if wildlife or object.field_notes.all or object.books.all %}{%endif%} +
+ {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + + {% if object.related.all %}
+ +
{%endif%} + + {% comment %}
+
If you enjoyed this, you should join the mailing list…
+ {% include 'mailing_list.html' %} +
{% endcomment %} + {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} +

{{comment_count}} Comment{{ comment_count|pluralize }}

+{% render_comment_list for object %} +{%endif%} +
+{% render_comment_form for object %} +
+{% else %} +

Sorry, comments have been disabled for this post.

+{%endif%} +
+{% endblock %} +{% block js %} + +{%endblock%} diff --git a/app/jrnl/templates/jrnl/entry_detail.txt b/app/jrnl/templates/jrnl/entry_detail.txt new file mode 100644 index 0000000..547ce79 --- /dev/null +++ b/app/jrnl/templates/jrnl/entry_detail.txt @@ -0,0 +1,8 @@ +{{object.title|safe}} +{% for letter in object.title %}={%endfor%} + + by Scott Gilbertson + <{{SITE_URL}}{{object.get_absolute_url}}> + {{object.pub_date|date:"l, d F Y"}} + +{{object.body_markdown|safe}} diff --git a/app/jrnl/templates/jrnl/entry_list.html b/app/jrnl/templates/jrnl/entry_list.html new file mode 100644 index 0000000..6eefe10 --- /dev/null +++ b/app/jrnl/templates/jrnl/entry_list.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load pagination_tags %} +{% block pagetitle %}Luxagraf | {% if region %}Travel Writing from {{region.name|title|smartypants|safe}}{%else%}Travel Writing from Around the World {%endif%}{% if page != "1" %} -- Page {{page}}{%endif%}{% endblock %} +{% block metadescription %}{% if region %}Travel writing, essays and dispatches from {{region.name|title|smartypants|safe}}{%else%}Travel writing, essays and dispatches from around the world{%endif%} Page {{page}}{% endblock %} +{%block bodyid%}id="writing" class="archive"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}
+

{% if region %}Journal entries from {%if region.name == 'United States'%}the United States{%else%}{{region.name|title|smartypants|safe}}{%endif%}{%else%}Journal {%endif%}

{% autopaginate object_list 24 %} {% for object in object_list %} +
+
+ {% if object.featured_image %} + {% include "lib/img_archive.html" with image=object.featured_image %} + {%else%} + {{ object.title }}{%endif%} +
+

{{object.title|safe|smartypants|widont}}

+ + +

+ + {% if object.location.country_name == "United States" %}{{object.location.name|smartypants|safe}}, {{object.location.state_name}}, U.S.{%else%}{{object.location.name|smartypants|safe}}, {{object.location.country_name}}{%endif%} + – + + {{object.dek|safe}} + +

+
{% endfor %} +
+ +{% endblock %} diff --git a/app/jrnl/views.py b/app/jrnl/views.py index 1b38de9..6b7cc8d 100644 --- a/app/jrnl/views.py +++ b/app/jrnl/views.py @@ -1,6 +1,7 @@ from django.views.generic import ListView from django.views.generic.detail import DetailView from django.views.generic.dates import DateDetailView +from django.urls import reverse from django.views.generic.dates import YearArchiveView, MonthArchiveView from django.contrib.syndication.views import Feed from django.apps import apps @@ -31,6 +32,7 @@ class EntryCountryList(PaginatedListView): """ Return a list of Entries by Country in reverse chronological order """ + model = Entry def get_context_data(self, **kwargs): # Call the base implementation first to get a context @@ -102,6 +104,8 @@ class EntryDetailView(DateDetailView): 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 + context['breadcrumbs'] = ("jrnl",) + context['crumb_url'] = reverse('jrnl:list') return context diff --git a/app/locations/admin.py b/app/locations/admin.py index 0e78948..4beca5b 100644 --- a/app/locations/admin.py +++ b/app/locations/admin.py @@ -300,9 +300,10 @@ class WalkAdmin(OLAdminBase): ('Region', { 'fields': ( ('title', 'rating'), + 'subtitle', 'body_markdown', ('date_walked', 'slug'), - 'distance', + ('distance', 'duration'), 'gpx_file', 'point', ), diff --git a/app/locations/migrations/0025_auto_20191230_0738.py b/app/locations/migrations/0025_auto_20191230_0738.py new file mode 100644 index 0000000..3dd9093 --- /dev/null +++ b/app/locations/migrations/0025_auto_20191230_0738.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.2 on 2019-12-30 07:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('locations', '0024_auto_20191229_1817'), + ] + + operations = [ + migrations.AddField( + model_name='walk', + name='duration', + field=models.DecimalField(decimal_places=0, help_text='in minutes', max_digits=3, null=True), + ), + migrations.AlterField( + model_name='walk', + name='distance', + field=models.DecimalField(decimal_places=2, max_digits=3, null=True), + ), + ] diff --git a/app/locations/migrations/0026_walk_subtitle.py b/app/locations/migrations/0026_walk_subtitle.py new file mode 100644 index 0000000..e5aae3f --- /dev/null +++ b/app/locations/migrations/0026_walk_subtitle.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.2 on 2020-01-22 10:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('locations', '0025_auto_20191230_0738'), + ] + + operations = [ + migrations.AddField( + model_name='walk', + name='subtitle', + field=models.CharField(blank=True, max_length=200), + ), + ] diff --git a/app/locations/models.py b/app/locations/models.py index e9eb047..6f598b2 100644 --- a/app/locations/models.py +++ b/app/locations/models.py @@ -469,6 +469,7 @@ def parse_gpx(gpx_obj, gpx_data): class Walk(models.Model): title = models.CharField(max_length=300) + subtitle = models.CharField(max_length=200, blank=True) slug = models.SlugField() body_markdown = models.TextField() body_html = models.TextField(blank=True) @@ -484,11 +485,19 @@ class Walk(models.Model): ('5', "5 Stars"), ) rating = models.CharField(max_length=1, choices=RATINGS, null=True, blank=True) - distance = models.DecimalField(max_digits=3, decimal_places=1, null=True) + distance = models.DecimalField(max_digits=3, decimal_places=2, null=True) + duration = models.DecimalField(max_digits=3, decimal_places=0, null=True, help_text="in minutes") def __str_(self): return self.title + def get_rating(self): + return int(self.rating) + + @property + def ratings_range(cls): + return range(1, 6) + def save(self, *args, **kwargs): created = self.pk is None if not created: diff --git a/app/locations/templates/locations/walk_detail.html b/app/locations/templates/locations/walk_detail.html new file mode 100644 index 0000000..f36a507 --- /dev/null +++ b/app/locations/templates/locations/walk_detail.html @@ -0,0 +1,76 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{%block bodyid%}class="detail"{%endblock%} +{% block primary %} +
+
+
+

{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|safe}}{%endif%}

+ {% if object.subtitle %}

{{object.subtitle|smartypants|safe}}

{%endif%} +
+ {% if object.location %}
+

{% if object.location.country_name == "United States" %}{{object.location.name|smartypants|safe}}, {{object.location.state_name|safe}}, U.S.{%else%}{{object.location.name|smartypants|safe}}, {{object.location.country_name|safe}}{%endif%}

+
{%endif%} + + +
+
+ {{object.title}} map + +
+ +
+
Notes
+ {{object.body_html|safe|smartypants}} +
+ + {%if wildlife %}
+ {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + +
+{% endblock %} diff --git a/app/locations/templates/locations/walk_list.html b/app/locations/templates/locations/walk_list.html new file mode 100644 index 0000000..28d86ec --- /dev/null +++ b/app/locations/templates/locations/walk_list.html @@ -0,0 +1,40 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %}Walks.{% endblock %} +{% block metadescription %}{% endblock %} +{% block breadcrumbs %}{% endblock %} +{% block primary %}
+
+

Walks

+

Walks, hikes, forays, whatever you wish to call them.

+

Walking is [meditation](/meditation), particularly the discursive meditation I practice. So this is not so much a record of physical activity as mental. If you're looking for awesome hikes, there might be some in here, but don't expect details. That's not what I'm interested in recording.

+

+

Walks

+ {% autopaginate object_list 30 %} + +
+{%endblock%} diff --git a/app/locations/urls.py b/app/locations/urls.py index 5faefc1..ee98b17 100644 --- a/app/locations/urls.py +++ b/app/locations/urls.py @@ -5,6 +5,11 @@ from . import views app_name = "locations" urlpatterns = [ + path( + r'', + views.WalkDetail.as_view(), + name="walk-detail" + ), path( r'///', views.LocationDetail.as_view(), diff --git a/app/locations/views.py b/app/locations/views.py index 3a93c0d..48ecc07 100644 --- a/app/locations/views.py +++ b/app/locations/views.py @@ -8,8 +8,8 @@ from django.db.models import Q from jrnl.models import Entry from projects.shortcuts import render_to_geojson from sightings.models import Sighting - -from .models import Country, Region, Route, Location +from utils.views import PaginatedListView +from .models import Country, Region, Route, Location, Walk def map_list(request): context = { @@ -99,3 +99,25 @@ class LocationDetail(DetailView): Q(location__in=Location.objects.filter(parent=self.get_object())) ).order_by('ap_id', 'ap__apclass__kind').distinct("ap") return context + + +class WalkDetail(DetailView): + model = Walk + + def get_context_data(self, **kwargs): + context = super(WalkDetail, self).get_context_data(**kwargs) + context['entry_list'] = Entry.objects.filter( + Q(location=self.get_object().location) | + Q(location__in=Location.objects.filter(parent=self.get_object().location)) + ) + context['wildlife'] = Sighting.objects.filter( + Q(location=self.get_object().location) | + Q(location__in=Location.objects.filter(parent=self.get_object().location)) + ).order_by('ap_id', 'ap__apclass__kind').distinct("ap") + return context + +class WalkList(PaginatedListView): + """ + Return list of Walks + """ + model = Walk diff --git a/app/locations/walk_urls.py b/app/locations/walk_urls.py new file mode 100644 index 0000000..4019ef6 --- /dev/null +++ b/app/locations/walk_urls.py @@ -0,0 +1,24 @@ +from django.urls import path, re_path + +from . import views + +app_name = "walks" + +urlpatterns = [ + path( + r'', + views.WalkDetail.as_view(), + name="walk-detail" + ), + re_path( + r'^(?P\d+)/$', + views.WalkList.as_view(), + name="walk-list" + ), + re_path( + r'', + views.WalkList.as_view(), + {'page':1}, + name="walk-list" + ), +] diff --git a/app/pages/templates/pages/page_detail.html b/app/pages/templates/pages/page_detail.html new file mode 100644 index 0000000..4644386 --- /dev/null +++ b/app/pages/templates/pages/page_detail.html @@ -0,0 +1,37 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} +{% block pagetitle %}Luxagraf | {{object.title}}{% endblock %} +{% block metadescription %}{{object.meta_description}}{% endblock %} +{%block htmlclass%}class="detail"{%endblock%} +{%block bodyid%}id="{{object.title|slugify}}"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}
+
+
+

{{object.title}}

+ {%if object.sub_title %}

{{object.sub_title}}

{%endif%} +
+
+ {{object.body_html|safe|smartypants|widont}} +
+
+ {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} +

{{comment_count}} Comment{{ comment_count|pluralize }}

+{% render_comment_list for object %} +{%endif%} +
+{% render_comment_form for object %} +
+{%endif%} +
+{% endblock %} +{% block js %} + + +{% endblock %} + + diff --git a/app/pages/templates/pages/page_detail.txt b/app/pages/templates/pages/page_detail.txt new file mode 100644 index 0000000..547ce79 --- /dev/null +++ b/app/pages/templates/pages/page_detail.txt @@ -0,0 +1,8 @@ +{{object.title|safe}} +{% for letter in object.title %}={%endfor%} + + by Scott Gilbertson + <{{SITE_URL}}{{object.get_absolute_url}}> + {{object.pub_date|date:"l, d F Y"}} + +{{object.body_markdown|safe}} diff --git a/app/pages/urls.py b/app/pages/urls.py new file mode 100644 index 0000000..c40eee0 --- /dev/null +++ b/app/pages/urls.py @@ -0,0 +1,13 @@ +from django.urls import path, re_path + +from . import views + +app_name = "pages" + +urlpatterns = [ + path( + r'', + views.PageDetailView.as_view(), + name="detail" + ), +] diff --git a/app/pages/views.py b/app/pages/views.py index 8431bc2..bef6529 100644 --- a/app/pages/views.py +++ b/app/pages/views.py @@ -1,12 +1,15 @@ -from django.views.generic.detail import DetailView +from utils.views import LuxDetailView from .models import Page -class PageDetailView(DetailView): +class PageDetailView(LuxDetailView): model = Page - slug_field = "slug" def get_template_names(self): obj = self.get_object() - return ["details/%s.html" % obj.slug, 'details/page.html'] + return ["pages/%s.html" % obj.slug, 'pages/page_detail.html'] + +class PageDetailTXTView(LuxDetailView): + model = Page + slug_field = "slug" 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" diff --git a/app/src/templates/src/srcpost_detail.html b/app/src/templates/src/srcpost_detail.html new file mode 100644 index 0000000..2ad4e26 --- /dev/null +++ b/app/src/templates/src/srcpost_detail.html @@ -0,0 +1,112 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} +{% block pagetitle %}{{object.title|striptags}} - by Scott Gilbertson{% endblock %} +{% block metadescription %}{% autoescape on %}{{object.meta_description|striptags|safe}}{% endautoescape %}{% endblock %} +{%block extrahead%} + + + + + + + + + + + + + + +{%endblock%} + +{% block bodyid %}class="src detail single"{% endblock %} +{%block sitesubtitle %}Code Slowly{% endblock%} +{% block breadcrumbs %}{% endblock %} +{% block primary %}
    +
    +
    +

    {%if object.template_name == 1 or object.template_name == 3 %}{{object.title|safe|smartypants}}{%else%}{{object.title|safe|smartypants|widont}}{%endif%}

    +

    {{object.meta_description|smartypants|safe}}

    +
    + {% if object.originally_published_by %}

    Originally Published By: {{object.originally_published_by}}

    {%endif%} + {% if object.topics.all %}

    Topics: {% for topic in object.topics.all%} {{topic.name}}{%if forloop.last%}{%else%}, {%endif%}{%endfor%}

    {%endif%} + + +
    +
    + + +
    + {{object.body_html|safe|smartypants|widont}} +
    +
    + {% if object.slug != 'about' %} + {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + {%endwith%}{%endwith%} + {%endif%} +
    + {% if object.slug != 'about' %} + {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} +

    {{comment_count}} Comment{{ comment_count|pluralize }}

    +{% render_comment_list for object %} +{%endif%} +
    +{% render_comment_form for object %} +
    +{% else %} +

    Sorry, comments have been disabled for this post.

    +{%endif%} +{%endif%} +{% endblock %} +{% block js %} + +{% if object.has_code %} +{%endif %} +{% endblock %} diff --git a/app/src/templates/src/srcpost_list.html b/app/src/templates/src/srcpost_list.html new file mode 100644 index 0000000..dd5d410 --- /dev/null +++ b/app/src/templates/src/srcpost_list.html @@ -0,0 +1,30 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} + +{% block pagetitle %}Tutorials and tools for building great things{% endblock %} +{% block metadescription %}Tutorials and tools for building great things on the web - by Scott Gilbertson.{% endblock %} +{%block sitesubtitle %}Code Slowly{% endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}
    +
    +

    Tutorials and tools for building great things on the web.

    +

    The indie web is an amazing democratic publishing platform unlike anything in history. The catch is, to avoid serving at the pleasure of the corporate king, you need to know how to publish. That's what these articles are here for, to help you learn how to use independent, community supported open source tools. The web won't last forever, let's build something cool while we can.

    +

    Topics include HTML, CSS, Django, Linux, Nginx, Python, Postgresql, free software, and, once, the evil that is Google AMP.

    +

    A few of the articles below were previously published in: Ars Technica, Wired, and The Register

    +
    +

    Articles

    + + + + +
    +{%endblock%} diff --git a/app/src/templates/src/topic_list.html b/app/src/templates/src/topic_list.html new file mode 100644 index 0000000..7149823 --- /dev/null +++ b/app/src/templates/src/topic_list.html @@ -0,0 +1,35 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} + +{% block pagetitle %}Tutorials and tools for building great things{% endblock %} + +{% block metadescription %}Tutorials about {{topic}} - by Scott Gilbertson.{% endblock %} +{%block sitesubtitle %}Code Slowly{% endblock%} +{% block primary %} +
    +
    +

    Tutorials and tools for building great things on the web.

    +

    The indie web is an amazing democratic publishing platform unlike anything in history. The catch is, to avoid serving at the pleasure of the corporate king, you need to know how to publish. That's what these articles are here for, to help you learn how to use independent, community supported open source tools. The web won't last forever, let's build something cool while we can.

    +

    A few of the articles below were previously published in: Ars Technica, Wired, and The Register

    +
    +

    Tutorials about {{topic}}

    + + + + +
    +{%endblock%} diff --git a/app/src/urls.py b/app/src/urls.py index 1e1488a..0ac6897 100644 --- a/app/src/urls.py +++ b/app/src/urls.py @@ -26,18 +26,24 @@ urlpatterns = [ name='list_books' ), path( - r'.txt', + r'.txt', views.EntryDetailViewTXT.as_view(), name="detail-txt" ), path( - r'', + r'', views.EntryDetailView.as_view(), name="detail" ), + re_path( + r'', + views.SrcListView.as_view(), + name="list" + ), path( r'', views.SrcListView.as_view(), - name="list", + {'page':1}, + name="list" ), ] diff --git a/app/src/views.py b/app/src/views.py index f929949..7540e02 100644 --- a/app/src/views.py +++ b/app/src/views.py @@ -5,7 +5,7 @@ from django.urls import reverse from django.conf import settings #from paypal.standard.forms import PayPalPaymentsForm - +from utils.views import PaginatedListView from .models import SrcPost, Topic, Book @@ -44,7 +44,8 @@ class BookDetailView(DetailView): return context -class SrcListView(ListView): +class SrcListView(PaginatedListView): + model = SrcPost def get_queryset(self): return SrcPost.objects.filter(status__exact=1) diff --git a/app/utils/views.py b/app/utils/views.py index 60cb7de..152b2b7 100644 --- a/app/utils/views.py +++ b/app/utils/views.py @@ -1,7 +1,8 @@ from itertools import chain import json +from django.urls import reverse from django.http import Http404, HttpResponse -from django.views.generic import ListView +from django.views.generic import ListView, DetailView from django.apps import apps from django.shortcuts import render_to_response from django.shortcuts import render @@ -11,9 +12,15 @@ from photos.models import LuxImage, LuxVideo from recordings.models import Audio +BREADCRUMBS = { + 'SrcPost':'SRC', + 'Book':'Book Notes', + 'Entry':'Jrnl' +} + class PaginatedListView(ListView): """ - handles my own pagination system + handles my own pagination system and breadcrumbs """ context_object_name = 'object_list' @@ -29,6 +36,49 @@ class PaginatedListView(ListView): request.base_path = path return super(PaginatedListView, self).dispatch(request, *args, **kwargs) + def get_context_data(self, **kwargs): + ''' + Adds breadcrumb path to every view + ''' + # Call the base implementation first to get a context + context = super(PaginatedListView, self).get_context_data(**kwargs) + try: + context['breadcrumbs'] = (BREADCRUMBS[self.model.__name__],) + except KeyError: + context['breadcrumbs'] = (self.model._meta.verbose_name_plural,) + return context + + +class LuxDetailView(DetailView): + """ + handles breadcrumbs for detail pages + """ + def get_context_data(self, **kwargs): + ''' + Adds breadcrumb path to every view + ''' + # Call the base implementation first to get a context + context = super(LuxDetailView, self).get_context_data(**kwargs) + print(self.object._meta.verbose_name_plural) + try: + context['breadcrumbs'] = (BREADCRUMBS[self.object._meta.model],) + except KeyError: + if self.object._meta.verbose_name_plural == 'posts': + context['breadcrumbs'] = (self.object.get_post_type_display()+"s",) + context['crumb_url'] = "/%ss/" % self.object.get_post_type_display() + else: + context['breadcrumbs'] = (self.object._meta.verbose_name_plural,) + try: + context['crumb_url'] + except KeyError: + try: + context['crumb_url'] = reverse('%s:list' % self.object._meta.verbose_name_plural) + except: + # special case for pages: + context['breadcrumbs'] = (self.object.title,) + context['crumb_url'] = None + return context + def insert_image(request): """ diff --git a/config/base_urls.py b/config/base_urls.py index f77a8c1..ed73844 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -5,7 +5,7 @@ from django.conf import settings from django.contrib.sitemaps.views import sitemap from django.views.generic.base import RedirectView -from pages.views import PageDetailView +from pages.views import PageDetailView, PageDetailTXTView from jrnl.models import BlogSitemap from fieldnotes.models import FieldNoteSitemap from jrnl.views import HomepageList @@ -47,6 +47,8 @@ urlpatterns = [ path(r'jrnl/', include('jrnl.urls')), path(r'projects/', include('projects.urls')), path(r'topics/', include('taxonomy.urls')), + path(r'walk/', include('locations.walk_urls')), + path(r'walks/', include('locations.walk_urls')), path(r'locations/', include('locations.urls')), path(r'expenses/', include('expenses.urls', namespace='expenses')), path(r'photos/', include('photos.urls')), @@ -69,7 +71,8 @@ urlpatterns = [ path(r'map/', include('locations.urls', namespace='map')), path(r'', HomepageList.as_view(), name="homepage"), path(r'comments/', include('django_comments.urls')), - path(r'', PageDetailView.as_view()), + path(r'.txt', PageDetailTXTView.as_view()), + path(r'', include('pages.urls', namespace='pages')), path(r'//', PageDetailView.as_view()), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/design/templates/archives/books.html b/design/templates/archives/books.html deleted file mode 100644 index 1862563..0000000 --- a/design/templates/archives/books.html +++ /dev/null @@ -1,58 +0,0 @@ -{% extends 'base.html' %} -{% load typogrify_tags %} -{% load html5_datetime %} -{% load pagination_tags %} -{% block pagetitle %} Books | luxagraf {% endblock %} -{% block metadescription %}Books I've read and thoughts on them. {% endblock %} -{%block bodyid%}class="archive" id="books-archive"{%endblock%} - -{% block primary %} - -
    {% autopaginate object_list 24 %} -

    Books

    -
    -

    I wear glasses because as a child I would stay up late, covers pulled over my head, reading by the dim light of a dying flashlight. At least that's what an eye doctor told me when I was younger. Probably a load of crap, but I still love reading and I still often do it by poor light far later in the night than is reasonable.

    -

    I've always taken notes while reading, usually with a pen and paper, but sometimes as highlights in the Kindle. And of course since I have all this stuff in text files I thought might as well put it online. So here you have it, books I've read and things I've thought about them.

    -
    - -
    {% for object in object_list %} -
    - {% if object.image %}
    cover art for {{object.title}} by {{object.author_name}}
    {%endif%} -

    {{object.title|amp|smartypants|widont|safe}}

    - -
    - {% if object.rating %}{% for i in object.ratings_range %}{% if i <= object.get_rating%}★{%else%}☆{%endif%}{%endfor%}{%endif%} - - Read in: {{object.read_date|date:"F Y"}}
    -
    - {% endfor %}
    - -
    -{% endblock %} - - - title = models.CharField(max_length=200) - author_name = models.CharField(max_length=200) - slug = models.CharField(max_length=50) - year_pub = models.CharField(max_length=4, blank=True, null=True) - read_date = models.DateTimeField() - isbn = models.CharField(max_length=100, blank=True, null=True) - body_html = models.TextField(null=True, blank=True) - url = models.CharField(max_length=200, blank=True, null=True) - tags = TaggableManager() - RATINGS = ( - ('1', "1 Star"), - ('2', "2 Stars"), - ('3', "3 Stars"), - ('4', "4 Stars"), - ('5', "5 Stars"), - ) - rating = models.CharField(max_length=1, choices=RATINGS, null=True) - enable_comments = models.BooleanField(default=False) - image = models.FileField(upload_to='book-covers/', null=True, blank=True) - diff --git a/design/templates/base.html b/design/templates/base.html index 67edd7a..2bdd7c0 100644 --- a/design/templates/base.html +++ b/design/templates/base.html @@ -41,6 +41,7 @@
+ {% block breadcrumbs %}{% endblock %} {% block primary %}{% endblock %} {% block extrabody %}{% endblock %} {% block disclaimer %}{% endblock%} diff --git a/design/templates/details/book.html b/design/templates/details/book.html deleted file mode 100644 index 8a87ae5..0000000 --- a/design/templates/details/book.html +++ /dev/null @@ -1,66 +0,0 @@ -{% extends 'base.html' %} -{% load typogrify_tags %} -{%block bodyid%}class="detail"{%endblock%} -{% block primary %} -
-
-

{{object.title|smartypants|widont|safe}}

- - - -
-
- {{object.title}} cover -
-
- -
- {% if object.isbn %}Borrow{%endif%} - {% if object.afflink %}Buy{%endif%} -
-
{%if object.body_html%} -
-
Notes
- {{object.rating}} - - -
{{object.body_html|safe|smartypants|widont}}
-
{%endif%} - {% if object.bookhighlight_set.all %} -
-

Highlights:

- {% for object in object.bookhighlight_set.all %} -
- -
- {{object.body_html|safe|amp|smartypants}} -
-

– Page: {{object.page}} {% if object.location %}(Kindle location: {{object.location|cut:"["|cut:"]"}}){%endif%}

-
- {% endfor %} -
- {%endif%} -
-{% endblock %} -{% block disclaimer %} -
-

When you buy a book using the link above, I may earn a small affiliate commission.

-
-{% endblock %} diff --git a/design/templates/details/note.html b/design/templates/details/note.html index 583d50b..4b52537 100644 --- a/design/templates/details/note.html +++ b/design/templates/details/note.html @@ -13,7 +13,27 @@ {%endblock%} {% block bodyid %}class="notes--permalin detail" id="archive-{% if month %}{{month|month_number_to_name}}{%endif%}{{year}}"{%endblock%} - +{% block breadcrumbs %}{% endblock %} {% block primary %}