diff --git a/tildes/alembic/versions/de83b8750123_add_setting_to_open_text_links_in_new_.py b/tildes/alembic/versions/de83b8750123_add_setting_to_open_text_links_in_new_.py new file mode 100644 index 0000000..e8705db --- /dev/null +++ b/tildes/alembic/versions/de83b8750123_add_setting_to_open_text_links_in_new_.py @@ -0,0 +1,24 @@ +"""Add setting to open text links in new tab + +Revision ID: de83b8750123 +Revises: 2512581c91b3 +Create Date: 2018-07-24 03:10:59.485645 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'de83b8750123' +down_revision = '2512581c91b3' +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column('users', sa.Column('open_new_tab_text', sa.Boolean(), server_default='false', nullable=False)) + + +def downgrade(): + op.drop_column('users', 'open_new_tab_text') diff --git a/tildes/static/js/behaviors/external-links-new-tabs.js b/tildes/static/js/behaviors/external-links-new-tabs.js new file mode 100644 index 0000000..20b90f3 --- /dev/null +++ b/tildes/static/js/behaviors/external-links-new-tabs.js @@ -0,0 +1,8 @@ +$.onmount('[data-js-external-links-new-tabs]', function() { + // Open external links in topic, comment, and message text in new tabs + $(this).find('a').each(function() { + if (this.host !== window.location.host) { + $(this).attr('target', '_blank'); + } + }); +}); diff --git a/tildes/tildes/models/user/user.py b/tildes/tildes/models/user/user.py index d4f9f40..af69bf7 100644 --- a/tildes/tildes/models/user/user.py +++ b/tildes/tildes/models/user/user.py @@ -86,6 +86,8 @@ class User(DatabaseModel): Boolean, nullable=False, server_default='false') open_new_tab_internal: bool = Column( Boolean, nullable=False, server_default='false') + open_new_tab_text: 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/comments.jinja2 b/tildes/tildes/templates/macros/comments.jinja2 index 8fdec2e..4d9b147 100644 --- a/tildes/tildes/templates/macros/comments.jinja2 +++ b/tildes/tildes/templates/macros/comments.jinja2 @@ -94,7 +94,11 @@ {% endif %} -
+
{% if comment.is_removed and 'admin' in request.effective_principals %}

Comment removed

{% endif %} diff --git a/tildes/tildes/templates/macros/messages.jinja2 b/tildes/tildes/templates/macros/messages.jinja2 index f7e8e84..5f95bfa 100644 --- a/tildes/tildes/templates/macros/messages.jinja2 +++ b/tildes/tildes/templates/macros/messages.jinja2 @@ -13,6 +13,10 @@ {{ time_ago(message.created_time) }} -
{{ message.rendered_html|safe }}
+
{{ message.rendered_html|safe }}
{% endmacro %} diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index daa1c06..eb9a5b8 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -51,7 +51,11 @@ {% if not topic.get_content_metadata('excerpt').endswith('...') %}

{{ topic.get_content_metadata('excerpt') }}

{% else %} -
+
{{ topic.get_content_metadata('excerpt') }} diff --git a/tildes/tildes/templates/settings.jinja2 b/tildes/tildes/templates/settings.jinja2 index e8264f6..bd16d7e 100644 --- a/tildes/tildes/templates/settings.jinja2 +++ b/tildes/tildes/templates/settings.jinja2 @@ -73,6 +73,20 @@
+
  • +
    + +
    +
  • diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index 508f15e..78e60a8 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -40,7 +40,11 @@ {% if request.has_permission('view_content', topic) %} {% if topic.is_text_type %} -
    {{ topic.rendered_html|safe }}
    +
    {{ topic.rendered_html|safe }}
    {% elif topic.is_link_type %}