Awesome PHP-based Git frontend.
Commited on by Robin.
diff --git a/gui/blob.php b/gui/blob.php
index 440b387..51688ea 100644
--- a/gui/blob.php
+++ b/gui/blob.php
@@ -26,21 +26,10 @@
if($mime == 'text/x-shellscript') $mode = 'text/x-sh';
// If the file info is being useless, try to match using
- // file extension data instead.
- else if($mime == 'application/octet-stream') {
- $mode = match($ext) {
- 'png' => 'image/png',
- 'webp' => 'image/webp',
- 'jpg' => 'image/jpg',
- 'jpeg' => 'image/jpg',
- default => $mime
- };
- }
-
- // Again, if the file info is being useless, try using
- // the extension :)
+ // file extension instead.
else if($mime == 'text/plain') {
$mode = match($ext) {
+ 'md' => 'text/x-markdown',
'json' => 'application/json',
'jsonld' => 'application/ld+json',
'ts' => 'application/typescript',
@@ -51,15 +40,16 @@
if(str_ends_with($ext, 'html')) $mime_type = 'text/html';
}
- else {
- $mode = $mime;
- }
+ // For all other cases, let CodeMirror decide.
+ else $mode = $mime;
?>
<div class="container blob">
<?php if(str_starts_with($mime, 'image/')): ?>
<img src="data:<?= $mime ?>;base64,<?= base64_encode($blob) ?>">
- <?php else: ?>
+ <?php elseif($mime == 'application/octet-stream'): ?>
+ <p>Cannot render binary data.</p>
+ <?php else: ?>
<pre class="code"><code><?= htmlspecialchars($blob) ?></code></pre>
<script>