Browse Source

Add settings to open group and user links in new tab

merge-requests/110/head
Bauke 5 years ago
committed by Deimos
parent
commit
accb39df8e
  1. 36
      tildes/alembic/versions/4241b0202fd4_add_setting_to_open_group_and_user_.py
  2. 2
      tildes/scripts/clean_private_data.py
  3. 2
      tildes/tildes/models/user/user.py
  4. 2
      tildes/tildes/templates/bookmarks.jinja2
  5. 2
      tildes/tildes/templates/error_group_not_found.jinja2
  6. 2
      tildes/tildes/templates/groups.jinja2
  7. 2
      tildes/tildes/templates/macros/comments.jinja2
  8. 12
      tildes/tildes/templates/macros/links.jinja2
  9. 2
      tildes/tildes/templates/macros/topics.jinja2
  10. 2
      tildes/tildes/templates/messages.jinja2
  11. 2
      tildes/tildes/templates/notifications_unread.jinja2
  12. 2
      tildes/tildes/templates/search.jinja2
  13. 28
      tildes/tildes/templates/settings.jinja2
  14. 2
      tildes/tildes/templates/topic.jinja2
  15. 2
      tildes/tildes/templates/topic_listing.jinja2
  16. 2
      tildes/tildes/templates/user.jinja2
  17. 4
      tildes/tildes/views/api/web/user.py

36
tildes/alembic/versions/4241b0202fd4_add_setting_to_open_group_and_user_.py

