Implement backward navigation for splited files

This commit is contained in:
KnugiHK
2025-02-09 14:47:05 +08:00
parent 0b2dfa9aba
commit dd75ec4b87
4 changed files with 24 additions and 11 deletions

View File

@@ -817,9 +817,10 @@ def create_html(
render_box, render_box,
contact, contact,
w3css, w3css,
f"{safe_file_name}-{current_page + 1}.html",
chat, chat,
headline headline,
next=f"{safe_file_name}-{current_page + 1}.html",
previous=f"{safe_file_name}-{current_page - 1}.html" if current_page > 1 else False
) )
render_box = [message] render_box = [message]
current_size = 0 current_size = 0
@@ -838,9 +839,10 @@ def create_html(
render_box, render_box,
contact, contact,
w3css, w3css,
False,
chat, chat,
headline headline,
False,
previous=f"{safe_file_name}-{current_page - 1}.html"
) )
else: else:
output_file_name = f"{output_folder}/{safe_file_name}.html" output_file_name = f"{output_folder}/{safe_file_name}.html"
@@ -851,9 +853,9 @@ def create_html(
chat.get_messages(), chat.get_messages(),
contact, contact,
w3css, w3css,
False,
chat, chat,
headline headline,
False
) )
if current % 10 == 0: if current % 10 == 0:
print(f"Generating chats...({current}/{total_row_number})", end="\r") print(f"Generating chats...({current}/{total_row_number})", end="\r")

View File

@@ -132,9 +132,10 @@ def rendering(
msgs, msgs,
contact, contact,
w3css, w3css,
next,
chat, chat,
headline headline,
next=False,
previous=False
): ):
if chat.their_avatar_thumb is None and chat.their_avatar is not None: if chat.their_avatar_thumb is None and chat.their_avatar is not None:
their_avatar_thumb = chat.their_avatar their_avatar_thumb = chat.their_avatar
@@ -153,6 +154,7 @@ def rendering(
their_avatar_thumb=their_avatar_thumb, their_avatar_thumb=their_avatar_thumb,
w3css=w3css, w3css=w3css,
next=next, next=next,
previous=previous,
status=chat.status, status=chat.status,
media_base=chat.media_base, media_base=chat.media_base,
headline=headline headline=headline

View File

@@ -271,6 +271,10 @@
</div> </div>
</article> </article>
<footer class="w3-center"> <footer class="w3-center">
<h2>
{% if previous %}
<a href="./{{ previous }}" target="_self">Previous</a>
{% endif %}
<h2> <h2>
{% if next %} {% if next %}
<a href="./{{ next }}" target="_self">Next</a> <a href="./{{ next }}" target="_self">Next</a>

View File

@@ -166,6 +166,13 @@
<!-- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-[#aebac1]" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <!-- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-[#aebac1]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg> --> </svg> -->
{% if previous %}
<a href="./{{ previous }}" target="_self">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-[#aebac1]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5l-7 7 7 7" />
</svg>
</a>
{% endif %}
{% if next %} {% if next %}
<a href="./{{ next }}" target="_self"> <a href="./{{ next }}" target="_self">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-[#aebac1]" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-[#aebac1]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
@@ -334,9 +341,7 @@
</div> </div>
<footer> <footer>
<h2 class="text-center"> <h2 class="text-center">
{% if next %} {% if not next %}
<a href="./{{ next }}" target="_self">Next</a>
{% else %}
End of History End of History
{% endif %} {% endif %}
</h2> </h2>