templates: Show Launch web client button for all FreedomBox URLs

Tests:

- For Bepasty app, the 'Launch web client' button is shown.

- For Matrix app, the 'Launch web client' button is not shown.

- For Home Assistant app, the 'Launch web client' button is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-05-15 15:12:29 -07:00 committed by James Valleroy
parent 298bb5ae58
commit f83485b68c
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -61,10 +61,18 @@ def lookup(dictionary, key):
return dictionary[key]
def _is_relative_url(url):
"""Check if the given link is relative or not."""
def _is_internal_url(url):
"""Check if the given link is internal or not.
A URL is internal if it is relative URL or points to one of the domains
managed by FreedomBox.
"""
parsed_url = urlparse(str(url))
return not parsed_url.netloc
if not parsed_url.netloc:
return True
from plinth.modules.names.components import DomainName
return parsed_url.netloc in DomainName.list_names()
@register.filter(name='clients_get_platforms')
@ -74,7 +82,7 @@ def clients_get_platforms(clients):
web = []
for client in clients:
for platform in client['platforms']:
if platform['type'] == 'web' and _is_relative_url(platform['url']):
if platform['type'] == 'web' and _is_internal_url(platform['url']):
web.append(platform)
else:
other.append(platform)