исправил пагинацию на главной, центрирование футера, ссылки со взаимодействием
parent
21a818d71e
commit
6af1d3c7cb
|
@ -1,5 +1,4 @@
|
||||||
from flask_admin import Admin
|
from flask_admin import Admin
|
||||||
from flask_ckeditor import CKEditor
|
|
||||||
|
|
||||||
admin = Admin(
|
admin = Admin(
|
||||||
name="Админ панель",
|
name="Админ панель",
|
||||||
|
|
|
@ -29,10 +29,10 @@ def index(page=1):
|
||||||
session["back_url"] = request.url
|
session["back_url"] = request.url
|
||||||
per_page = current_app.config.get("POSTS_ON_PAGE")
|
per_page = current_app.config.get("POSTS_ON_PAGE")
|
||||||
|
|
||||||
posts, total_pages = get_paginated_posts(page, per_page)
|
posts, total = get_paginated_posts(page, per_page)
|
||||||
list_pages = [
|
total_pages = total // per_page + [0, 1][total % per_page != 0]
|
||||||
x for x in range(1, total_pages + 1) if x >= page - 2 and x <= page + 2
|
|
||||||
]
|
list_pages = [x for x in range(1, total_pages + 1)]
|
||||||
return render_template(
|
return render_template(
|
||||||
"blog/index.html",
|
"blog/index.html",
|
||||||
title=f'{current_app.config.get("BRAND")} - разговоры про питон',
|
title=f'{current_app.config.get("BRAND")} - разговоры про питон',
|
||||||
|
|
|
@ -38,12 +38,10 @@ def get_all_posts_by_tag(tag, page, per_page):
|
||||||
.order_by(Post.create_datetime.desc())
|
.order_by(Post.create_datetime.desc())
|
||||||
.paginate(page=page, per_page=per_page, error_out=True)
|
.paginate(page=page, per_page=per_page, error_out=True)
|
||||||
)
|
)
|
||||||
total_pages = (
|
|
||||||
posts_query.total // per_page + [0, 1][posts_query.total % per_page != 0]
|
|
||||||
)
|
|
||||||
if posts_query.total == 0:
|
if posts_query.total == 0:
|
||||||
return None, None
|
return None, False
|
||||||
return posts_query, total_pages
|
print(posts_query.total)
|
||||||
|
return posts_query, posts_query.total
|
||||||
|
|
||||||
|
|
||||||
def get_page(slug):
|
def get_page(slug):
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
{% block tail %}
|
{% block tail %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{{ ckeditor.load() }}
|
{{ ckeditor.load() }}
|
||||||
{{ ckeditor.config(name='text')}}
|
{{ ckeditor.config(name='title', serve_local=True, pkg_type='basic')}}
|
||||||
|
{{ ckeditor.config(name='description', serve_local=True, pkg_type='basic')}}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -36,17 +36,17 @@
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="text-body navbar-nav me-auto mb-2 mb-lg-0 p-3">
|
<ul class="text-body navbar-nav me-auto mb-2 mb-lg-0 p-3">
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white p-2 link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="{{ url_for('bp_blog.index')}}">Главная
|
href="{{ url_for('bp_blog.index')}}">Главная
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white p-2 link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="{{ url_for('bp_blog.get_all_tags')}}">Статьи по темам</a>
|
href="{{ url_for('bp_blog.get_all_tags')}}">Статьи по темам</a>
|
||||||
</li>
|
</li>
|
||||||
{% for m in menu_items %}
|
{% for m in menu_items %}
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white p-2 link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="/{{m.slug}}">{{m.name}}</a>
|
href="/{{m.slug}}">{{m.name}}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -78,27 +78,27 @@
|
||||||
<!-- Section: Social media -->
|
<!-- Section: Social media -->
|
||||||
|
|
||||||
<!-- Section: Links -->
|
<!-- Section: Links -->
|
||||||
<section class="">
|
<section class="container-fluid justify-content-center">
|
||||||
<!--Grid row-->
|
<!--Grid row-->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!--Grid column-->
|
<!--Grid column-->
|
||||||
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
|
<div class="col-lg-6 col-md-6 mb-4 mb-md-0">
|
||||||
<h5 class="text-white">{{ menu_title }}.ru</h5>
|
<h5 class="text-white">{{ menu_title }}.ru</h5>
|
||||||
|
|
||||||
<ul class="list-unstyled mb-0">
|
<ul class="list-unstyled mb-0">
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="{{ url_for('bp_blog.index')}}">Главная
|
href="{{ url_for('bp_blog.index')}}">Главная
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="{{ url_for('bp_blog.get_all_tags')}}">Статьи по темам</a>
|
href="{{ url_for('bp_blog.get_all_tags')}}">Статьи по темам</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% for m in menu_items %}
|
{% for m in menu_items %}
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="/{{m.slug}}">{{m.name}}</a>
|
href="/{{m.slug}}">{{m.name}}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -107,24 +107,24 @@
|
||||||
<!--Grid column-->
|
<!--Grid column-->
|
||||||
|
|
||||||
<!--Grid column-->
|
<!--Grid column-->
|
||||||
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
|
<div class="col-lg-6 col-md-6 mb-4 mb-md-0">
|
||||||
<h5 class="text-white">Вебхостинг</h5>
|
<h5 class="text-white">Вебхостинг</h5>
|
||||||
|
|
||||||
<ul class="list-unstyled mb-0">
|
<ul class="list-unstyled mb-0">
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="https://www.reg.ru/?rlink=reflink-11750021">Российский регистратор reg.ru </a>
|
href="https://www.reg.ru/?rlink=reflink-11750021">Российский регистратор reg.ru </a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="https://www.reg.ru/domain/new/?rlink=reflink-11750021">Регистрация доменов</a>
|
href="https://www.reg.ru/domain/new/?rlink=reflink-11750021">Регистрация доменов</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="https://www.reg.ru/hosting/?rlink=reflink-11750021">Веб хостинг сайтов</a>
|
href="https://www.reg.ru/hosting/?rlink=reflink-11750021">Веб хостинг сайтов</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white"
|
<a class="link-offset-2 link-underline link-underline-opacity-0 text-white link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover"
|
||||||
href="https://www.reg.ru/vps/cloud/?rlink=reflink-11750021">Облачные серверы</a>
|
href="https://www.reg.ru/vps/cloud/?rlink=reflink-11750021">Облачные серверы</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="conteiner p-4 px-lg-5">
|
<div class="container p-4 px-lg-5">
|
||||||
<h4>{{ post.Post.title | safe }}</h4>
|
<h4>{{ post.Post.title | safe }}</h4>
|
||||||
{{ post.Post.text | safe }}
|
{{ post.Post.text | safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue