move the decision about where to render the filename into the template

This commit is contained in:
pho4cexa 2022-12-26 10:38:04 -08:00
parent e2487098c5
commit f1c42b4a6a
2 changed files with 21 additions and 19 deletions

View file

@ -42,6 +42,9 @@
<a href="{{ relative_root }}contributors.html">contributors</a>
</nav>
<hr />
{% if source_file %}
<p id="file-path">{{ source_file }}</p>
{% endif %}
{{ content|safe }}
<hr />
<footer>

View file

@ -174,25 +174,24 @@
`(pre ,(git-file->string source-file)))
(define (binary)
'(p "(Binary file)"))
`((p (@ id "file-path") ,source-file)
,(case (string->symbol extension)
((.md .markdown)
(handle-exceptions exn
(begin
(format (current-error-port) "Error parsing ~a\n" source-file)
`((p (b "There was an error parsing this file as Markdown."))
,(plaintext)))
(markdown->sxml (git-file->string source-file))))
((.jpg .jpeg .png .gif .webp .webm .apng .avif .svgz .ico)
(image-link))
((.svg)
(list (image-link) (plaintext)))
((.gz .pack .idx)
(binary))
(else
(if (git-file-is-text? source-file)
(plaintext)
(binary))))))
(case (string->symbol extension)
((.md .markdown)
(handle-exceptions exn
(begin
(format (current-error-port) "Error parsing ~a\n" source-file)
`((p (b "There was an error parsing this file as Markdown."))
,(plaintext)))
(markdown->sxml (git-file->string source-file))))
((.jpg .jpeg .png .gif .webp .webm .apng .avif .svgz .ico)
(image-link))
((.svg)
(list (image-link) (plaintext)))
((.gz .pack .idx)
(binary))
(else
(if (git-file-is-text? source-file)
(plaintext)
(binary))))
(define (filelist->sxml source-files-list relative-root)
`((h1 "Files")