diff --git a/config/settings.py b/config/settings.py index bef1cbe..d688f2c 100644 --- a/config/settings.py +++ b/config/settings.py @@ -236,3 +236,4 @@ CACHE_CATEGORIES: bool = True CACHE_RECENT_PUBLISHED_POSTS: bool = False RECENT_PUBLISHED_POSTS_COUNT: int = 20 +BLOG_TITLE = "stuartm.nz" diff --git a/djpress/templates/djpress/index.html b/djpress/templates/djpress/index.html index c6081bd..56650d8 100644 --- a/djpress/templates/djpress/index.html +++ b/djpress/templates/djpress/index.html @@ -1,32 +1,89 @@ -{% extends '_base.html' %} {% load djpress_tags %} -{% block title %}Home{% endblock %} + + + + + + {% get_blog_title %} + + +
+

{% get_blog_title %}

+
-{% block content %} +
- {% if slug %} - {% comment %} If there's a slug, we only display a single post. {% endcomment %} + {% if slug %} + {% comment %} If there's a slug, we only display a single post. {% endcomment %} - {% get_single_published_content slug as post %} + {% get_single_published_content slug as post %} - {% include "djpress/snippets/content_detail.html" %} +
+
+

{{ post.title }}

+

By

+

+
+
+ {{ post.content_markdown|safe }} +
+
+

Categories:

+ +
+
- {% else %} - {% comment %} If there's no slug, we loop through recent published content. {% endcomment %} + {% else %} + {% comment %} If there's no slug, we loop through recent published content. {% endcomment %} - {% get_recent_published_content as posts %} + {% get_recent_published_content as posts %} - {% for post in posts %} + {% for post in posts %} - {% include "djpress/snippets/content_summary.html" %} +
+
+

{{ post.title }}

+

By

+

+
+
+ {{ post.truncated_content_markdown|safe }} - {% empty %} + {% if post.is_truncated %} +

Read more

+ {% endif %} +
+
+

Categories:

+ +
+
-

No posts available.

+ {% empty %} - {% endfor %} +

No posts available.

- {% endif %} + {% endfor %} -{% endblock %} + {% endif %} + +
+ + + + diff --git a/djpress/templatetags/djpress_tags.py b/djpress/templatetags/djpress_tags.py index 750eaa3..2ed7da2 100644 --- a/djpress/templatetags/djpress_tags.py +++ b/djpress/templatetags/djpress_tags.py @@ -3,6 +3,7 @@ from django import template from django.db import models +from config.settings import BLOG_TITLE from djpress.models import Category, Content register = template.Library() @@ -24,3 +25,9 @@ def get_recent_published_content() -> models.QuerySet[Category] | None: def get_single_published_content(slug: str) -> Content | None: """Return a single published post by slug.""" return Content.post_objects.get_published_post_by_slug(slug) + + +@register.simple_tag +def get_blog_title() -> str: + """Return the blog title.""" + return BLOG_TITLE diff --git a/templates/_base.html b/templates/base.html similarity index 94% rename from templates/_base.html rename to templates/base.html index 786ea07..eee46c7 100644 --- a/templates/_base.html +++ b/templates/base.html @@ -13,7 +13,7 @@ - {% include "snippets/navbar.html" %} + {% include "djpress/snippets/navbar.html" %}
{% block content %} {% endblock %} diff --git a/djpress/templates/djpress/category_posts.html b/templates/djpress/category_posts.html similarity index 92% rename from djpress/templates/djpress/category_posts.html rename to templates/djpress/category_posts.html index 3b7e80f..7767136 100644 --- a/djpress/templates/djpress/category_posts.html +++ b/templates/djpress/category_posts.html @@ -1,4 +1,4 @@ -{% extends '_base.html' %} +{% extends 'base.html' %} {% block title %}{{ category.name }}{% endblock %} diff --git a/templates/djpress/index.html b/templates/djpress/index.html new file mode 100644 index 0000000..71e7a57 --- /dev/null +++ b/templates/djpress/index.html @@ -0,0 +1,32 @@ +{% extends 'base.html' %} +{% load djpress_tags %} + +{% block title %}Home{% endblock %} + +{% block content %} + + {% if slug %} + {% comment %} If there's a slug, we only display a single post. {% endcomment %} + + {% get_single_published_content slug as post %} + + {% include "djpress/snippets/content_detail.html" %} + + {% else %} + {% comment %} If there's no slug, we loop through recent published content. {% endcomment %} + + {% get_recent_published_content as posts %} + + {% for post in posts %} + + {% include "djpress/snippets/content_summary.html" %} + + {% empty %} + +

No posts available.

+ + {% endfor %} + + {% endif %} + +{% endblock %} diff --git a/djpress/templates/djpress/post.html b/templates/djpress/post.html similarity index 89% rename from djpress/templates/djpress/post.html rename to templates/djpress/post.html index 4a0c317..8e11726 100644 --- a/djpress/templates/djpress/post.html +++ b/templates/djpress/post.html @@ -1,4 +1,4 @@ -{% extends '_base.html' %} +{% extends 'base.html' %} {% block title %}{{ post.title }}{% endblock %} diff --git a/djpress/templates/djpress/snippets/content_detail.html b/templates/djpress/snippets/content_detail.html similarity index 100% rename from djpress/templates/djpress/snippets/content_detail.html rename to templates/djpress/snippets/content_detail.html diff --git a/djpress/templates/djpress/snippets/content_summary.html b/templates/djpress/snippets/content_summary.html similarity index 100% rename from djpress/templates/djpress/snippets/content_summary.html rename to templates/djpress/snippets/content_summary.html diff --git a/templates/snippets/navbar.html b/templates/djpress/snippets/navbar.html similarity index 100% rename from templates/snippets/navbar.html rename to templates/djpress/snippets/navbar.html