Fixed rendering issues

- Image paths: Images worked on the README.md, but as soon as you tried
  to view the images in the files tree, and the images were in a
  subdirectory, the full path was added after the directory name.

  For example, an image at <git-repo-root>/images/screenshot.gif, would be
  generated in the file tree with the following link:
  <git-repo-root>images/images/screenshot.gif
  because it doesn't know that the link to the source file is actually
  also linking to the images directory, because I generate directories for
  all links, as if you were actually traversing them.

  This means we are able to strip the directory from the file path
  completely, because our links already go to the desired directory, to
  get images to show up in the source file view

- Unknown file type issues: I changed the else statement to render the
  unknown filetype, because it cause the source of, for example,
  main.scm to just say "(Unknown file type)". Maybe we can revise this
  in the future to see when we want to use Unknown filetypes!

Thoughts: I think I'm going to try to see if prepending a slash at the
front of image paths will create an absolute path, so we dont have to
get into messy relative paths haha.
This commit is contained in:
m455 2022-12-07 21:27:30 -05:00
parent 0b86b0022e
commit 7dbf2fb3fc

View file

@ -103,9 +103,9 @@ string-block
(display "</pre>")) (display "</pre>"))
(markdown->html (git-file->string source-file)))) (markdown->html (git-file->string source-file))))
((jpg jpeg png gif webp webm apng avif svgz ico) ((jpg jpeg png gif webp webm apng avif svgz ico)
(format #t "<p><img src=\"~a\" /></p>" source-file)) (format #t "<p><img src=\"/~a\" /></p>" source-file))
((svg) ((svg)
(format #t "<p><img src=\"~a\" /></p>" source-file) (format #t "<p><img src=\"/~a\" /></p>" source-file)
(display "<pre>") (display "<pre>")
(display-escaped-html (git-file->string source-file)) (display-escaped-html (git-file->string source-file))
(display "</pre>")) (display "</pre>"))
@ -116,7 +116,9 @@ string-block
(display-escaped-html (git-file->string source-file)) (display-escaped-html (git-file->string source-file))
(display "</pre>")) (display "</pre>"))
(else (else
(display "<p>(Unknown file type)</p>")))) (display "<pre>")
(display-escaped-html (git-file->string source-file))
(display "</pre>"))))
(define (display-files-html source-files-list) (define (display-files-html source-files-list)
(display "<ul>\n") (display "<ul>\n")