views: Use tags from menu or shortcut instead of the app

- Also remove the extra unwanted space between the tags.

- This allows different shortcuts of the same app to have different tags on the
home page. Example: email shortcuts on the home page.

- This also allows custom shortcuts to have their own tags without being
attached to any app provided by FreedomBox.

- Filter shown menu items by tags on the menu item rather than tags on the app.
They could be different.

Tests:

- Home page shows shortcuts with tags.

- Apps and system pages show shortcuts with apps.

- Apps are properly filtered when tags are clicked on in the app page.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa 2024-12-30 22:12:37 -08:00 committed by Joseph Nuthalapati
parent ffc95019f0
commit 42d1225f5b
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
3 changed files with 3 additions and 5 deletions

View File

@ -20,7 +20,7 @@
</div>
<div class="card-title">{{ item.name }}</div>
<div class="card-tags">
{% for tag in item.app.info.tags|slice:":3" %}{% trans tag %}{% if not forloop.last %}・{% endif %}{% endfor %}
{% for tag in item.tags|slice:":3" %}{% trans tag %}{% if not forloop.last %}・{% endif %}{% endfor %}
</div>
</a>
</div>

View File

@ -76,9 +76,7 @@
{{ shortcut.name }}
</div>
<div class="card-tags">
{% for tag in shortcut.app.info.tags|slice:":3" %}
{% trans tag %}{% if not forloop.last %}・{% endif %}
{% endfor %}
{% for tag in shortcut.tags|slice:":3" %}{% trans tag %}{% if not forloop.last %}・{% endif %}{% endfor %}
</div>
</a>
</div>

View File

@ -191,7 +191,7 @@ class AppsIndexView(TemplateView):
A mismatch is when a selected tag is *not* present in the list of
tags for menu item.
"""
menu_tags = set(menu_item.app.info.tags)
menu_tags = set(menu_item.tags)
return [tag not in menu_tags for tag in selected_tags]
def _sort_key(menu_item):