From b9019017f0a3dbe21f973e3ec31a6415f27f3b4d Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Mon, 4 Jun 2018 20:05:50 +0530 Subject: [PATCH] shortcuts: Fix urls for ikiwiki shortcuts The shortcuts api is currently showing all ikiwiki urls as /ikiwiki and not like /ikiwiki/blog. This takes users on the Android app to a directory view where they have to select the name of the blog or wiki. With this patch, users will be directly taken to the appropriate blog or wiki. Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- plinth/modules/api/views.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plinth/modules/api/views.py b/plinth/modules/api/views.py index d9b945d25..c9e14bbc7 100644 --- a/plinth/modules/api/views.py +++ b/plinth/modules/api/views.py @@ -18,6 +18,7 @@ FreedomBox app for api for android app. """ +import copy import json from django.core.serializers.json import DjangoJSONEncoder @@ -55,13 +56,17 @@ def shortcuts(request, **kwargs): def _get_shortcut_data(module_name, shortcut): """Return detailed information about a shortcut.""" module = module_loader.loaded_modules[module_name] - return { + shortcut_data = { 'name': shortcut['name'], 'short_description': shortcut['short_description'], 'description': shortcut['details'], 'icon_url': _get_icon_url(shortcut['icon']), - 'clients': getattr(module, 'clients', None) + 'clients': copy.deepcopy(getattr(module, 'clients', None)) } + if module_name == 'ikiwiki': + shortcut_data['clients'][0]['platforms'][0]['url'] += '/{}'.format( + shortcut['name']) + return shortcut_data def _get_icon_url(icon_name):