From f83485b68c301871c2a50efc1d7969509bf0a520 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 15 May 2025 15:12:29 -0700 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/templatetags/plinth_extras.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plinth/templatetags/plinth_extras.py b/plinth/templatetags/plinth_extras.py index 7f04f5b30..ce471f6a0 100644 --- a/plinth/templatetags/plinth_extras.py +++ b/plinth/templatetags/plinth_extras.py @@ -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)