@ -0,0 +1,36 @@
"""Add setting to open group and user links in new tab
Revision ID: 4241b0202fd4
Revises: 34753d8124b4
Create Date: 2020-02-06 16:59:10.720154
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "4241b0202fd4"
down_revision = "34753d8124b4"
branch_labels = None
depends_on = None
def upgrade():
op.add_column(
"users",
sa.Column(
"open_new_tab_group", sa.Boolean(), server_default="false", nullable=False
),
)
op.add_column(
"users",
sa.Column(
"open_new_tab_user", sa.Boolean(), server_default="false", nullable=False
),
)
def downgrade():
op.drop_column("users", "open_new_tab_user")
op.drop_column("users", "open_new_tab_group")

2
tildes/scripts/clean_private_data.py

@ -197,6 +197,8 @@ class DataCleaner:
"open_new_tab_external": DEFAULT,
"open_new_tab_internal": DEFAULT,
"open_new_tab_text": DEFAULT,
"open_new_tab_group": DEFAULT,
"open_new_tab_user": DEFAULT,
"theme_default": DEFAULT,
"permissions": DEFAULT,
"home_default_order": DEFAULT,

2
tildes/tildes/models/user/user.py

@ -103,6 +103,8 @@ class User(DatabaseModel):
Boolean, nullable=False, server_default="false"
)
open_new_tab_text: bool = Column(Boolean, nullable=False, server_default="false")
open_new_tab_group: bool = Column(Boolean, nullable=False, server_default="false")
open_new_tab_user: bool = Column(Boolean, nullable=False, server_default="false")
theme_default: str = Column(Text)
show_tags_in_listings: bool = Column(
Boolean, nullable=False, server_default="false"

2
tildes/tildes/templates/bookmarks.jinja2

@ -1,7 +1,7 @@
{% extends 'base_user_menu.jinja2' %}
{% from 'macros/comments.jinja2' import render_single_comment with context %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% from 'macros/topics.jinja2' import render_topic_for_listing with context %}
{% block title %}Bookmarks{% endblock %}

2
tildes/tildes/templates/error_group_not_found.jinja2

@ -3,7 +3,7 @@
{% extends 'base_no_sidebar.jinja2' %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% block title %}
Group not found

2
tildes/tildes/templates/groups.jinja2

@ -4,7 +4,7 @@
{% extends 'base_no_sidebar.jinja2' %}
{% from 'macros/groups.jinja2' import render_group_subscription_box with context %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% block title %}Browse groups{% endblock %}

2
tildes/tildes/templates/macros/comments.jinja2

@ -4,7 +4,7 @@
{% from 'buttons.jinja2' import post_action_toggle_button with context %}
{% from 'datetime.jinja2' import adaptive_date_responsive %}
{% from 'forms.jinja2' import markdown_textarea %}
{% from 'links.jinja2' import link_to_user %}
{% from 'links.jinja2' import link_to_user with context %}
{% from 'utils.jinja2' import pluralize %}
{% macro render_single_comment(comment) %}

12
tildes/tildes/templates/macros/links.jinja2

@ -3,12 +3,20 @@
{% macro link_to_user(user) -%}
{% if user.is_real_user %}
<a href="/user/{{ user.username }}" class="link-user">{{ user.username }}</a>
<a
href="/user/{{ user.username }}"
class="link-user"
{% if request.user.open_new_tab_user %}target="_blank"{% endif %}
>{{ user.username }}</a>
{% else %}
{{ user.username }}
{% endif %}
{%- endmacro %}
{% macro link_to_group(group) -%}
<a href="/~{{ group.path }}" class="link-group">~{{ group.path }}</a>
<a
href="/~{{ group.path }}"
class="link-group"
{% if request.user.open_new_tab_group %}target="_blank"{% endif %}
>~{{ group.path }}</a>
{%- endmacro %}

2
tildes/tildes/templates/macros/topics.jinja2

@ -3,7 +3,7 @@
{% from 'macros/buttons.jinja2' import post_action_toggle_button with context %}
{% from 'macros/datetime.jinja2' import adaptive_date_responsive %}
{% from 'macros/links.jinja2' import link_to_group, link_to_user %}
{% from 'macros/links.jinja2' import link_to_group, link_to_user with context %}
{% from 'utils.jinja2' import pluralize %}
{% macro render_topic_for_listing(topic, show_group=False, rank=None) %}

2
tildes/tildes/templates/messages.jinja2

@ -4,7 +4,7 @@
{% extends 'base_user_menu.jinja2' %}
{% from 'macros/datetime.jinja2' import adaptive_date_responsive %}
{% from 'macros/links.jinja2' import link_to_user %}
{% from 'macros/links.jinja2' import link_to_user with context %}
{% block title %}Message Inbox{% endblock %}

2
tildes/tildes/templates/notifications_unread.jinja2

@ -4,7 +4,7 @@
{% extends 'base_user_menu.jinja2' %}
{% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_single_comment with context %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% block title %}Unread notifications{% endblock %}

2
tildes/tildes/templates/search.jinja2

@ -4,7 +4,7 @@
{% extends 'topic_listing.jinja2' %}
{% from 'macros/forms.jinja2' import search_form %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% block title %}Search results: {{ search }}{% endblock %}

28
tildes/tildes/templates/settings.jinja2

@ -144,6 +144,34 @@
</label>
</div>
</li>
<li>
<div class="form-group">
<label class="form-checkbox">
<input
type="checkbox"
id="open_new_tab_group"
name="open_new_tab_group"
data-js-autosubmit-on-change
{% if request.user.open_new_tab_group %}checked{% endif %}
>
<i class="form-icon"></i> Links to groups on Tildes
</label>
</div>
</li>
<li>
<div class="form-group">
<label class="form-checkbox">
<input
type="checkbox"
id="open_new_tab_user"
name="open_new_tab_user"
data-js-autosubmit-on-change
{% if request.user.open_new_tab_user %}checked{% endif %}
>
<i class="form-icon"></i> Links to users on Tildes
</label>
</div>
</li>
</ul>
</form>
</li>

2
tildes/tildes/templates/topic.jinja2

@ -8,7 +8,7 @@
{% from 'macros/datetime.jinja2' import adaptive_date_responsive, time_ago %}
{% from 'macros/forms.jinja2' import markdown_textarea %}
{% from 'macros/groups.jinja2' import group_segmented_link %}
{% from 'macros/links.jinja2' import link_to_user %}
{% from 'macros/links.jinja2' import link_to_user with context %}
{% from 'macros/topics.jinja2' import topic_voting with context %}
{% from 'macros/utils.jinja2' import pluralize %}

2
tildes/tildes/templates/topic_listing.jinja2

@ -5,7 +5,7 @@
{% from 'macros/forms.jinja2' import search_form %}
{% from 'macros/groups.jinja2' import group_segmented_link, render_group_subscription_box with context %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% from 'macros/topics.jinja2' import render_topic_for_listing with context %}
{% block title %}Topics in ~{{ group.path }}{% endblock %}

2
tildes/tildes/templates/user.jinja2

@ -4,7 +4,7 @@
{% extends 'base_user_menu.jinja2' %}
{% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_single_comment with context %}
{% from 'macros/links.jinja2' import link_to_group %}
{% from 'macros/links.jinja2' import link_to_group with context %}
{% from 'macros/topics.jinja2' import render_topic_for_listing with context %}
{% block title %}User: {{ user.username }}{% endblock %}

4
tildes/tildes/views/api/web/user.py

@ -229,9 +229,13 @@ def patch_change_open_links_new_tab(request: Request) -> Response:
external = bool(request.params.get("open_new_tab_external"))
internal = bool(request.params.get("open_new_tab_internal"))
text = bool(request.params.get("open_new_tab_text"))
group = bool(request.params.get("open_new_tab_group"))
open_new_tab_user = bool(request.params.get("open_new_tab_user"))
user.open_new_tab_external = external
user.open_new_tab_internal = internal
user.open_new_tab_text = text
user.open_new_tab_group = group
user.open_new_tab_user = open_new_tab_user
return IC_NOOP

Loading…
Cancel
Save