From d605907bbec007484f53202caa999eb427183ee9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 15 Oct 2024 15:45:16 -0700 Subject: [PATCH] context_processors: Use active menu urls to decide what to highlight - We are using submenu.url to check for specific URLs and then highlight a menu item. This is somewhat incorrect due to string search and not generic enough. We have another mechanism 'active_menu_urls' to perform this. Improve and use this instead. Signed-off-by: Sunil Mohan Adapa --- plinth/context_processors.py | 4 +++- plinth/templates/base.html | 8 ++++---- plinth/tests/test_context_processors.py | 12 ++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plinth/context_processors.py b/plinth/context_processors.py index 01a4bbf8b..ddfc2af0f 100644 --- a/plinth/context_processors.py +++ b/plinth/context_processors.py @@ -27,7 +27,9 @@ def common(request): request, user=request.user) slash_indices = [match.start() for match in re.finditer('/', request.path)] - active_menu_urls = [request.path[:index + 1] for index in slash_indices] + active_menu_urls = [ + request.path[:index + 1] for index in slash_indices[2:] + ] # Ignore the first two slashes '/plinth/apps/' return { 'cfg': cfg, 'submenu': menu.main_menu.active_item(request), diff --git a/plinth/templates/base.html b/plinth/templates/base.html index eb91fc4b6..680d93184 100644 --- a/plinth/templates/base.html +++ b/plinth/templates/base.html @@ -83,7 +83,7 @@ {% block mainmenu_left %} @@ -110,7 +110,7 @@