add: view и шаблоны для блогов и страниц
This commit is contained in:
49
etpgrf_site/blog/templates/blog/page_detail.html
Normal file
49
etpgrf_site/blog/templates/blog/page_detail.html
Normal file
@@ -0,0 +1,49 @@
|
||||
{% extends 'typograph/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{ page.seo_title|default:page.title }} — ETPGRF{% endblock %}
|
||||
{% block description %}{{ page.seo_description|default:page.content|striptags|truncatechars:160 }}{% endblock %}
|
||||
{% block og_title %}{{ page.seo_title|default:page.title }}{% endblock %}
|
||||
{% block og_description %}{{ page.seo_description|default:page.content|striptags|truncatechars:160 }}{% endblock %}
|
||||
{% block og_image %}{% if page.image %}{{ request.scheme }}://{{ request.get_host }}{{ page.image.url }}{% else %}{{ request.scheme }}://{{ request.get_host }}{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}{% endif %}{% endblock %}
|
||||
{% block twitter_title %}{{ page.seo_title|default:page.title }}{% endblock %}
|
||||
{% block twitter_description %}{{ page.seo_description|default:page.content|striptags|truncatechars:160 }}{% endblock %}
|
||||
{% block twitter_image %}{% if page.image %}{{ request.scheme }}://{{ request.get_host }}{{ page.image.url }}{% else %}{{ request.scheme }}://{{ request.get_host }}{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
||||
{# Левая колонка: Дата и Картинка #}
|
||||
<div class="col-lg-2 align-self-start text-end mb-4">
|
||||
<p class="small align-self-end">
|
||||
<small class="bg-secondary bg-opacity-10 p-2 text-nowrap">
|
||||
{{ page.published_at|date:"d.M.Y"|lower }}
|
||||
</small>
|
||||
</p>
|
||||
<p>
|
||||
{% if post.image %}
|
||||
<img src="{{ post.image.url }}" class="w-100 rounded" alt="{{ post.title|safe }}" />
|
||||
{% else %}
|
||||
<img src="{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}" class="w-100 rounded opacity-50" alt="{{ post.title|safe }}" />
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{# Правая колонка: Контент #}
|
||||
<div class="col-lg-10 border-start ps-lg-4">
|
||||
|
||||
<h1 class="display-4 mb-4">{{ page.title|safe }}</h1>
|
||||
|
||||
{% if page.excerpt %}
|
||||
<div class="lead bg-secondary bg-opacity-10 p-3 rounded">
|
||||
{{ page.excerpt|safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="page-content mt-4">
|
||||
{{ page.content|safe }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
58
etpgrf_site/blog/templates/blog/post_detail.html
Normal file
58
etpgrf_site/blog/templates/blog/post_detail.html
Normal file
@@ -0,0 +1,58 @@
|
||||
{% extends 'typograph/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{ post.seo_title|default:post.title }} — ETPGRF{% endblock %}
|
||||
{% block description %}{{ post.seo_description|default:post.excerpt|default:post.content|striptags|truncatechars:160 }}{% endblock %}
|
||||
{% block og_title %}{{ post.seo_title|default:post.title }}{% endblock %}
|
||||
{% block og_description %}{{ post.seo_description|default:post.excerpt|default:post.content|striptags|truncatechars:160 }}{% endblock %}
|
||||
{% block og_image %}{% if post.image %}{{ request.scheme }}://{{ request.get_host }}{{ post.image.url }}{% else %}{{ request.scheme }}://{{ request.get_host }}{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}{% endif %}{% endblock %}
|
||||
{% block twitter_title %}{{ post.seo_title|default:post.title }}{% endblock %}
|
||||
{% block twitter_description %}{{ post.seo_description|default:post.excerpt|default:post.content|striptags|truncatechars:160 }}{% endblock %}
|
||||
{% block twitter_image %}{% if post.image %}{{ request.scheme }}://{{ request.get_host }}{{ post.image.url }}{% else %}{{ request.scheme }}://{{ request.get_host }}{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}{% endif %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
||||
{# Левая колонка: Дата и Картинка #}
|
||||
<div class="col-lg-2 align-self-start text-end mb-4">
|
||||
<p class="small align-self-end">
|
||||
<small class="bg-secondary bg-opacity-10 p-2 text-nowrap">
|
||||
{{ post.published_at|date:"d.M.Y"|lower }}
|
||||
</small>
|
||||
</p>
|
||||
<p>
|
||||
{% if post.image %}
|
||||
<img src="{{ post.image.url }}" class="w-100 rounded" alt="{{ post.title }}" />
|
||||
{% else %}
|
||||
<img src="{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}" class="w-100 rounded opacity-50" alt="{{ post.title }}" />
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<div class="d-none d-lg-block mt-5">
|
||||
<a href="{% url 'blog:post_list' %}" class="btn btn-sm btn-outline-secondary w-100">← В блог</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Правая колонка: Контент #}
|
||||
<div class="col-lg-10 border-start ps-lg-4">
|
||||
|
||||
<h1 class="display-4 mb-4">{{ post.title }}</h1>
|
||||
|
||||
{% if post.excerpt %}
|
||||
<p class="lead bg-secondary bg-opacity-10 p-3 rounded">
|
||||
{{ post.excerpt|linebreaksbr }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="post-content mt-4">
|
||||
{{ post.content|safe }}
|
||||
</div>
|
||||
|
||||
<div class="d-lg-none mt-5 border-top pt-3">
|
||||
<a href="{% url 'blog:post_list' %}" class="btn btn-outline-secondary">← Назад к списку статей</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
76
etpgrf_site/blog/templates/blog/post_list.html
Normal file
76
etpgrf_site/blog/templates/blog/post_list.html
Normal file
@@ -0,0 +1,76 @@
|
||||
{% extends 'typograph/base.html' %}
|
||||
|
||||
{% block title %}Блог — ETPGRF{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<h1 class="mb-4">Блог</h1>
|
||||
|
||||
{% for post in page_obj %}
|
||||
<article class="card mb-4 shadow-sm">
|
||||
{% if post.image %}
|
||||
<img src="{{ post.image.url }}" class="card-img-top" alt="{{ post.title }}" style="max-height: 300px; object-fit: cover;" />
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h4">
|
||||
<a href="{{ post.get_absolute_url }}" class="text-decoration-none text-reset">{{ post.title }}</a>
|
||||
</h2>
|
||||
<p class="card-text text-muted small mb-2">
|
||||
{{ post.published_at|date:"d E Y" }}
|
||||
</p>
|
||||
<p class="card-text">
|
||||
{% if post.excerpt %}
|
||||
{{ post.excerpt|linebreaks }}
|
||||
{% else %}
|
||||
{{ post.content|striptags|truncatewords:30 }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<a href="{{ post.get_absolute_url }}" class="btn btn-outline-primary btn-sm">Читать далее →</a>
|
||||
</div>
|
||||
</article>
|
||||
{% empty %}
|
||||
<p class="text-muted">Пока нет записей.</p>
|
||||
{% endfor %}
|
||||
|
||||
{# Пагинация #}
|
||||
{% if page_obj.has_other_pages %}
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination justify-content-center">
|
||||
{% if page_obj.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ page_obj.previous_page_number }}">«</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">«</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% for i in page_obj.paginator.page_range %}
|
||||
{% if page_obj.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ i }}">{{ i }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ page_obj.next_page_number }}">»</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">»</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user