From f19bf61740abcacd4344026c7f77bcd95c3921ad Mon Sep 17 00:00:00 2001 From: Ivan Fonseca Date: Wed, 18 Jul 2018 23:30:17 -0400 Subject: [PATCH] Add user settings for opening links in new tabs Adds two separate user settings. One only affects "external" links (the actual links for link topics), while the other will also affect links to comments pages (including text topics). --- ...b3_add_setting_to_open_links_in_new_tab.py | 26 +++++++++++++ tildes/scss/modules/_settings.scss | 5 +++ tildes/tildes/models/user/user.py | 4 ++ tildes/tildes/templates/macros/topics.jinja2 | 15 +++++-- tildes/tildes/templates/settings.jinja2 | 39 +++++++++++++++++++ tildes/tildes/templates/topic.jinja2 | 5 ++- tildes/tildes/views/api/web/user.py | 18 +++++++++ 7 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 tildes/alembic/versions/2512581c91b3_add_setting_to_open_links_in_new_tab.py diff --git a/tildes/alembic/versions/2512581c91b3_add_setting_to_open_links_in_new_tab.py b/tildes/alembic/versions/2512581c91b3_add_setting_to_open_links_in_new_tab.py new file mode 100644 index 0000000..a05b76b --- /dev/null +++ b/tildes/alembic/versions/2512581c91b3_add_setting_to_open_links_in_new_tab.py @@ -0,0 +1,26 @@ +"""Add setting to open links in new tab + +Revision ID: 2512581c91b3 +Revises: +Create Date: 2018-07-21 22:23:49.563318 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2512581c91b3' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column('users', sa.Column('open_new_tab_external', sa.Boolean(), server_default='false', nullable=False)) + op.add_column('users', sa.Column('open_new_tab_internal', sa.Boolean(), server_default='false', nullable=False)) + + +def downgrade(): + op.drop_column('users', 'open_new_tab_internal') + op.drop_column('users', 'open_new_tab_external') diff --git a/tildes/scss/modules/_settings.scss b/tildes/scss/modules/_settings.scss index a7f1417..c6bfcae 100644 --- a/tildes/scss/modules/_settings.scss +++ b/tildes/scss/modules/_settings.scss @@ -4,4 +4,9 @@ li { margin-bottom: 1rem; } + + // Nested settings list + ul li { + margin-bottom: unset; + } } diff --git a/tildes/tildes/models/user/user.py b/tildes/tildes/models/user/user.py index a27d0dd..d4f9f40 100644 --- a/tildes/tildes/models/user/user.py +++ b/tildes/tildes/models/user/user.py @@ -82,6 +82,10 @@ class User(DatabaseModel): Boolean, nullable=False, server_default='false') auto_mark_notifications_read: bool = Column( Boolean, nullable=False, server_default='false') + open_new_tab_external: bool = Column( + Boolean, nullable=False, server_default='false') + open_new_tab_internal: bool = Column( + Boolean, nullable=False, server_default='false') is_banned: bool = Column(Boolean, nullable=False, server_default='false') is_admin: bool = Column(Boolean, nullable=False, server_default='false') home_default_order: Optional[TopicSortOption] = Column( diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index 092ef4e..daa1c06 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -11,9 +11,15 @@

{% if topic.is_text_type %} - {{ topic.title }} + {{ topic.title }} {% elif topic.is_link_type %} - {{ topic.title }} + {{ topic.title }} {% endif %}

@@ -56,7 +62,10 @@