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]
|
return dictionary[key]
|
||||||
|
|
||||||
|
|
||||||
def _is_relative_url(url):
|
def _is_internal_url(url):
|
||||||
"""Check if the given link is relative or not."""
|
"""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))
|
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')
|
@register.filter(name='clients_get_platforms')
|
||||||
@ -74,7 +82,7 @@ def clients_get_platforms(clients):
|
|||||||
web = []
|
web = []
|
||||||
for client in clients:
|
for client in clients:
|
||||||
for platform in client['platforms']:
|
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)
|
web.append(platform)
|
||||||
else:
|
else:
|
||||||
other.append(platform)
|
other.append(platform)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user