check file existence in source-files-list not cwd
added source-files-list to populate-html-template. kindof dislike having so many variables passed to a function but i also kindof dislike global variables; not sure how to make this prettier yet. but this solves the bug i introduced in my last commit where the nav links were broken when used as a githook.
This commit is contained in:
parent
c645880703
commit
626a84a76e
2 changed files with 10 additions and 7 deletions
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
Assuming the current directory is a Git repository, this command populates *DESTINATION* with HTML files that provide a web-browsable view of the contents of the git repository.
|
Assuming the current directory is a Git repository, this command populates *DESTINATION* with HTML files that provide a web-browsable view of the contents of the git repository.
|
||||||
|
|
||||||
|
Note: changes must be at least committed before they will appear in the HTML output.
|
||||||
|
More precisely: the HTML output represents the state of the HEAD commit, not that of the current work-tree (if any).
|
||||||
|
|
||||||
You may also cause this directory to be automatically updated upon every `git push`, by invoking *repo2html* as a Git *post-receive hook*.
|
You may also cause this directory to be automatically updated upon every `git push`, by invoking *repo2html* as a Git *post-receive hook*.
|
||||||
|
|
||||||
## features
|
## features
|
||||||
|
|
14
main.scm
14
main.scm
|
@ -19,7 +19,7 @@
|
||||||
(define DESCRIPTION (or (get-environment-variable "REPO2HTML_DESCRIPTION") "my git repositories"))
|
(define DESCRIPTION (or (get-environment-variable "REPO2HTML_DESCRIPTION") "my git repositories"))
|
||||||
(define H1 (or (get-environment-variable "REPO2HTML_H1") "git.example.com"))
|
(define H1 (or (get-environment-variable "REPO2HTML_H1") "git.example.com"))
|
||||||
|
|
||||||
(define (populate-html-template repository-name source-file display-body-thunk)
|
(define (populate-html-template repository-name source-files-list source-file display-body-thunk)
|
||||||
(define-values (source-directory source-filename source-extension)
|
(define-values (source-directory source-filename source-extension)
|
||||||
(decompose-pathname source-file))
|
(decompose-pathname source-file))
|
||||||
(define-values (base-origin base-directory directory-elements)
|
(define-values (base-origin base-directory directory-elements)
|
||||||
|
@ -75,14 +75,14 @@ hr {
|
||||||
<h2>#{repository-name}</h2>
|
<h2>#{repository-name}</h2>
|
||||||
<p>clone url: #{CLONE-URL}/#{repository-name}</p>
|
<p>clone url: #{CLONE-URL}/#{repository-name}</p>
|
||||||
<nav>
|
<nav>
|
||||||
#(if (or (file-exists? "README")
|
#(if (or (member "README" source-files-list)
|
||||||
(file-exists? "README.md")
|
(member "README.md" source-files-list)
|
||||||
(file-exists? "README.txt"))
|
(member "README.txt" source-files-list))
|
||||||
(string-append "<a href=\"" relative-root "index.html\">about</a>"))
|
(string-append "<a href=\"" relative-root "index.html\">about</a>"))
|
||||||
<a href="#{relative-root}files.html">files</a>
|
<a href="#{relative-root}files.html">files</a>
|
||||||
#(cond ((file-exists? "LICENSE")
|
#(cond ((member "LICENSE" source-files-list)
|
||||||
(string-append "<a href=\"" relative-root "LICENSE.html\">license</a>"))
|
(string-append "<a href=\"" relative-root "LICENSE.html\">license</a>"))
|
||||||
((file-exists? "LICENSE.md")
|
((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}contributors.html">contributors</a>
|
<a href="#{relative-root}contributors.html">contributors</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -181,7 +181,7 @@ string-block
|
||||||
(when destination-directory
|
(when destination-directory
|
||||||
(create-directory (make-pathname html-repo-path destination-directory) #t)))
|
(create-directory (make-pathname html-repo-path destination-directory) #t)))
|
||||||
(with-output-to-file (make-pathname html-repo-path filename)
|
(with-output-to-file (make-pathname html-repo-path filename)
|
||||||
(lambda () (populate-html-template repository-name filename display-body-thunk))))
|
(lambda () (populate-html-template repository-name source-files-list filename display-body-thunk))))
|
||||||
|
|
||||||
(create-directory html-repo-path #t)
|
(create-directory html-repo-path #t)
|
||||||
;; special files
|
;; special files
|
||||||
|
|
Loading…
Reference in a new issue