Added home and back links to gallery view.

This commit is contained in:
2026-03-25 12:35:00 -04:00
parent 5a2bea3040
commit 24c1c96f19
2 changed files with 86 additions and 0 deletions

View File

@@ -153,6 +153,22 @@ def render_directory(request, path_text, full_path):
search_action_query = {"sort": sort_key, "theme": theme}
# Back (directory) and Home (root) links and thumbnails
dir_rel = None
try:
# derive directory path text relative to gallery root
dir_rel = full_path.parent.relative_to(settings.GALLERY_ROOT)
dir_text = str(dir_rel).replace("\\", "/")
except Exception:
dir_text = ""
back_url = gallery_url(
Path(dir_text) if dir_text != "" else None, True, query_state
)
back_thumb = get_first_image_thumbnail_url(full_path.parent)
home_url = gallery_url(None, True, query_state)
home_thumb = get_first_image_thumbnail_url(settings.GALLERY_ROOT)
context = {
"path": path_text,
"search_text": search_text,
@@ -163,6 +179,10 @@ def render_directory(request, path_text, full_path):
"breadcrumbs": build_breadcrumbs(path_text, query_state),
"images": image_data,
"subdirs": subdir_data,
"back_url": back_url,
"back_thumb": back_thumb,
"home_url": home_url,
"home_thumb": home_thumb,
"theme_toggle_url": append_query(
"/gallery/toggle-settings/", theme_toggle_query
),