detect (er, ask git) if files are text or binary (ty m455 & acdw!)
also remove unused procedure display-readme-html
This commit is contained in:
parent
a97c673158
commit
d106bf4ca6
2 changed files with 13 additions and 6 deletions
|
@ -57,7 +57,6 @@ TODO
|
||||||
- **documenation**: scope the readme audience to folks who kind of know what they're doing with servers
|
- **documenation**: scope the readme audience to folks who kind of know what they're doing with servers
|
||||||
- **documentation/feature**: use post-update rather than post-receive hook for simplicity
|
- **documentation/feature**: use post-update rather than post-receive hook for simplicity
|
||||||
- **documentation**: also describe use with post-commit hook
|
- **documentation**: also describe use with post-commit hook
|
||||||
- **feature**: need better detection and rendering of binary files
|
|
||||||
- **feature**: multi-page or collapse-able files list
|
- **feature**: multi-page or collapse-able files list
|
||||||
- **feature**: commit log
|
- **feature**: commit log
|
||||||
- **feature**: branches and releases (tags)
|
- **feature**: branches and releases (tags)
|
||||||
|
|
18
main.scm
18
main.scm
|
@ -102,6 +102,13 @@ string-block
|
||||||
(define (in-git-directory?)
|
(define (in-git-directory?)
|
||||||
(not (eof-object? (call-with-input-pipe "git rev-parse --git-dir" read-line))))
|
(not (eof-object? (call-with-input-pipe "git rev-parse --git-dir" read-line))))
|
||||||
|
|
||||||
|
(define (is-text? path)
|
||||||
|
(not (equal?
|
||||||
|
"-\t-\t"
|
||||||
|
(call-with-input-pipe
|
||||||
|
(string-append "git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 --numstat HEAD -- " path)
|
||||||
|
(lambda (port) (read-line port 4))))))
|
||||||
|
|
||||||
(define (git-repository->paths-list)
|
(define (git-repository->paths-list)
|
||||||
(call-with-input-pipe "git ls-tree -r --name-only HEAD" read-lines))
|
(call-with-input-pipe "git ls-tree -r --name-only HEAD" read-lines))
|
||||||
|
|
||||||
|
@ -125,6 +132,8 @@ string-block
|
||||||
(display "<pre>")
|
(display "<pre>")
|
||||||
(display-escaped-html (git-file->string source-file))
|
(display-escaped-html (git-file->string source-file))
|
||||||
(display "</pre>"))
|
(display "</pre>"))
|
||||||
|
(define (binary)
|
||||||
|
(display "<p>(Binary file)</p>"))
|
||||||
(format #t "<p id=\"file-path\">~a</p>" source-file)
|
(format #t "<p id=\"file-path\">~a</p>" source-file)
|
||||||
(case (string->symbol (or source-extension source-filename))
|
(case (string->symbol (or source-extension source-filename))
|
||||||
;; markdown files get rendered in-place, unless there's an error, in which
|
;; markdown files get rendered in-place, unless there's an error, in which
|
||||||
|
@ -143,9 +152,11 @@ string-block
|
||||||
((svg)
|
((svg)
|
||||||
(image-link) (plaintext))
|
(image-link) (plaintext))
|
||||||
((gz pack idx)
|
((gz pack idx)
|
||||||
(display "<p>(Binary file)</p>"))
|
(binary))
|
||||||
(else
|
(else
|
||||||
(plaintext))))
|
(if (is-text? source-file)
|
||||||
|
(plaintext)
|
||||||
|
(binary)))))
|
||||||
|
|
||||||
(define (display-files-html source-files-list)
|
(define (display-files-html source-files-list)
|
||||||
(display "<ul>\n")
|
(display "<ul>\n")
|
||||||
|
@ -155,9 +166,6 @@ string-block
|
||||||
source-files-list)
|
source-files-list)
|
||||||
(display "</ul>\n"))
|
(display "</ul>\n"))
|
||||||
|
|
||||||
(define (display-readme-html)
|
|
||||||
(markdown->html (git-file->string "README.md")))
|
|
||||||
|
|
||||||
(define (display-contributors-html)
|
(define (display-contributors-html)
|
||||||
(SXML->HTML
|
(SXML->HTML
|
||||||
`((h1 "Contributors")
|
`((h1 "Contributors")
|
||||||
|
|
Loading…
Reference in a new issue