Created initial templates for articles app with basic layout and no styling.

pull/1/head
Calum Andrew Morrell 2025-02-16 23:09:43 +00:00
parent 835de18952
commit 0a3ef1070f
4 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% block content %}
<article>
<h3>{{ article.title }}</h3>
{% if article.subtitle %}
<h5>{{ article.subtitle }}</h5>
{% endif %}
<p>Added on the {{ article.created|date:'jS \o\f F, Y' }}
{% if article.created.date != article.updated.date %}
and updated on the {{ article.updated|date:'jS \o\f F, Y' }}
{% endif %}
</p>
<hr>
{% if article.introduction %}
<p>{{ article.introduction|linebreaksbr }}</p>
<hr>
{% endif %}
<div>
{{ article.body_as_markdown|safe }}
</div>
<hr>
<div>
<span>Posted in the <a
href="{% url 'articles:list_category' category=article.category.slug %}">{{ article.category }}</a> category</span>
<span>
{% for tag in article.tags.all %}
<a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if tag != article.tags.last %},{% endif %}
{% endfor %}
</span>
</div>
</article>
{% endblock %}

View File

@ -0,0 +1,58 @@
{% extends 'base.html' %}
{% block content %}
<main>
{% if object_list %}
{% if category %}
<h3>{{ category }} Articles</h3>
{% if category.introduction %}
<div>
<p>{{ category.introduction }}</p>
</div>
{% endif %}
{% elif tag %}
<h3>Articles for tag: {{ tag }}</h3>
{% else %}
<h3>Recent Articles</h3>
{% endif %}
<hr>
<div>
{% for article in object_list %}
<div>
<a href="{{ article.get_absolute_url }}">{{ article.title }}</a>
{% if article.subtitle %}
<h5>{{ article.subtitle }}</h5>
{% endif %}
{% if article.introduction %}
<hr>
<p>{{ article.introduction|linebreaksbr }}</p>
{% endif %}
<hr>
<div>
<span>
<a href="{% url 'articles:list_category' category=article.category.slug %}">{{ article.category }} </a>
&bull; {{ article.created|date:'jS \o\f F, Y' }}
</span>
<span>
{% for tag in article.tags.all %}
<a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if tag != article.tags.last %},
{% endif %}
{% endfor %}
</span>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div>
<h3>Oops!</h3>
<h5>It looks like there are no articles for that {% if category %}category{% elif tag %} tag{% endif %}
yet.</h5>
<p>(sorry not sorry)</p>
</div>
{% endif %}
{% if page_obj.has_previous or page_obj.has_next %}
{% include 'pagination.html' %}
{% endif %}
</main>
{% endblock %}

View File

@ -0,0 +1,21 @@
{% extends 'base.html' %}
{% block content %}
<main>
{% if object_list %}
<h3>Category List</h3>
<hr>
<ul>
{% for category in object_list %}
<li>
<a href="{{ category.get_absolute_url }}">{{ category.title }}</a>
{% if category.introduction %}
<hr>
<p>{{ category.introduction }}</p>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
</main>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}
<main>
{% if object_list %}
<h3>List of Tags</h3>
<hr>
<ul>
{% for tag in object_list %}
<li>
<a href="{{ tag.get_absolute_url }}">{{ tag }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</main>
{% endblock %}