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 <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-06-04 20:05:50 +05:30 committed by James Valleroy
parent 18912f5373
commit b9019017f0
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -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):