From 43957873de7e09d85a29a6ca0c27a7b07c210c6e Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:29:13 +1300 Subject: [PATCH] breadcrumbs --- app/cli.py | 1 + app/models.py | 10 ++++++ app/static/structure.css | 39 ++++++++++++++++++++++ app/static/structure.scss | 46 ++++++++++++++++++++++++++ app/templates/community/community.html | 19 +++++++++-- app/templates/community/post.html | 20 +++++++++-- 6 files changed, 131 insertions(+), 4 deletions(-) diff --git a/app/cli.py b/app/cli.py index a966d217..4c96e649 100644 --- a/app/cli.py +++ b/app/cli.py @@ -58,6 +58,7 @@ def register(app): db.session.append(Settings(name='federation', value=json.dumps(True))) db.session.append(BannedInstances(domain='lemmygrad.ml')) db.session.append(BannedInstances(domain='gab.com')) + db.session.append(BannedInstances(domain='rqd2.net')) db.session.append(BannedInstances(domain='exploding-heads.com')) db.session.append(BannedInstances(domain='hexbear.net')) db.session.append(BannedInstances(domain='threads.net')) diff --git a/app/models.py b/app/models.py index 42517c59..c1277a18 100644 --- a/app/models.py +++ b/app/models.py @@ -10,6 +10,8 @@ from werkzeug.security import generate_password_hash, check_password_hash from flask_babel import _, lazy_gettext as _l from sqlalchemy.orm import backref from sqlalchemy_utils.types import TSVectorType # https://sqlalchemy-searchable.readthedocs.io/en/latest/installation.html +from flask_sqlalchemy import BaseQuery +from sqlalchemy_searchable import SearchQueryMixin from app import db, login import jwt @@ -17,6 +19,10 @@ from app.constants import SUBSCRIPTION_NONMEMBER, SUBSCRIPTION_MEMBER, SUBSCRIPT SUBSCRIPTION_BANNED +class FullTextSearchQuery(BaseQuery, SearchQueryMixin): + pass + + class File(db.Model): id = db.Column(db.Integer, primary_key=True) file_path = db.Column(db.String(255)) @@ -28,6 +34,7 @@ class File(db.Model): class Community(db.Model): + query_class = FullTextSearchQuery id = db.Column(db.Integer, primary_key=True) icon_id = db.Column(db.Integer, db.ForeignKey('file.id')) image_id = db.Column(db.Integer, db.ForeignKey('file.id')) @@ -107,6 +114,7 @@ class Community(db.Model): class User(UserMixin, db.Model): + query_class = FullTextSearchQuery id = db.Column(db.Integer, primary_key=True) user_name = db.Column(db.String(255), unique=True, index=True) email = db.Column(db.String(255), index=True) @@ -236,6 +244,7 @@ class ActivityLog(db.Model): class Post(db.Model): + query_class = FullTextSearchQuery id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) community_id = db.Column(db.Integer, db.ForeignKey('community.id'), index=True) @@ -279,6 +288,7 @@ class Post(db.Model): class PostReply(db.Model): + query_class = FullTextSearchQuery id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) post_id = db.Column(db.Integer, db.ForeignKey('post.id'), index=True) diff --git a/app/static/structure.css b/app/static/structure.css index e0e09d69..a44675bb 100644 --- a/app/static/structure.css +++ b/app/static/structure.css @@ -265,12 +265,51 @@ fieldset legend { margin-right: auto; } +#breadcrumb_nav { + display: none; +} + +@media (min-width: 992px) { + #breadcrumb_nav { + display: block; + font-size: 87%; + } + #breadcrumb_nav .breadcrumb { + padding: 0; + margin-bottom: 0; + background-color: inherit; + } + #breadcrumb_nav .breadcrumb .breadcrumb-item + .breadcrumb-item::before { + content: ">"; + } +} .community_header { background-repeat: no-repeat; background-position: center center; background-size: cover; border-radius: 5px; } +@media (min-width: 992px) { + .community_header #breadcrumb_nav { + padding-left: 20px; + padding-top: 13px; + } + .community_header #breadcrumb_nav .breadcrumb { + padding: 0; + margin-bottom: 0; + background-color: inherit; + } + .community_header #breadcrumb_nav .breadcrumb .breadcrumb-item { + color: white; + } + .community_header #breadcrumb_nav .breadcrumb .breadcrumb-item a { + color: white; + } + .community_header #breadcrumb_nav .breadcrumb .breadcrumb-item + .breadcrumb-item::before { + content: ">"; + color: white; + } +} .community_header_no_background .community_icon, .community_header .community_icon { width: 120px; diff --git a/app/static/structure.scss b/app/static/structure.scss index 55d5455e..10739a36 100644 --- a/app/static/structure.scss +++ b/app/static/structure.scss @@ -51,11 +51,57 @@ nav, etc which are used site-wide */ margin-right: auto; } +#breadcrumb_nav { + display: none; +} + +@include breakpoint(tablet) { + #breadcrumb_nav { + display: block; + font-size: 87%; + + .breadcrumb { + padding: 0; + margin-bottom: 0; + background-color: inherit; + + .breadcrumb-item + .breadcrumb-item::before { + content: ">"; + } + } + } +} + .community_header { background-repeat: no-repeat; background-position: center center; background-size: cover; border-radius: 5px; + + @include breakpoint(tablet) { + #breadcrumb_nav { + padding-left: 20px; + padding-top: 13px; + + .breadcrumb { + padding: 0; + margin-bottom: 0; + background-color: inherit; + + .breadcrumb-item { + color: white; + a { + color: white; + } + } + + .breadcrumb-item + .breadcrumb-item::before { + content: ">"; + color: white; + } + } + } + } } .community_header_no_background, .community_header { diff --git a/app/templates/community/community.html b/app/templates/community/community.html index 7959946e..afef3b81 100644 --- a/app/templates/community/community.html +++ b/app/templates/community/community.html @@ -5,7 +5,15 @@
{{ post.url|shorten_url }} {% if post.type == post_type_link %} @@ -27,7 +35,15 @@ {% endif %}