Clicking image in refresh mode stops the refresh

This commit is contained in:
Timothy Farrell 2026-03-12 09:07:41 +00:00
parent 4eb9ff1188
commit 143c8563de
2 changed files with 8 additions and 6 deletions

View File

@ -42,7 +42,7 @@
</head> </head>
<body> <body>
<div id="container"> <div id="container">
<a href="$next_random_url"><img id="img" src="$img_url" title="$filename"></a> <a href="$image_click_url"><img id="img" src="$img_url" title="$filename"></a>
<a href="$prev_url" class="chevron left" id="prev-btn">&#8249;</a> <a href="$prev_url" class="chevron left" id="prev-btn">&#8249;</a>
<a href="$next_url" class="chevron right" id="next-btn">&#8250;</a> <a href="$next_url" class="chevron right" id="next-btn">&#8250;</a>
</div> </div>

12
main.py
View File

@ -186,7 +186,9 @@ def _get_navigation_data(file_hash: str):
} }
def _render_page(navigation_data: dict, extra_meta: str = "") -> HTMLResponse: def _render_page(
navigation_data: dict, extra_meta: str = "", image_click_url: str = ""
) -> HTMLResponse:
"""Render the frontend page with navigation data""" """Render the frontend page with navigation data"""
with open("frontend.html", "r") as f: with open("frontend.html", "r") as f:
content = f.read() content = f.read()
@ -194,9 +196,8 @@ def _render_page(navigation_data: dict, extra_meta: str = "") -> HTMLResponse:
template = string.Template(content) template = string.Template(content)
content = template.substitute( content = template.substitute(
img_url="/api/{file_hash}/data".format(file_hash=navigation_data["file_hash"]), img_url="/api/{file_hash}/data".format(file_hash=navigation_data["file_hash"]),
next_random_url="/{next_random_hash}".format( image_click_url=image_click_url
next_random_hash=navigation_data["next_random_hash"] or "/{next_random_hash}".format(next_random_hash=navigation_data["next_random_hash"]),
),
next_url="/{next_hash}".format(next_hash=navigation_data["next_hash"]), next_url="/{next_hash}".format(next_hash=navigation_data["next_hash"]),
prev_url="/{prev_hash}".format(prev_hash=navigation_data["prev_hash"]), prev_url="/{prev_hash}".format(prev_hash=navigation_data["prev_hash"]),
filename=navigation_data["filename"], filename=navigation_data["filename"],
@ -237,8 +238,9 @@ async def hash_page_with_refresh(order: str, delay: int, file_hash: str):
) )
refresh_meta = f'<meta http-equiv="refresh" content="{delay};url={refresh_url}">' refresh_meta = f'<meta http-equiv="refresh" content="{delay};url={refresh_url}">'
image_click_url = "/{file_hash}".format(file_hash=file_hash)
return _render_page(navigation_data, refresh_meta) return _render_page(navigation_data, refresh_meta, image_click_url)
def _find_indexer_for_hash(file_hash: str): def _find_indexer_for_hash(file_hash: str):