implement commit log! also, tabulate contributors

This commit is contained in:
pho4cexa 2022-12-09 20:55:33 -08:00 committed by m455
parent fecd7af9c3
commit 75b7406508
2 changed files with 27 additions and 6 deletions

View file

@ -58,12 +58,12 @@ TODO
- **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**: multi-page or collapse-able files list - **feature**: multi-page or collapse-able files list
- **feature**: commit log
- **feature**: branches and releases (tags) - **feature**: branches and releases (tags)
- **feature**: clickable line numbers in source files - **feature**: clickable line numbers in source files
- **feature**: customizable templates - **feature**: customizable templates
- **feature**: display binary files as output from binary-file analysis tools like hexdump, xxd, dumpelf, elfls, readelf, etc.? - **feature**: display binary files as output from binary-file analysis tools like hexdump, xxd, dumpelf, elfls, readelf, etc.?
- **feature**: syntax highlighting? - **feature**: syntax highlighting?
- **bug**: markdown-render and/or html-escape git log text
## license: agpl-3.0+ ## license: agpl-3.0+

View file

@ -65,6 +65,10 @@ hr {
border-bottom: 1px solid black; border-bottom: 1px solid black;
margin-top: 16px; margin-top: 16px;
} }
td {
padding: 0em .5em;
vertical-align: top;
}
##file-path { ##file-path {
/* change this to your liking */ /* change this to your liking */
} }
@ -84,6 +88,7 @@ hr {
(string-append "<a href=\"" relative-root "LICENSE.html\">license</a>")) (string-append "<a href=\"" relative-root "LICENSE.html\">license</a>"))
((member "LICENSE.md" source-files-list) ((member "LICENSE.md" source-files-list)
(string-append "<a href=\"" relative-root "LICENSE.md.html\">license</a>"))) (string-append "<a href=\"" relative-root "LICENSE.md.html\">license</a>")))
<a href="#{relative-root}commits.html">commits</a>
<a href="#{relative-root}contributors.html">contributors</a> <a href="#{relative-root}contributors.html">contributors</a>
</nav> </nav>
<hr> <hr>
@ -166,13 +171,28 @@ string-block
source-files-list) source-files-list)
(display "</ul>\n")) (display "</ul>\n"))
(define (display-commits-html)
(SXML->HTML
`((h1 "Commits")
(table
(tr (th "Date") (th "Ref") (th "Log") (th "Author"))
,(map
(lambda (line)
(let-values (((date ref title author) (apply values (string-split line "\t"))))
`(tr (td ,date) (td ,ref) (td ,title) (td ,author))))
(call-with-input-pipe
"git log --format=format:%as%x09%h%x09%s%x09%aN HEAD"
read-lines))))))
(define (display-contributors-html) (define (display-contributors-html)
(SXML->HTML (SXML->HTML
`((h1 "Contributors") `((h1 "Contributors")
(ul ,(map (table
(tr (th "Author") (th "Commits"))
,(map
(lambda (line) (lambda (line)
(let-values (((commits . author) (apply values (string-split line "\t")))) (let-values (((commits . author) (apply values (string-split line "\t"))))
`(li ,author))) `(tr (td ,author) (td ,commits))))
(call-with-input-pipe "git shortlog -ns HEAD" read-lines)))))) (call-with-input-pipe "git shortlog -ns HEAD" read-lines))))))
(define (first-if pred lst) (define (first-if pred lst)
@ -195,6 +215,7 @@ string-block
;; special files ;; special files
(write-with-template "files.html" (lambda () (display-files-html source-files-list))) (write-with-template "files.html" (lambda () (display-files-html source-files-list)))
(write-with-template "contributors.html" display-contributors-html) (write-with-template "contributors.html" display-contributors-html)
(write-with-template "commits.html" display-commits-html)
;; htmlified repo contents ;; htmlified repo contents
(for-each (for-each
(lambda (source-file) (lambda (source-file)