mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Add client information for Matrix Synapse and Syncthing
- Add logos for desktop operating systems Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
823e06271f
commit
d403782b77
15 files changed
+134
-126
No files matched your search
+37
-28
@@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for api for android app.
|
||||
"""
|
||||
@@ -28,32 +27,42 @@ from plinth import module_loader
|
||||
import json
|
||||
|
||||
|
||||
def get_apps(request, **kwargs):
|
||||
shortcuts = frontpage.get_shortcuts()
|
||||
|
||||
response = {'services': list(map(get_app_data, shortcuts)) }
|
||||
return HttpResponse(json.dumps(response, cls=DjangoJSONEncoder),
|
||||
content_type="application/json")
|
||||
|
||||
|
||||
def get_app_data(item):
|
||||
item_id = item['id'].split('_')[0]
|
||||
shortcut_module = module_loader.loaded_modules[item_id]
|
||||
|
||||
def get_icon_url(icon):
|
||||
return 'static/theme/icons/{}.svg'.format(icon) if icon else None
|
||||
|
||||
return {key: value for key, value in dict(name=shortcut_module.name,
|
||||
short_description=getattr(shortcut_module,
|
||||
'short_description', None),
|
||||
icon_url=get_icon_url(getattr(shortcut_module, 'icon', None)),
|
||||
description=getattr(shortcut_module, 'description', None),
|
||||
usage=getattr(shortcut_module, 'usage', None),
|
||||
manual_url=getattr(shortcut_module, 'manual_url', None),
|
||||
clients=getattr(shortcut_module, 'clients', None)).items() if value }
|
||||
|
||||
|
||||
def get_access_info(request, **kwargs):
|
||||
response = {domain_type: get_domain(domain_type) for domain_type in
|
||||
get_domain_types()}
|
||||
response = {
|
||||
domain_type: get_domain(domain_type)
|
||||
for domain_type in get_domain_types()
|
||||
}
|
||||
return HttpResponse(json.dumps(response), content_type="application/json")
|
||||
|
||||
|
||||
def get_services(request, **kwargs):
|
||||
services = [shortcut['id'].split('_')[0]
|
||||
for shortcut in frontpage.get_shortcuts()]
|
||||
response = {'services': list(map(_get_service_data, services))}
|
||||
return HttpResponse(
|
||||
json.dumps(response, cls=DjangoJSONEncoder),
|
||||
content_type="application/json")
|
||||
|
||||
|
||||
def _get_service_data(service):
|
||||
module = module_loader.loaded_modules[service]
|
||||
|
||||
def _getattr(attr, not_found=None):
|
||||
"""A closure to get the enclosed module's attributes"""
|
||||
return getattr(module, attr, not_found)
|
||||
|
||||
return {
|
||||
key: value
|
||||
for key, value in dict(
|
||||
name=module.name,
|
||||
short_description=_getattr('short_description'),
|
||||
icon_url=_get_icon_url(_getattr('icon')),
|
||||
description=_getattr('description'),
|
||||
usage=_getattr('usage'),
|
||||
manual_url=_getattr('manual_url'),
|
||||
clients=_getattr('clients')).items()
|
||||
}
|
||||
|
||||
|
||||
def _get_icon_url(icon):
|
||||
return 'static/theme/icons/{}.svg'.format(icon) if icon else None
|
||||
Reference in new issue
Block a user