Merge branch 'no-abstract'
This commit is contained in:
commit
00ec56fef6
8 changed files with 44 additions and 24 deletions
|
@ -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):
|
||||
|
|
|
@ -48,6 +48,10 @@ a {
|
|||
border-bottom: .3ex solid var(--accent);
|
||||
}
|
||||
|
||||
.index-page h2 {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.article-list h2 a {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
{% extends 'articles/base.html' %}
|
||||
|
||||
{% block title %}
|
||||
{{ title_header }}
|
||||
{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
{% block content %}
|
||||
<h1>{{ blog_title }}{% if title %} · {{ title }}{% endif %}</h1>
|
||||
<p class="metadata">{{ blog_description }}</p>
|
||||
{% for article in articles %}
|
||||
<article class="article-list">
|
||||
<h2><a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a></h2>
|
||||
{% include "articles/metadata_snippet.html" %}
|
||||
{{ article.get_abstract|safe }}
|
||||
<p class="read-more"><a href="{% url 'article-detail' slug=article.slug %}">Read more...</a></p>
|
||||
</article>
|
||||
{% empty %}
|
||||
<p>No article here. Come back later 🙂</p>
|
||||
{% endfor %}
|
||||
<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>
|
||||
{% if article.published_at %}
|
||||
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
|
||||
{% else %}
|
||||
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
|
||||
{% endif %}
|
||||
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>No article here. Come back later 🙂</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
<nav class="pagination">
|
||||
<div class="older">
|
||||
{% if page_obj.has_next %}
|
||||
|
@ -28,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 %}
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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<!--more-->\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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Reference in a new issue