Browse Source

Add more places to open user and group links in new tabs

merge-requests/110/head
Bauke 5 years ago
committed by Deimos
parent
commit
6b3ae4e3c5
  1. 11
      tildes/static/js/behaviors/group-links-new-tabs.js
  2. 11
      tildes/static/js/behaviors/user-links-new-tabs.js
  3. 2
      tildes/tildes/templates/home.jinja2
  4. 12
      tildes/tildes/templates/macros/comments.jinja2
  5. 12
      tildes/tildes/templates/macros/messages.jinja2
  6. 12
      tildes/tildes/templates/macros/topics.jinja2
  7. 12
      tildes/tildes/templates/topic.jinja2

11
tildes/static/js/behaviors/group-links-new-tabs.js

@ -0,0 +1,11 @@
// Copyright (c) 2020 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-group-links-new-tabs]", function() {
// Open links to groups on Tildes in new tabs
$(this)
.find(".link-group")
.each(function() {
$(this).attr("target", "_blank");
});
});

11
tildes/static/js/behaviors/user-links-new-tabs.js

@ -0,0 +1,11 @@
// Copyright (c) 2020 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-user-links-new-tabs]", function() {
// Open links to users on Tildes in new tabs
$(this)
.find(".link-user")
.each(function() {
$(this).attr("target", "_blank");
});
});

2
tildes/tildes/templates/home.jinja2

@ -56,7 +56,7 @@
<ul class="nav nav-group-list">
{% for group in groups|sort %}
<li class="nav-item"><a href="/~{{ group.path }}">~{{ group.path }}</a></li>
<li class="nav-item">{{ link_to_group(group) }}</li>
{% endfor %}
</ul>
</ul>

12
tildes/tildes/templates/macros/comments.jinja2

@ -133,9 +133,17 @@
{% endif %}
<div class="comment-text"
{% if request.user and request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_group %}
data-js-group-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_user %}
data-js-user-links-new-tabs
{% endif %}
{% endif %}
>
{% if comment.is_removed %}
<p class="comment-removed-warning">This comment has been removed and is not visible to other users</p>

12
tildes/tildes/templates/macros/messages.jinja2

@ -17,8 +17,16 @@
</header>
<div class="message-text"
{% if request.user and request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_group %}
data-js-group-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_user %}
data-js-user-links-new-tabs
{% endif %}
{% endif %}
>{{ message.rendered_html|safe }}</div>
</article>

12
tildes/tildes/templates/macros/topics.jinja2

@ -138,8 +138,16 @@
{% if is_expandable %}
<details class="topic-text-excerpt"
{% if request.user and request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_group %}
data-js-group-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_user %}
data-js-user-links-new-tabs
{% endif %}
{% endif %}
>
<summary><span>{{ excerpt }}</span></summary>

12
tildes/tildes/templates/topic.jinja2

@ -65,8 +65,16 @@
{% if request.has_permission('view_content', topic) %}
{% if topic.is_text_type %}
<div class="topic-full-text"
{% if request.user and request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_group %}
data-js-group-links-new-tabs
{% endif %}
{% if request.user.open_new_tab_user %}
data-js-user-links-new-tabs
{% endif %}
{% endif %}
>{{ topic.rendered_html|safe }}</div>
{% elif topic.is_link_type %}

Loading…
Cancel
Save