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:
Joseph Nuthalapati authored and James Valleroy committed 2017-12-04 12:14:42 -05:00
1 parent 823e06271f
commit d403782b77
15 files changed
+134 -126

No files matched your search

+4 -5
View File
@@ -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/>.
#
"""
URLs for the plinth api for android app.
"""
@@ -22,9 +21,9 @@ URLs for the plinth api for android app.
from django.conf.urls import url
from stronghold.decorators import public
from plinth.modules.api.views import get_apps, get_access_info
from plinth.modules.api.views import get_access_info, get_services
urlpatterns = [
url(r'^api/(?P<version>[0-9]+)/services/?$', public(get_apps)),
url(r'^api/(?P<version>[0-9]+)/access-info/?$', public(get_access_info))
]
url(r'^api/(?P<version>[0-9]+)/services/?$', public(get_services)),
url(r'^api/(?P<version>[0-9]+)/access-info/?$', public(get_access_info)),
]
+37 -28
View File
@@ -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