Display selected tags in tag cloud (#307)

* Add links to remove tags from current query

* Display selected tags in tag cloud

* Add tag cloud tests

* Fix tag cloud in archive

* Add tests for bookmark views

* Expose parse query string

* Improve tag cloud tests

* Cleanup

* Fix rebase issues

* Ignore casing when removing tags from query

Co-authored-by: Jon Hauris <jonp@hauris.org>
This commit is contained in:
Sascha Ißbrücker
2022-08-04 20:31:24 +02:00
committed by GitHub
parent fec966f687
commit dd5e65ecd7
14 changed files with 271 additions and 66 deletions

View File

@@ -36,7 +36,7 @@
<div class="content-area-header">
<h2>Tags</h2>
</div>
{% tag_cloud tags %}
{% tag_cloud tags selected_tags %}
</section>
</div>

View File

@@ -15,7 +15,7 @@
{% if bookmark.tag_names %}
<span>
{% for tag_name in bookmark.tag_names %}
<a href="?{% append_query_param q=tag_name|hash_tag %}">{{ tag_name|hash_tag }}</a>
<a href="?{% append_to_query_param q=tag_name|hash_tag %}">{{ tag_name|hash_tag }}</a>
{% endfor %}
</span>
{% endif %}

View File

@@ -36,7 +36,7 @@
<div class="content-area-header">
<h2>Tags</h2>
</div>
{% tag_cloud tags %}
{% tag_cloud tags selected_tags %}
</section>
</div>

View File

@@ -39,7 +39,7 @@
<div class="content-area-header">
<h2>Tags</h2>
</div>
{% tag_cloud tags %}
{% tag_cloud tags selected_tags %}
</section>
</div>

View File

@@ -1,23 +1,35 @@
{% load shared %}
<div class="tag-cloud">
{% for group in groups %}
<p class="group">
{% for tag in group.tags %}
{# Highlight first char of first tag in group #}
{% if forloop.counter == 1 %}
<a href="?{% append_query_param q=tag.name|hash_tag %}"
class="mr-2" data-is-tag-item>
<span class="highlight-char">{{ tag.name|first_char }}</span><span>{{ tag.name|remaining_chars:1 }}</span>
</a>
{% else %}
{# Render remaining tags normally #}
<a href="?{% append_query_param q=tag.name|hash_tag %}"
class="mr-2" data-is-tag-item>
<span>{{ tag.name }}</span>
</a>
{% endif %}
{% if has_selected_tags %}
<p class="selected-tags">
{% for tag in selected_tags %}
<a href="?{% remove_from_query_param q=tag.name|hash_tag %}"
class="text-bold mr-2">
<span>-{{ tag.name }}</span>
</a>
{% endfor %}
</p>
{% endfor %}
{% endif %}
<div class="unselected-tags">
{% for group in groups %}
<p class="group">
{% for tag in group.tags %}
{# Highlight first char of first tag in group #}
{% if forloop.counter == 1 %}
<a href="?{% append_to_query_param q=tag.name|hash_tag %}"
class="mr-2" data-is-tag-item>
<span class="highlight-char">{{ tag.name|first_char }}</span><span>{{ tag.name|remaining_chars:1 }}</span>
</a>
{% else %}
{# Render remaining tags normally #}
<a href="?{% append_to_query_param q=tag.name|hash_tag %}"
class="mr-2" data-is-tag-item>
<span>{{ tag.name }}</span>
</a>
{% endif %}
{% endfor %}
</p>
{% endfor %}
</div>
</div>