Let smallish plaintext files display as a pre element.

master
voussoir 2022-10-27 21:15:52 -07:00
parent 706a5eb185
commit 6cc0246764
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 12 additions and 0 deletions

View File

@ -91,6 +91,15 @@
max-height: 100%; max-height: 100%;
max-width: 100%; max-width: 100%;
} }
#photo_viewer pre
{
align-self: start;
width: 100%;
max-height: 100%;
overflow-y: auto;
margin: 0;
white-space: pre-wrap;
}
#photo_viewer a #photo_viewer a
{ {
margin: auto; margin: auto;
@ -254,6 +263,9 @@
{% elif photo.simple_mimetype == "audio" %} {% elif photo.simple_mimetype == "audio" %}
<audio src="{{photo|file_link}}" controls></audio> <audio src="{{photo|file_link}}" controls></audio>
{% elif photo.simple_mimetype == "text" and photo.real_path.is_file and photo.real_path.size < 2**20 %}
<pre>{{photo.real_path.open('r', encoding='utf-8', errors='replace').read()}}</pre>
{% else %} {% else %}
<a href="{{photo|file_link}}">View {{photo.basename}}</a> <a href="{{photo|file_link}}">View {{photo.basename}}</a>