добавил tag description на страницы
parent
52d1b84658
commit
50e74ccf38
|
@ -0,0 +1,33 @@
|
||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 055327bef08e
|
||||||
|
Revises: 849ff22feb97
|
||||||
|
Create Date: 2023-10-23 09:29:00.193470
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import flask_security
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '055327bef08e'
|
||||||
|
down_revision = '849ff22feb97'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('header_description', sa.Text(), nullable=True))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('header_description')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
|
@ -0,0 +1,53 @@
|
||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 849ff22feb97
|
||||||
|
Revises: 68537cc1688c
|
||||||
|
Create Date: 2023-10-23 08:34:08.251453
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import flask_security
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '849ff22feb97'
|
||||||
|
down_revision = '68537cc1688c'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('footer_icons', schema=None) as batch_op:
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
with op.batch_alter_table('post', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('header_description', sa.Text(), nullable=True))
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
with op.batch_alter_table('site_headers', schema=None) as batch_op:
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('site_headers', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
|
||||||
|
with op.batch_alter_table('post', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
batch_op.drop_column('header_description')
|
||||||
|
|
||||||
|
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
|
||||||
|
with op.batch_alter_table('footer_icons', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
|
@ -72,6 +72,7 @@ class PostView(MyAdminView):
|
||||||
tags="Тэги",
|
tags="Тэги",
|
||||||
slug="Слаг",
|
slug="Слаг",
|
||||||
title="Заголовок",
|
title="Заголовок",
|
||||||
|
header_description="description заголовок в head страницы",
|
||||||
description="Краткое описание статьи",
|
description="Краткое описание статьи",
|
||||||
author="Автор",
|
author="Автор",
|
||||||
published="Опубликовано",
|
published="Опубликовано",
|
||||||
|
@ -92,6 +93,7 @@ class PostView(MyAdminView):
|
||||||
class PageView(MyAdminView):
|
class PageView(MyAdminView):
|
||||||
column_labels = dict(
|
column_labels = dict(
|
||||||
name="Название страницы",
|
name="Название страницы",
|
||||||
|
header_description="description заголовок в head страницы",
|
||||||
slug="URL страницы",
|
slug="URL страницы",
|
||||||
text="Содержимое страницы",
|
text="Содержимое страницы",
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
import locale
|
import locale
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from flask import abort, current_app, redirect, render_template, request, url_for
|
from flask import (abort, current_app, redirect, render_template, request,
|
||||||
|
url_for)
|
||||||
|
|
||||||
from ..dbase.database import (
|
from ..dbase.database import (get_all_posts_by_tag, get_page,
|
||||||
get_all_posts_by_tag,
|
get_paginated_posts, get_post, get_tags)
|
||||||
get_page,
|
|
||||||
get_paginated_posts,
|
|
||||||
get_post,
|
|
||||||
get_tags,
|
|
||||||
)
|
|
||||||
from .blog import bp
|
from .blog import bp
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, ("ru", "utf-8"))
|
locale.setlocale(locale.LC_ALL, ("ru", "utf-8"))
|
||||||
|
@ -29,6 +25,7 @@ def index(page=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")} - разговоры про питон',
|
||||||
|
header_description="Про изучение python, веб разработку и прочие вещи",
|
||||||
headers=current_app.config.get("SITE_HEADERS"),
|
headers=current_app.config.get("SITE_HEADERS"),
|
||||||
menu_title=current_app.config.get("BRAND"),
|
menu_title=current_app.config.get("BRAND"),
|
||||||
menu_items=current_app.config.get("MENU_ITEMS"),
|
menu_items=current_app.config.get("MENU_ITEMS"),
|
||||||
|
@ -77,6 +74,7 @@ def get_all_tags():
|
||||||
return render_template(
|
return render_template(
|
||||||
"blog/tags.html",
|
"blog/tags.html",
|
||||||
title=f'{current_app.config.get("BRAND")} - поиск по тэгу',
|
title=f'{current_app.config.get("BRAND")} - поиск по тэгу',
|
||||||
|
header_description="Выбор статей по тематике",
|
||||||
headers=current_app.config.get("SITE_HEADERS"),
|
headers=current_app.config.get("SITE_HEADERS"),
|
||||||
menu_title=current_app.config.get("BRAND"),
|
menu_title=current_app.config.get("BRAND"),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
|
@ -91,7 +89,6 @@ def get_all_tags():
|
||||||
def get_posts_by_tag(page=1, tag=None):
|
def get_posts_by_tag(page=1, tag=None):
|
||||||
per_page = current_app.config.get("POSTS_ON_PAGE")
|
per_page = current_app.config.get("POSTS_ON_PAGE")
|
||||||
posts, total = get_all_posts_by_tag(tag, page, per_page)
|
posts, total = get_all_posts_by_tag(tag, page, per_page)
|
||||||
|
|
||||||
if posts is None:
|
if posts is None:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
@ -104,6 +101,7 @@ def get_posts_by_tag(page=1, tag=None):
|
||||||
return render_template(
|
return render_template(
|
||||||
"blog/tagget_posts.html",
|
"blog/tagget_posts.html",
|
||||||
title=f'{current_app.config.get("BRAND")} - посты по {tag}',
|
title=f'{current_app.config.get("BRAND")} - посты по {tag}',
|
||||||
|
header_description=f"Статьи по теме {tag}",
|
||||||
headers=current_app.config.get("SITE_HEADERS"),
|
headers=current_app.config.get("SITE_HEADERS"),
|
||||||
menu_title=current_app.config.get("BRAND"),
|
menu_title=current_app.config.get("BRAND"),
|
||||||
menu_items=current_app.config.get("MENU_ITEMS"),
|
menu_items=current_app.config.get("MENU_ITEMS"),
|
||||||
|
@ -125,6 +123,7 @@ def page(slug=None):
|
||||||
return render_template(
|
return render_template(
|
||||||
"blog/page.html",
|
"blog/page.html",
|
||||||
title=f'{current_app.config.get("BRAND")} - {page.name}',
|
title=f'{current_app.config.get("BRAND")} - {page.name}',
|
||||||
|
header_description=page.header_description,
|
||||||
headers=current_app.config.get("SITE_HEADERS"),
|
headers=current_app.config.get("SITE_HEADERS"),
|
||||||
menu_title=current_app.config.get("BRAND"),
|
menu_title=current_app.config.get("BRAND"),
|
||||||
menu_items=current_app.config.get("MENU_ITEMS"),
|
menu_items=current_app.config.get("MENU_ITEMS"),
|
||||||
|
|
|
@ -72,6 +72,7 @@ class Post(db.Model):
|
||||||
author = Column(Integer, db.ForeignKey("user.id"))
|
author = Column(Integer, db.ForeignKey("user.id"))
|
||||||
slug = Column(String(100), nullable=False)
|
slug = Column(String(100), nullable=False)
|
||||||
title = Column(Text, nullable=False)
|
title = Column(Text, nullable=False)
|
||||||
|
header_description = Column(Text)
|
||||||
description = Column(Text, nullable=False)
|
description = Column(Text, nullable=False)
|
||||||
published = Column(Boolean, default=False)
|
published = Column(Boolean, default=False)
|
||||||
tags = db.relationship("Tag", secondary=tag_post)
|
tags = db.relationship("Tag", secondary=tag_post)
|
||||||
|
@ -99,6 +100,7 @@ class Page(db.Model):
|
||||||
unique=True,
|
unique=True,
|
||||||
autoincrement=True,
|
autoincrement=True,
|
||||||
)
|
)
|
||||||
|
header_description = Column(Text)
|
||||||
name = Column(String(20))
|
name = Column(String(20))
|
||||||
slug = Column(String(50), nullable=False)
|
slug = Column(String(50), nullable=False)
|
||||||
text = Column(Text)
|
text = Column(Text)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||||
<title>{% block title %}{% endblock title %}</title>
|
<title>{% block title %}{% endblock title %}</title>
|
||||||
|
<meta name="description" content="{% block header_description %}{% endblock header_description %}" />
|
||||||
{% for h in headers %}
|
{% for h in headers %}
|
||||||
{{h.content | safe}}
|
{{h.content | safe}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
{{title}}
|
{{title}}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block header_description %}
|
||||||
|
{{ header_description }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block menu_title %}
|
{% block menu_title %}
|
||||||
{{ menu_title }}
|
{{ menu_title }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
{{ menu_title }}
|
{{ menu_title }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block header_description %}
|
||||||
|
{{ header_description }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<!-- Main Content-->
|
<!-- Main Content-->
|
||||||
<div class="conteiner ">
|
<div class="conteiner ">
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
{{ title }}
|
{{ title }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block header_description%}
|
||||||
|
{{ post.Post.header_description }}
|
||||||
|
{% endblock%}
|
||||||
|
|
||||||
{% block menu_title %}
|
{% block menu_title %}
|
||||||
{{ menu_title }}
|
{{ menu_title }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
{{title}}
|
{{title}}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block header_description %}
|
||||||
|
{{ header_description }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block menu_title %}
|
{% block menu_title %}
|
||||||
{{ menu_title }}
|
{{ menu_title }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue