From 7538220e9ace8eb0ecb018ae1eb5615816ad95c9 Mon Sep 17 00:00:00 2001 From: Calum Andrew Morrell Date: Sun, 9 Nov 2025 21:43:02 +0000 Subject: [PATCH] Created basic templates to display news items, categories and tags. --- news/templates/news/category_list.html | 21 +++++++++ .../templates/news/includes/display_tags.html | 3 ++ news/templates/news/newsitem_detail.html | 17 +++++++ news/templates/news/newsitem_list.html | 45 +++++++++++++++++++ news/templates/news/tag_list.html | 17 +++++++ 5 files changed, 103 insertions(+) create mode 100644 news/templates/news/category_list.html create mode 100644 news/templates/news/includes/display_tags.html create mode 100644 news/templates/news/newsitem_detail.html create mode 100644 news/templates/news/newsitem_list.html create mode 100644 news/templates/news/tag_list.html diff --git a/news/templates/news/category_list.html b/news/templates/news/category_list.html new file mode 100644 index 0000000..ed34151 --- /dev/null +++ b/news/templates/news/category_list.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} + +{% block content %} +
+ {% if object_list %} +

Category List

+
+ + {% endif %} +
+{% endblock %} diff --git a/news/templates/news/includes/display_tags.html b/news/templates/news/includes/display_tags.html new file mode 100644 index 0000000..0ba6250 --- /dev/null +++ b/news/templates/news/includes/display_tags.html @@ -0,0 +1,3 @@ +{% for tag in newsitem.tags.all %} + {{ tag }}{% if tag != newsitem.tags.last %},{% endif %} +{% endfor %} diff --git a/news/templates/news/newsitem_detail.html b/news/templates/news/newsitem_detail.html new file mode 100644 index 0000000..0ac6e3a --- /dev/null +++ b/news/templates/news/newsitem_detail.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block content %} +
+

{{ newsitem.title }}

+

{{ newsitem.created_at | date:'jS \o\f F, Y' }}

+
+
+ {{ newsitem.body_as_markdown|safe }} +
+
+
+ Posted in the {{ newsitem.category }} category + {% include 'news/includes/display_tags.html' %} +
+
+{% endblock %} diff --git a/news/templates/news/newsitem_list.html b/news/templates/news/newsitem_list.html new file mode 100644 index 0000000..f05453c --- /dev/null +++ b/news/templates/news/newsitem_list.html @@ -0,0 +1,45 @@ +{% extends 'base.html' %} + +{% block content %} +
+ {% if object_list %} + {% if category %} +

{{ category }} News

+ + + + + + {% elif tag %} +

News for tag: {{ tag }}

+ {% else %} +

Recent News

+ {% endif %} +
+
+ {% for news in object_list %} +
+ {{ news.title }} +
+
+ + {{ news.category }} + • {{ news.created | date:'jS \o\f F, Y' }} + + {% include 'news/includes/display_tags.html' %} +
+
+ {% endfor %} +
+ {% else %} +
+

Oops!

+
It looks like there is no news for that {% if category %}category{% elif tag %}tag{% endif %} yet.
+

(sorry not sorry)

+
+ {% endif %} + {% if page_obj.has_previous or page_obj.has_next %} + {% include 'pagination.html' %} + {% endif %} +
+{% endblock %} diff --git a/news/templates/news/tag_list.html b/news/templates/news/tag_list.html new file mode 100644 index 0000000..58113ee --- /dev/null +++ b/news/templates/news/tag_list.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block content %} +
+ {% if object_list %} +

List of Tags

+
+ + {% endif %} +
+{% endblock %}