diff options
-rw-r--r-- | app/posts/admin.py | 15 | ||||
-rw-r--r-- | app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py | 22 | ||||
-rw-r--r-- | app/posts/migrations/0030_post_template_name.py | 18 | ||||
-rw-r--r-- | app/posts/migrations/0031_alter_post_enable_comments.py | 18 | ||||
-rw-r--r-- | app/posts/models.py | 11 | ||||
-rw-r--r-- | app/posts/templates/posts/essay_detail_lt.html | 139 | ||||
-rw-r--r-- | app/posts/urls/essay_urls.py | 6 | ||||
-rw-r--r-- | app/posts/urls/range_urls.py | 5 | ||||
-rw-r--r-- | app/posts/views/essay_views.py | 6 | ||||
-rw-r--r-- | app/posts/views/range_views.py | 21 | ||||
-rw-r--r-- | config/base_urls.py | 6 |
11 files changed, 223 insertions, 44 deletions
diff --git a/app/posts/admin.py b/app/posts/admin.py index c0081af..d2d1a33 100644 --- a/app/posts/admin.py +++ b/app/posts/admin.py @@ -42,16 +42,15 @@ class PostAdmin(OSMGeoAdmin): fieldsets = ( ('Entry', { 'fields': ( - ('title', 'short_title'), - ('subtitle', 'trip'), + ('title', 'subtitle'), 'body_markdown', - ('pub_date', 'status', 'post_type', 'post_topic'), - ('slug', 'enable_comments',), + ('featured_image', 'pub_date'), + ('dek', 'meta_description'), + ('status', 'post_type', 'post_topic'), + ('slug', "template_name", 'enable_comments'), 'point', - 'dek', - 'meta_description', - ('featured_image','related'), - 'site' + ('related'), + ('site', 'trip'), ), 'classes': ( 'show', diff --git a/app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py b/app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py new file mode 100644 index 0000000..a5b98cc --- /dev/null +++ b/app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.7 on 2024-03-10 09:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0028_alter_post_post_type_alter_post_title'), + ] + + operations = [ + migrations.RemoveField( + model_name='post', + name='short_title', + ), + migrations.AlterField( + model_name='post', + name='post_type', + field=models.IntegerField(choices=[(2, 'essay'), (3, 'src'), (4, 'jrnl'), (5, 'field note')], default=4), + ), + ] diff --git a/app/posts/migrations/0030_post_template_name.py b/app/posts/migrations/0030_post_template_name.py new file mode 100644 index 0000000..9d52571 --- /dev/null +++ b/app/posts/migrations/0030_post_template_name.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-03-10 09:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0029_remove_post_short_title_alter_post_post_type'), + ] + + operations = [ + migrations.AddField( + model_name='post', + name='template_name', + field=models.IntegerField(choices=[(0, 'Default'), (1, 'Large Top Image')], default=0), + ), + ] diff --git a/app/posts/migrations/0031_alter_post_enable_comments.py b/app/posts/migrations/0031_alter_post_enable_comments.py new file mode 100644 index 0000000..7b6e588 --- /dev/null +++ b/app/posts/migrations/0031_alter_post_enable_comments.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-03-10 10:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0030_post_template_name'), + ] + + operations = [ + migrations.AlterField( + model_name='post', + name='enable_comments', + field=models.BooleanField(default=True), + ), + ] diff --git a/app/posts/models.py b/app/posts/models.py index 11ad509..80153e0 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -73,7 +73,6 @@ class PostType(models.IntegerChoices): SRC = 3, ('src') JRNL = 4, ('jrnl') FIELD_NOTE = 5, ('field note') - FILM = 7, ('film') class PostTopic(models.IntegerChoices): @@ -85,7 +84,6 @@ class PostTopic(models.IntegerChoices): class Post(models.Model): site = models.ForeignKey(Site, on_delete=models.SET_NULL, default=1, null=True) title = models.CharField(max_length=200,help_text="49 characters is ideal for essays") - short_title = models.CharField(max_length=200, blank=True, null=True) subtitle = models.CharField(max_length=200, blank=True) slug = models.SlugField(unique_for_date='pub_date') prologue_markdown = models.TextField(blank=True, null=True) @@ -98,12 +96,17 @@ class Post(models.Model): meta_description = models.CharField(max_length=256, blank=True) pub_date = models.DateTimeField('Date published') last_updated = models.DateTimeField(auto_now=True) - enable_comments = models.BooleanField(default=False) + enable_comments = models.BooleanField(default=True) PUB_STATUS = ( (0, 'Draft'), (1, 'Published'), ) status = models.IntegerField(choices=PUB_STATUS, default=0) + TEMPLATE_NAMES = ( + (0, 'Default'), + (1, 'Large Top Image'), + ) + template_name = models.IntegerField(choices=TEMPLATE_NAMES, default=0) featured_image = models.ForeignKey(LuxImage, on_delete=models.SET_NULL, null=True, blank=True) post_type = models.IntegerField(choices=PostType.choices, default=PostType.JRNL) post_topic = models.IntegerField(choices=PostTopic.choices, default=PostTopic.SPIRIT) @@ -131,8 +134,6 @@ class Post(models.Model): return self.title def get_absolute_url(self): - if self.post_type == PostType.FILM: - return reverse('film:detail', kwargs={"slug": self.slug}) if self.post_type == PostType.ESSAY: return reverse('essays:detail', kwargs={"cat": self.get_post_topic_display(), "slug": self.slug}) if self.post_type == PostType.SRC: diff --git a/app/posts/templates/posts/essay_detail_lt.html b/app/posts/templates/posts/essay_detail_lt.html new file mode 100644 index 0000000..3dc8de5 --- /dev/null +++ b/app/posts/templates/posts/essay_detail_lt.html @@ -0,0 +1,139 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load get_image_by_size %} +{%block htmlclass%}{%endblock%} +{% block sitename %} +<head itemscope itemtype="http://schema.org/WebSite"> + <title itemprop='name'>{{object.title|safe}} by Scott Gilbertson</title> + <link rel="canonical" href="https://luxagraf.net{{object.get_absolute_url}}">{%endblock%} + + {%block extrahead%} + <link rel="canonical" href="https://luxagraf.net{{object.get_absolute_url}}" /> +{%endblock%} +{%block bodyid%}id="essay"{%endblock%} +{% block breadcrumbs %}<nav class="breadcrumbs" itemscope itemtype="http://schema.org/BreadcrumbList"> + <span class="nav-item" itemprop="item"> + <a href="/" itemprop="name">Home</a> + <meta itemprop="position" content="1" /> + </span> + <span class="nav-item" itemprop="item"> + <a href="/range/" itemprop="name">Range</a> + <meta itemprop="position" content="2" /> + </span> + </nav> +{% endblock %} +{% block primary %} + <main> + <figure class="large-top-image"> + <a href="{{object.get_absolute_url}}" title="{{object.title}}">{%with image=object.featured_image%} + <img style="margin:0;" sizes="(max-width: 960px) 100vw" + srcset="{{image.get_srcset}}" + src="{{image.get_src}}" + alt="{{image.alt}} photographed by {% if image.photo_credit_source %}{{image.photo_credit_source}}{%else%}luxagraf{%endif%}"> + </a> + <figcaption class="exif-caption"> + {{image.location}}, {{image.location.state}}, {{image.location.state.country}} + </figcaption> + </figure>{%endwith%} + <article class="h-entry hentry content" itemscope itemType="http://schema.org/BlogPosting"> + <header id="header" class="post-header"> + <h1 class="p-name post-title" itemprop="headline">{{object.title|smartypants|safe}}</h1> + {% if object.subtitle %}<h2 class="post-subtitle">{{object.subtitle|smartypants|safe}}</h2>{%endif%} + <div class="post-dateline"><time class="dt-published published dt-updated post-date" style="display:inline" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"Y"}}</span></time> – + {% if object.location %}<div class="p-location h-adr adr post-location" style="display:inline" itemprop="contentLocation" itemscope itemtype="http://schema.org/Place"> + <span class="h-adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">{% if object.location.country_name == "United States" %} + <span class="p-locality locality" itemprop="addressLocality">{{object.location.name|smartypants|safe}}</span>, <span class="p-region region">{{object.location.state_name|safe}}</span><span class="p-country-name" itemprop="addressCountry"></span>{%else%} + <span class="p-region" itemprop="addressRegion">{{object.location.name|smartypants|safe}}</span>, <span class="p-country-name country-name"><span itemprop="addressCountry">{{object.location.country_name|safe}}</span></span>{%endif%} + </span> + </div>{%endif%} + <div>Filed under: <a href="{% url 'essays:category-detail' topic=object.get_post_topic_display %}">{{object.get_post_topic_display}}</a></div> + {% if object.originally_published_by %}<h4 class="post-source">Originally Published By: <a href="{{object.originally_published_by_url}}" title="View {{object.title}} on {{object.originally_published_by}}">{{object.originally_published_by}}</a></h4>{%endif%} + <span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span> + </div> + </header> + <div id="article" class="e-content entry-content post-body" itemprop="articleBody"> + {{object.body_html|safe|smartypants}} + </div> + {%if object.books.all %}<div class="entry-footer"> + <aside id="recommended-reading" class="" > + <h3>Recommended Reading</h3>{% for obj in object.books.all %} + <div itemprop="mainEntity" itemscope itemtype="http://schema.org/Book"> + <div class="book-cover-wrapper"> + <img src="{{obj.get_image_url}}" alt="{{obj.title}} cover" class="lttr-cover" /> + </div> + <div class="meta-cover"> + <h5 class="post-title book-title" itemprop="name">{{obj.title|smartypants|widont|safe}}</h6> + <h6 class="post-subtitle" itemprop="author" itemscope itemtype="http://schema.org/Person"> + <meta itemprop="name" content="{{obj.author_name}}"/>by {{obj.author_name}}</h5> + <dl class="book-metadata"> + {% if obj.rating %}<dt>Rating</dt><dd class="book-stars"> + {% for i in obj.ratings_range %}{% if i <= obj.get_rating%}★{%else%}☆{%endif%}{%endfor%}</span></dd>{%endif%} + {% if obj.read_in %}<dt>Read</dt> + <dd>{{obj.read_in}}</dd>{%endif%} + {% if obj.pages %}<dt>Pages</dt> + <dd itemprop="numberOfPages">{{obj.pages}}</dd>{%endif%} + {% if obj.publish_date %}<dt>Published</dt> + <dd>{%if obj.publish_place%}{{obj.publish_place}}, {%endif%}{{obj.publish_date}}</dd>{%endif%} + {% if obj.isbn %}<dt>ISBN</dt> + <dd>{{obj.isbn}}</dd>{%endif%} + </dl> + <div class="buy-btn-wrapper"> + {% if obj.isbn %}<a class="buy-btn" href="http://worldcat.org/isbn/{{obj.isbn}}" title="find {{obj.title}} in your local library">Borrow</a>{%endif%} + {% if obj.afflink %}<a class="buy-btn" href="{{obj.afflink}}" title="buy {{obj.title}} at Amazon">Buy</a>{%endif%} + </div> + </div>{%if obj.body_html%} + <div class="thoughts" itemprop="review" itemscope itemtype="http://schema.org/Review"> + <h5>Notes</h5> + <span class="hide" itemprop="reviewRating">{{obj.rating}}</span> + <meta itemprop="author" content="Scott Gilbertson" /> + <meta itemprop="datePublished" content="{{obj.read_date|date:"c"}}"> + <div itemprop="reviewBody">{{obj.body_html|safe|smartypants|widont}}</div> + </div>{%endif%} + </div> + {% endfor %} + </aside>{%endif%} + </article> + + {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + <nav class="page-navigation"> + <div>{% if prev%} + <span class="label">Previous:</span> + <a href="{{ prev.get_absolute_url }}" rel="prev" title=" {{prev.title}}">{{prev.title|safe}}</a> + </div>{%endif%}{% if next %} + <div> + <span class="label">Next:</span> + <a href="{{ next.get_absolute_url }}" rel="next" title=" {{next.title}}">{{next.title|safe}}</a> + </div>{%endif%} + </nav>{%endwith%}{%endwith%} + <aside class="narrow donate join"> + <p>You're reading <em>Range</em>, a weekly mailing about tools, craft, and spirit. If you'd like to join us, drop your email in the form below: </p> + <iframe style="border:none !important; background:white; width:100% !important;" title="embedded form for subscribing to the Range newsletter" src="{% url 'lttr:subscribe' slug='range' %}"></iframe> + </aside> + {% if object.related.all %}<div class="article-afterward related"> + <div class="related-bottom"> + <h6 class="hedtinycaps">You might also enjoy</h6> + <div class="archive-grid-quad">{% for object in related %} + <div class="archive-grid-card archive-grid-card-simple" itemscope itemType="http://schema.org/BlogPosting"> + <a href="{{object.get_absolute_url}}" title="{{object.title}}"> + <div class="card-image-tiny"> + {% if object.featured_image %} + {% include "lib/img_archive.html" with image=object.featured_image nolightbox=True %} + {%endif%} + </div> + <h4 class="p-name card-hed" itemprop="headline">{% if object.title %}{{object.title|safe|smartypants|widont}}{% else %}{{object.common_name}}{%endif%}</h4> + <p class="p-author author hide" itemprop="author"><span class="byline-author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Scott Gilbertson</span></span></p> + <span class="card-smcaps"> + {% if object.location %}<span class="p-location h-adr adr card-location" itemprop="contentLocation" itemscope itemtype="http://schema.org/Place"> + {% if object.location.country_name == "United States" %}{{object.location.state_name}}{%else%}{{object.location.country_name}}{%endif%} + </span>{%endif%} + {% if object.location and object.model_name.model != 'page' %}–{%endif%} + {% if object.model_name.model != 'page' %}<time class="dt-published published dt-updated" datetime="{{object.pub_date|date:'c'}}"><span>{{object.pub_date|date:" Y"}}</span></time>{%endif%} + </span> + </a> + </div> + {% endfor %}</div> + </div> + </div>{%endif%} + </main> +{% endblock %} diff --git a/app/posts/urls/essay_urls.py b/app/posts/urls/essay_urls.py index 90a087c..197e72c 100644 --- a/app/posts/urls/essay_urls.py +++ b/app/posts/urls/essay_urls.py @@ -6,14 +6,14 @@ app_name = "essays" urlpatterns = [ path( - r'<str:topic>/<int:page>/', + r'<str:topic>/', views.EssayCategoryList.as_view(), + {'page':1}, name="category-detail" ), path( - r'<str:topic>/', + r'<str:topic>/<int:page>/', views.EssayCategoryList.as_view(), - {'page':1}, name="category-detail" ), path( diff --git a/app/posts/urls/range_urls.py b/app/posts/urls/range_urls.py index 57d72a7..65638ce 100644 --- a/app/posts/urls/range_urls.py +++ b/app/posts/urls/range_urls.py @@ -7,11 +7,6 @@ app_name = "range" urlpatterns = [ path( - r'feed.xml', - views.RangeRSSFeedView(), - name="feed" - ), - path( r'', views.RangeListView.as_view(), {'page':1}, diff --git a/app/posts/views/essay_views.py b/app/posts/views/essay_views.py index 76a022c..41fbc03 100644 --- a/app/posts/views/essay_views.py +++ b/app/posts/views/essay_views.py @@ -71,7 +71,11 @@ class EssayDetailView(LuxDetailView): def get_template_names(self): obj = self.get_object() - return ["posts/essay_detail.html"] + if obj.template_name == 1: + t = "posts/essay_detail_lt.html" + else: + t = "posts/essay_detail.html" + return t class EssayDetailViewTXT(EssayDetailView): diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py index b358051..7ef5054 100644 --- a/app/posts/views/range_views.py +++ b/app/posts/views/range_views.py @@ -20,30 +20,13 @@ from sightings.models import Sighting class RangeListView(PaginatedListView): """ - Return a list of Newsletter posts in reverse chronological order + Return a list of Essay posts in reverse chronological order """ model = Post template_name = "posts/range_list.html" - queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM],status=1).order_by('-pub_date') + queryset = Post.objects.filter(post_type__in=[PostType.ESSAY],status=1).order_by('-pub_date') def get_context_data(self, **kwargs): context = super(RangeListView, self).get_context_data(**kwargs) context['breadcrumbs'] = ['range',] return context - - -class RangeRSSFeedView(Feed): - title = "Range: A weekly photo, developed" - link = "/range/" - description = "Range: A weekly photo, developed" - description_template = 'feeds/blog_description.html' - - def items(self): - return Post.objects.filter(status__exact=1).filter(post_type=PostType.RANGE).order_by('-pub_date')[:10] - - def item_pubdate(self, item): - """ - Takes an item, as returned by items(), and returns the item's - pubdate. - """ - return item.pub_date diff --git a/config/base_urls.py b/config/base_urls.py index bf623df..9d0a507 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -48,9 +48,9 @@ urlpatterns = [ #path(r'expenses/', include('expenses.urls', namespace='expenses')), path(r'newsletter/', include('lttr.urls')), path(r'photos/', include('media.urls')), - path(r'film/', include('posts.urls.film_urls')), - re_path(r'^film/$', RedirectView.as_view(url='/films/')), - path(r'films/', include('posts.urls.film_urls', namespace='films')), + #path(r'film/', include('posts.urls.film_urls')), + #re_path(r'^film/$', RedirectView.as_view(url='/films/')), + #path(r'films/', include('posts.urls.film_urls', namespace='films')), re_path(r'^trip/$', RedirectView.as_view(url='/trips/')), path(r'trip/', include('posts.urls.trip_urls')), path(r'trips/', include('posts.urls.trip_urls', namespace='trips')), |