Display an index page below the articles without abstract

This commit is contained in:
Gabriel Augendre 2020-11-26 11:26:47 +01:00
parent ffe246033e
commit 4f354c0014
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
6 changed files with 38 additions and 24 deletions

View file

@ -10,7 +10,7 @@ IGNORED_PATHS = [
def pages(request):
if request.path in IGNORED_PATHS:
return {}
return {"pages": Page.objects.filter(status=Article.PUBLISHED)}
return {"pages": Page.objects.filter(status=Article.PUBLISHED).exclude(position=0)}
def drafts_count(request):

View file

@ -48,6 +48,10 @@ a {
border-bottom: .3ex solid var(--accent);
}
.index-page h2 {
margin-top: 2em;
}
.article-list h2 a {
border-color: transparent;
}

View file

@ -1,8 +1,6 @@
{% extends 'articles/base.html' %}
{% block title %}
{{ article.title }}
{% endblock %}
{% block title %}{{ article.title }} | {% endblock %}
{% block content %}
<article class="article-detail">
<h1>{{ article.title }}{% if article.status != article.PUBLISHED %}

View file

@ -1,11 +1,11 @@
{% extends 'articles/base.html' %}
{% block title %}
{{ title_header }}
{% endblock %}
{% block title %}{% endblock %}
{% block content %}
<h1>{{ blog_title }}{% if title %} &middot; {{ title }}{% endif %}</h1>
<p class="metadata">{{ blog_description }}</p>
<p class="metadata">{{ blog_description }} {% include "articles/admin_link_snippet.html" %}</p>
<section class="blog-posts">
<h2>Blog posts</h2>
<ul>
{% for article in articles %}
<li>
@ -20,6 +20,7 @@
<li>No article here. Come back later 🙂</li>
{% endfor %}
</ul>
</section>
<nav class="pagination">
<div class="older">
{% if page_obj.has_next %}
@ -32,4 +33,10 @@
{% endif %}
</div>
</nav>
<section class="index-page">
<h2>{{ index_page.title }}</h2>
<div>
{{ index_page.get_formatted_content|safe }}
</div>
</section>
{% endblock %}

View file

@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Home{% endblock %} | Gab's Notes</title>
<title>{% block title %}Home | {% endblock %}Gab's Notes</title>
<link rel="stylesheet" id="code-light" href="{% static 'code-light.css' %}" type="text/css">
<link rel="stylesheet" id="code-dark" href="{% static 'code-dark.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'style.css' %}" type="text/css">

View file

@ -9,6 +9,8 @@ from articles.models import Article, Page
class BaseArticleListView(generic.ListView):
paginate_by = 10
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["blog_title"] = settings.BLOG["title"]
@ -23,7 +25,10 @@ class ArticlesListView(BaseArticleListView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title_header"] = "Articles"
index_page = Page.objects.filter(
status=Article.PUBLISHED, position=0
).first() # type: Page
context["index_page"] = index_page
return context