mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
3 files changed
+13
-11
No files matched your search
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user