diff options
author | lxf <sng@luxagraf.net> | 2025-05-31 11:37:22 -0500 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2025-05-31 11:37:22 -0500 |
commit | e2b3a335e3984931f1343cb6be8db53a8a1304ab (patch) | |
tree | 4c31dcb9e55487858dbb939f3fc53afd153eeb5c | |
parent | e0bd735f74c327f1c6f0abccc431b35a270fb8eb (diff) |
condensed everything into jrnl. need to clean up
-rw-r--r-- | app/media/utils.py | 2 | ||||
-rw-r--r-- | app/posts/build.py | 4 | ||||
-rw-r--r-- | app/posts/models.py | 3 | ||||
-rw-r--r-- | app/posts/urls/jrnl_urls.py | 5 | ||||
-rw-r--r-- | app/posts/views/jrnl_views.py | 21 | ||||
-rw-r--r-- | config/base_urls.py | 13 | ||||
-rw-r--r-- | config/django.ini | 12 | ||||
-rw-r--r-- | templates/base.html | 12 |
8 files changed, 44 insertions, 28 deletions
diff --git a/app/media/utils.py b/app/media/utils.py index 893663c..0a5a8ea 100644 --- a/app/media/utils.py +++ b/app/media/utils.py @@ -23,4 +23,4 @@ def resize_image(img, width=None, height=None, quality=72, filepath=""): newimg = resizeimage.resize_height(img, height) ImageFile.MAXBLOCK = img.size[0] * img.size[1] * 4 newimg.save(filepath, newimg.format, quality=quality) - subprocess.call(["jpegoptim", "%s" % filepath]) + #subprocess.call(["jpegoptim", "%s" % filepath]) diff --git a/app/posts/build.py b/app/posts/build.py index ba0fe27..5c8b8f2 100644 --- a/app/posts/build.py +++ b/app/posts/build.py @@ -4,6 +4,7 @@ from django.apps import apps from builder.base import BuildNew from itertools import chain +from django.db.models import Q from django.conf import settings from .models import PostType, PostTopic @@ -55,7 +56,7 @@ class BuildJrnl(BuildNew): Write jrnl to disk ''' def get_model_queryset(self): - return self.model.objects.filter(post_type=PostType.JRNL).filter(status__exact=1).order_by('-pub_date') + return self.model.objects.filter(Q(post_type=PostType.JRNL)|Q(post_type=PostType.ESSAY)).filter(status__exact=1).order_by('-pub_date') def build(self): self.build_list_view( @@ -65,6 +66,7 @@ class BuildJrnl(BuildNew): self.build_year_view("jrnl:list_year") self.build_month_view("jrnl:list_month") self.build_detail_view() + self.build_detail_view() self.build_location_view() self.build_latest() diff --git a/app/posts/models.py b/app/posts/models.py index ba578b8..94adf6c 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -138,7 +138,8 @@ class Post(models.Model): if self.post_type == PostType.PHOTO_ESSAY: return reverse('photo_essay: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}) + #return reverse('essays:detail', kwargs={"cat": self.get_post_topic_display(), "slug": self.slug}) + return reverse('jrnl:essay', kwargs={"slug": self.slug,}) if self.post_type == PostType.SRC: return reverse('src:detail', kwargs={"slug": self.slug}) if self.post_type == PostType.FIELD_NOTE: diff --git a/app/posts/urls/jrnl_urls.py b/app/posts/urls/jrnl_urls.py index d7f0fb1..11685b0 100644 --- a/app/posts/urls/jrnl_urls.py +++ b/app/posts/urls/jrnl_urls.py @@ -36,6 +36,11 @@ urlpatterns = [ name="list" ), path( + r'<str:slug>', + views.JrnlEssayView.as_view(), + name="essay" + ), + path( r'latest/', views.JrnlLatestView.as_view(), name="latest" diff --git a/app/posts/views/jrnl_views.py b/app/posts/views/jrnl_views.py index a7d9f1c..bd22343 100644 --- a/app/posts/views/jrnl_views.py +++ b/app/posts/views/jrnl_views.py @@ -24,7 +24,7 @@ class JrnlListView(PaginatedListView): """ model = Post template_name = "posts/jrnl_list.html" - queryset = Post.objects.filter(post_type=PostType.JRNL).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') + queryset = Post.objects.filter(Q(post_type=PostType.JRNL)|Q(post_type=PostType.ESSAY)).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') def get_context_data(self, **kwargs): context = super(JrnlListView, self).get_context_data(**kwargs) @@ -87,6 +87,23 @@ class JrnlMonthArchiveView(MonthArchiveView): template_name = "posts/jrnl_date.html" +class JrnlEssayView(DetailView): + model = Post + slug_field = "slug" + template_name = "posts/jrnl_detail.html" + + def get_context_data(self, **kwargs): + context = super(JrnlEssayView, 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 + context['breadcrumbs'] = ("jrnl",) + context['crumb_url'] = '/jrnl/' + return context + + class JrnlDetailView(DateDetailView): model = Post date_field = 'pub_date' @@ -147,7 +164,7 @@ class JrnlRSSFeedView(Feed): description_template = 'feeds/blog_description.html' def items(self): - return Post.objects.filter(status__exact=1).filter(post_type__in=[PostType.JRNL]).order_by('-pub_date')[:10] + return Post.objects.filter(status__exact=1).filter(post_type__in=[PostType.JRNL,PostType.ESSAY]).order_by('-pub_date')[:10] def item_pubdate(self, item): """ diff --git a/config/base_urls.py b/config/base_urls.py index ad79987..ce0b577 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -67,7 +67,7 @@ urlpatterns = [ path(r'walks/', include('locations.walk_urls')), path(r'locations/', include('locations.urls')), path(r'newsletter/', include('lttr.urls')), - #path(r'photos/', include('media.urls')), + path(r'photos/', include('media.urls')), path(r'photos/', include('posts.urls.photo_essay_urls', namespace='photo-essay-list')), re_path(r'^essay/$', RedirectView.as_view(url='/essays/')), path(r'essay/', include('posts.urls.essay_urls')), @@ -85,14 +85,3 @@ urlpatterns = [ path(r'<slug>.txt', PageDetailTXTView.as_view()), path(r'<slug>', include('pages.urls', namespace='pages')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) - - -if settings.DEBUG: - import debug_toolbar - urlpatterns = [ - path('__debug__/', include(debug_toolbar.urls)), - - # For django versions before 2.0: - # url(r'^__debug__/', include(debug_toolbar.urls)), - - ] + urlpatterns diff --git a/config/django.ini b/config/django.ini index 4cf9697..d1b157a 100644 --- a/config/django.ini +++ b/config/django.ini @@ -1,18 +1,18 @@ # django.ini file [uwsgi] -plugins = python +#plugins = python # maximum number of processes processes = 4 max-requests = 5000 enable-threads = true # the socket (use the full path to be safe) -socket = /run/uwsgi/%n.sock +socket = /var/run/uwsgi/%n.sock -uid = http -gid = http +uid = www +gid = www chmod-socket = 664 -chown-socket = http:http +chown-socket = www:www # the base directory chdir = /home/lxf/sites/luxagraf @@ -29,5 +29,5 @@ limit-post = 0 # clear environment on exit vacuum = true logto = /var/log/uwsgi/luxagraf.log -logfile-chown = http:http +logfile-chown = www:www logfile-chmod = 664 diff --git a/templates/base.html b/templates/base.html index 2e4eb8b..9aecc6a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -16,7 +16,7 @@ title="Luxagraf RSS feed" href="https://luxagraf.net/rss/"> {%block stylesheet%}<link rel="stylesheet" - href="/media/screenv11.css?{% now "u" %}" + href="/media/screenv11.min.css?{% now "u" %}" media="screen">{%endblock%} {%block extrahead%}{%endblock%} </head> @@ -28,8 +28,8 @@ </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="/essays/" title="Life and how to live it">Essays</a> - <a class="nav-item smcaps" href="{% url "photo_essay:list" %}" title="Photo essays">Photos</a> + <!--<a class="nav-item smcaps" href="/essays/" title="Life and how to live it">Essays</a> + <a class="nav-item smcaps" href="{% url "photo_essay:list" %}" title="Photo essays">Photos</a>--> <a class="nav-item smcaps" href="/about" title="About Scott">About</a> </nav> </header> @@ -49,7 +49,8 @@ <span class="h-card"><a class="p-name u-url" href="https://luxagraf.net/">Scott Gilbertson</a><data class="p-nickname" value="luxagraf"></data></span>. </p> </footer> -{% block js %}<script> +{% block js %} +<script> function isOdd(num) { return num % 2;} document.addEventListener("DOMContentLoaded", function(event) { var today = new Date(); @@ -59,5 +60,6 @@ document.addEventListener("DOMContentLoaded", function(event) { slogan.innerHTML = "Safety Third"; } }); -</script>{% endblock%}</body> +</script> +{% endblock%}</body> </html> |