From 284f3972844ea124c0cd9ee5500e99440bb96aac Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sun, 31 Aug 2025 01:09:37 +0200 Subject: g2h: Add file page Also move helpers to dedicated files. --- templates/file.md | 13 +++++++++++++ templates/tree.md | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 templates/file.md (limited to 'templates') diff --git a/templates/file.md b/templates/file.md new file mode 100644 index 0000000..12a5a81 --- /dev/null +++ b/templates/file.md @@ -0,0 +1,13 @@ +{% include '_head.md' %} + +{% if type == 'text' %} +```{{ file_extension }} +{{ content }} +``` +{% elif type == 'image' %} +![](data:image/png;base64,{{ content }}) +{% elif type == 'empty' %} +File is empty. +{% else %} +Can't display binary file. +{% endif %} diff --git a/templates/tree.md b/templates/tree.md index 7a891ab..53644bc 100644 --- a/templates/tree.md +++ b/templates/tree.md @@ -4,7 +4,7 @@ | Name | Last modified | |------|---------------| {%- for entry in entries %} -| [{{ entry.name }}](/{{ subdir }}/{{ entry.name}}) | {% if entry.modified %} {{ entry.modified.strftime('%Y-%m-%d %H:%M:%S') }} {% endif %} |{% endfor %} +| [{{ entry.name }}](/{{ subdir }}/{{ entry.file_name}}) | {% if entry.modified %} {{ entry.modified.strftime('%Y-%m-%d %H:%M:%S') }} {% endif %} |{% endfor %} {% else %} No files. {% endif %} -- cgit v1.2.3