From 5c13eec0288d45ad735754dd100eaf4ca522fca6 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 24 May 2025 14:30:59 -0400 Subject: [PATCH] Add created timestamp to directory listing Display both created and modified dates for files and directories in the template, along with improved mobile responsiveness throughout the interface. --- engine.py | 1 + templates/directory.html | 170 ++++++++++++++++++++------------------- 2 files changed, 89 insertions(+), 82 deletions(-) diff --git a/engine.py b/engine.py index f616069..e77504a 100644 --- a/engine.py +++ b/engine.py @@ -49,6 +49,7 @@ def get_directory_structure(path): 'is_markdown': item.suffix == '.md', 'is_image': item.suffix.lower() in ['.jpg', '.jpeg', '.png', '.gif', '.webp'], 'size': item.stat().st_size if item.is_file() else None, + 'created': datetime.fromtimestamp(item.stat().st_ctime), 'modified': datetime.fromtimestamp(item.stat().st_mtime), 'file_type': item.suffix.lower() if item.is_file() else 'directory', 'static_path': f"/static/data/{item.relative_to(DATA_DIR)}" if not item.is_dir() else None diff --git a/templates/directory.html b/templates/directory.html index f702c06..ae2824a 100644 --- a/templates/directory.html +++ b/templates/directory.html @@ -12,44 +12,41 @@ {% else %} -
-

+
+

{{ title }}

{% if current_path and current_path != '' %} -

{{ current_path }}

+

{{ current_path }}

{% endif %}
{% endif %} {% if is_image_gallery and image_items %} -
-
-

Gallery

-
- -
-
+
{% for item in image_items %} -
+ {% endfor %} @@ -58,12 +55,12 @@ {% set non_image_items = items | rejectattr('is_image') | list %} {% if non_image_items %} -

Other Files

-
+

Other Files

+
{% for item in non_image_items %} -
+
-
+
{% if item.is_dir %} 📁 {% elif item.is_markdown %} @@ -74,26 +71,29 @@
-
+
+ class="text-base md:text-lg font-medium {% if item.is_dir %}text-primary-300{% else %}text-gray-200 et-book{% endif %} hover:text-primary-400 transition-colors duration-200 group-hover:text-primary-300 tracking-wide break-words"> {{ item.display_name }}{% if item.is_dir %}/{% endif %} -
- - {{ item.modified.strftime('%b %d, %Y') }} - - {% if item.is_dir %} - - folder - - {% elif not item.is_markdown %} - - {{ item.file_type.replace('.', '') or 'file' }} - - {% endif %} +
+
+ Created: {{ item.created.strftime('%b %d, %Y') }} + Modified: {{ item.modified.strftime('%b %d, %Y') }} +
+
+ {% if item.is_dir %} + + folder + + {% elif not item.is_markdown %} + + {{ item.file_type.replace('.', '') or 'file' }} + + {% endif %} +
@@ -103,12 +103,12 @@
-