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 <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa committed 2024-10-16 21:08:00 -07:00
1 parent 5fa9bf2928
commit d605907bbe
3 files changed
+13 -11

No files matched your search

+3 -1
View File
@@ -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),