Browse Source

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

merge-requests/102/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. 10
      tildes/tildes/templates/macros/comments.jinja2
  5. 10
      tildes/tildes/templates/macros/messages.jinja2
  6. 10
      tildes/tildes/templates/macros/topics.jinja2
  7. 10
      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"> <ul class="nav nav-group-list">
{% for group in groups|sort %} {% 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 %} {% endfor %}
</ul> </ul>
</ul> </ul>

10
tildes/tildes/templates/macros/comments.jinja2

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

10
tildes/tildes/templates/macros/messages.jinja2

@ -17,9 +17,17 @@
</header> </header>
<div class="message-text" <div class="message-text"
{% if request.user and request.user.open_new_tab_text %}
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs data-js-external-links-new-tabs
{% endif %} {% 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> >{{ message.rendered_html|safe }}</div>
</article> </article>
{% endmacro %} {% endmacro %}

10
tildes/tildes/templates/macros/topics.jinja2

@ -138,9 +138,17 @@
{% if is_expandable %} {% if is_expandable %}
<details class="topic-text-excerpt" <details class="topic-text-excerpt"
{% if request.user and request.user.open_new_tab_text %}
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs data-js-external-links-new-tabs
{% endif %} {% 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> <summary><span>{{ excerpt }}</span></summary>
{{ full_text }} {{ full_text }}

10
tildes/tildes/templates/topic.jinja2

@ -65,9 +65,17 @@
{% if request.has_permission('view_content', topic) %} {% if request.has_permission('view_content', topic) %}
{% if topic.is_text_type %} {% if topic.is_text_type %}
<div class="topic-full-text" <div class="topic-full-text"
{% if request.user and request.user.open_new_tab_text %}
{% if request.user %}
{% if request.user.open_new_tab_text %}
data-js-external-links-new-tabs data-js-external-links-new-tabs
{% endif %} {% 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> >{{ topic.rendered_html|safe }}</div>
{% elif topic.is_link_type %} {% elif topic.is_link_type %}
<div class="topic-full-link"> <div class="topic-full-link">

Loading…
Cancel
Save