diff --git a/articles/context_processors.py b/articles/context_processors.py index 65b429d..022bde3 100644 --- a/articles/context_processors.py +++ b/articles/context_processors.py @@ -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): diff --git a/articles/static/style.css b/articles/static/style.css index e4c6e4f..e4bfa9b 100644 --- a/articles/static/style.css +++ b/articles/static/style.css @@ -48,6 +48,10 @@ a { border-bottom: .3ex solid var(--accent); } +.index-page h2 { + margin-top: 2em; +} + .article-list h2 a { border-color: transparent; } diff --git a/articles/templates/articles/article_detail.html b/articles/templates/articles/article_detail.html index de72597..b517771 100644 --- a/articles/templates/articles/article_detail.html +++ b/articles/templates/articles/article_detail.html @@ -1,8 +1,6 @@ {% extends 'articles/base.html' %} -{% block title %} - {{ article.title }} -{% endblock %} +{% block title %}{{ article.title }} | {% endblock %} {% block content %}

{{ article.title }}{% if article.status != article.PUBLISHED %} diff --git a/articles/templates/articles/article_list.html b/articles/templates/articles/article_list.html index 818bfd4..ccde986 100644 --- a/articles/templates/articles/article_list.html +++ b/articles/templates/articles/article_list.html @@ -1,21 +1,26 @@ {% extends 'articles/base.html' %} -{% block title %} - {{ title_header }} -{% endblock %} +{% block title %}{% endblock %} {% block content %}

{{ blog_title }}{% if title %} · {{ title }}{% endif %}

-

{{ blog_description }}

- {% for article in articles %} -
-

{{ article.title }}

- {% include "articles/metadata_snippet.html" %} - {{ article.get_abstract|safe }} -

Read more...

-
- {% empty %} -

No article here. Come back later 🙂

- {% endfor %} +

{{ blog_description }} {% include "articles/admin_link_snippet.html" %}

+
+

Blog posts

+ +
+
+

{{ index_page.title }}

+
+ {{ index_page.get_formatted_content|safe }} +
+
{% endblock %} diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index 586c52b..73d04e0 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -4,7 +4,7 @@ - {% block title %}Home{% endblock %} | Gab's Notes + {% block title %}Home | {% endblock %}Gab's Notes diff --git a/articles/tests/conftest.py b/articles/tests/conftest.py index 908e95a..c1448f6 100644 --- a/articles/tests/conftest.py +++ b/articles/tests/conftest.py @@ -33,4 +33,5 @@ def published_page(author: User) -> Page: published_at=timezone.now(), slug="some-page-slug", content="## some page markdown\n\n[a page link](https://page.com)", + position=2, ) diff --git a/articles/tests/test_articles.py b/articles/tests/test_articles.py index 847821f..155a098 100644 --- a/articles/tests/test_articles.py +++ b/articles/tests/test_articles.py @@ -15,23 +15,26 @@ def test_can_access_list( content = res.content.decode("utf-8") for art in [published_article, published_page]: assert art.title in content - assert published_article.get_abstract() in content + assert published_article.get_abstract() not in content assert published_page.get_formatted_content() not in content @pytest.mark.django_db -def test_abstract_shown_on_list(client: Client, author: User): +def test_only_title_shown_on_list(client: Client, author: User): + title = "This is a very long title mouahahaha" abstract = "Some abstract" after = "Some content after abstract" baker.make( Article, + title=title, status=Article.PUBLISHED, author=author, content=f"{abstract}\n\n{after}", ) # type: Article res = client.get(reverse("articles-list")) content = res.content.decode("utf-8") - assert abstract in content + assert title in content + assert abstract not in content assert after not in content diff --git a/articles/views/html.py b/articles/views/html.py index 88ea7fe..12d4764 100644 --- a/articles/views/html.py +++ b/articles/views/html.py @@ -9,7 +9,7 @@ from articles.models import Article, Page class BaseArticleListView(generic.ListView): - paginate_by = 15 + paginate_by = 10 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -25,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