mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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:
parent
298bb5ae58
commit
f83485b68c
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user