2022-12-07 19:17:44 -05:00
|
|
|
#!/usr/bin/csi -s
|
2022-12-04 15:17:29 -05:00
|
|
|
|
2022-12-02 16:41:55 -05:00
|
|
|
(import utf8
|
|
|
|
lowdown
|
|
|
|
(chicken string)
|
|
|
|
(chicken port)
|
|
|
|
(chicken io)
|
|
|
|
(chicken process)
|
|
|
|
(chicken process-context)
|
|
|
|
(chicken format)
|
|
|
|
(chicken pathname)
|
2022-12-04 21:07:09 -05:00
|
|
|
(chicken file)
|
|
|
|
sxml-transforms
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(clojurian syntax)
|
2022-12-04 21:07:09 -05:00
|
|
|
)
|
2022-12-02 16:41:55 -05:00
|
|
|
|
2022-12-07 15:32:06 -05:00
|
|
|
(define CLONE-URL (or (get-environment-variable "REPO2HTML_CLONE_URL") "git://git.example.com"))
|
|
|
|
(define TITLE (or (get-environment-variable "REPO2HTML_TITLE") "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"))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
2022-12-07 21:42:04 -05:00
|
|
|
(define (populate-html-template repository-name display-body-thunk)
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(display #<#string-block
|
2022-12-02 16:41:55 -05:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2022-12-02 17:54:10 -05:00
|
|
|
<title>#{TITLE}</title>
|
2022-12-02 16:41:55 -05:00
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
|
|
<link rel="icon" href="data:,">
|
2022-12-02 17:54:10 -05:00
|
|
|
<meta name="description" content="#{DESCRIPTION}"/>
|
2022-12-02 16:41:55 -05:00
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 0 auto;
|
|
|
|
max-width: 700px;
|
|
|
|
}
|
2022-12-03 00:47:48 -05:00
|
|
|
pre, code {
|
2022-12-02 17:54:10 -05:00
|
|
|
background-color: ##ffd9df;
|
2022-12-03 00:47:48 -05:00
|
|
|
}
|
|
|
|
pre {
|
2022-12-02 16:41:55 -05:00
|
|
|
padding: 15px 20px;
|
|
|
|
white-space: pre;
|
|
|
|
overflow: scroll;
|
|
|
|
}
|
|
|
|
a { color: blue; }
|
|
|
|
nav a { margin-right: 10px; }
|
|
|
|
hr {
|
|
|
|
border:0;
|
|
|
|
border-bottom: 1px solid black;
|
|
|
|
margin-top: 16px;
|
|
|
|
}
|
2022-12-02 17:54:10 -05:00
|
|
|
##file-path {
|
2022-12-02 16:41:55 -05:00
|
|
|
/* change this to your liking */
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2022-12-02 17:54:10 -05:00
|
|
|
<h1>#{H1}</h1>
|
2022-12-07 21:42:04 -05:00
|
|
|
<h2>#{repository-name}</h2>
|
|
|
|
<p>clone url: #{CLONE-URL}/#{repository-name}</p>
|
2022-12-02 16:41:55 -05:00
|
|
|
<nav>
|
2022-12-07 21:42:04 -05:00
|
|
|
<a href="/#{repository-name}/index.html">about</a>
|
|
|
|
<a href="/#{repository-name}/files.html">files</a>
|
|
|
|
<a href="/#{repository-name}/contributors.html">contributors</a>
|
2022-12-02 16:41:55 -05:00
|
|
|
</nav>
|
|
|
|
<hr>
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
string-block
|
|
|
|
)
|
|
|
|
(display-body-thunk)
|
|
|
|
(display #<#string-block
|
2022-12-02 16:41:55 -05:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
string-block
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(define (display-escaped-html str)
|
|
|
|
(SRV:send-reply (string->goodHTML str)))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
|
|
|
(define (in-git-directory?)
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(not (eof-object? (call-with-input-pipe "git rev-parse --git-dir" read-line))))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
|
|
|
(define (git-repository->paths-list)
|
|
|
|
(call-with-input-pipe "git ls-tree -r --name-only HEAD" read-lines))
|
|
|
|
|
|
|
|
(define (git-file->string path)
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(->
|
|
|
|
(format "git show HEAD:~a" path)
|
|
|
|
(call-with-input-pipe read-lines)
|
|
|
|
(string-intersperse "\n")))
|
|
|
|
|
2022-12-07 22:31:58 -05:00
|
|
|
(define (display-source-html source-file) ;; src/main.scm
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(format #t "<p id=\"file-path\">~a</p>" source-file)
|
2022-12-07 19:17:48 -05:00
|
|
|
(case (string->symbol (or (pathname-extension source-file) "no-extension"))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
((md markdown)
|
2022-12-07 19:17:48 -05:00
|
|
|
(handle-exceptions exn
|
|
|
|
(begin
|
|
|
|
(display "Error parsing " (current-error-port))
|
|
|
|
(display source-file (current-error-port))
|
|
|
|
(display "\n" (current-error-port))
|
|
|
|
(display "<p><b>There was an error parsing this file as Markdown.</b></p>")
|
|
|
|
(display "<pre>")
|
|
|
|
(display-escaped-html (git-file->string source-file))
|
|
|
|
(display "</pre>"))
|
|
|
|
(markdown->html (git-file->string source-file))))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
((jpg jpeg png gif webp webm apng avif svgz ico)
|
2022-12-07 22:31:58 -05:00
|
|
|
(format #t "<p><img src=\"~a\" /></p>" (pathname-strip-directory repository-name) source-file))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
((svg)
|
2022-12-07 22:31:58 -05:00
|
|
|
(format #t "<p><img src=\"~a\" /></p>" (pathname-strip-directory repository-name) source-file)
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(display "<pre>")
|
|
|
|
(display-escaped-html (git-file->string source-file))
|
|
|
|
(display "</pre>"))
|
2022-12-07 19:17:48 -05:00
|
|
|
((gz pack idx)
|
|
|
|
(display "<p>(Binary file)</p>"))
|
|
|
|
((txt no-extension)
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(display "<pre>")
|
|
|
|
(display-escaped-html (git-file->string source-file))
|
2022-12-07 19:17:48 -05:00
|
|
|
(display "</pre>"))
|
|
|
|
(else
|
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.
2022-12-07 21:27:30 -05:00
|
|
|
(display "<pre>")
|
|
|
|
(display-escaped-html (git-file->string source-file))
|
|
|
|
(display "</pre>"))))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
|
|
|
|
(define (display-files-html source-files-list)
|
|
|
|
(display "<ul>\n")
|
|
|
|
(for-each
|
|
|
|
(lambda (source-file)
|
|
|
|
(format #t "<li><a href=\"~a.html\">~a</a></li>\n" source-file source-file))
|
|
|
|
source-files-list)
|
|
|
|
(display "</ul>\n"))
|
|
|
|
|
|
|
|
(define (display-readme-html)
|
|
|
|
(markdown->html (git-file->string "README.md")))
|
|
|
|
|
|
|
|
(define (display-contributors-html)
|
|
|
|
(SXML->HTML
|
|
|
|
`((h1 "Contributors")
|
|
|
|
(ul ,(map
|
|
|
|
(lambda (line)
|
|
|
|
(let-values (((commits . author) (apply values (string-split line "\t"))))
|
|
|
|
`(li ,author)))
|
|
|
|
(call-with-input-pipe "git shortlog -ns HEAD" read-lines))))))
|
|
|
|
|
|
|
|
(define (generate-html-files html-repo-path)
|
|
|
|
(let ((source-files-list (git-repository->paths-list))
|
|
|
|
(repository-name (pathname-strip-directory html-repo-path)))
|
|
|
|
|
|
|
|
(define (write-with-template filename display-body-thunk)
|
|
|
|
(let ((destination-directory (pathname-directory filename)))
|
2022-12-07 19:17:46 -05:00
|
|
|
(when destination-directory
|
|
|
|
(create-directory (make-pathname html-repo-path destination-directory) #t)))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(with-output-to-file (make-pathname html-repo-path filename)
|
|
|
|
(lambda () (populate-html-template repository-name display-body-thunk))))
|
|
|
|
|
|
|
|
(create-directory html-repo-path #t)
|
|
|
|
|
|
|
|
(write-with-template "index.html" (lambda () (display-readme-html)))
|
|
|
|
(write-with-template "files.html" (lambda () (display-files-html source-files-list)))
|
|
|
|
(write-with-template "contributors.html" (lambda () (display-contributors-html)))
|
|
|
|
(for-each
|
|
|
|
(lambda (source-file)
|
|
|
|
(write-with-template
|
|
|
|
(string-append source-file ".html")
|
2022-12-07 22:31:58 -05:00
|
|
|
(lambda () (display-source-html source-file)))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(case (string->symbol (or (pathname-extension source-file) ""))
|
|
|
|
((jpg jpeg png gif webp webm svg apng avif svgz ico)
|
2022-12-07 19:17:49 -05:00
|
|
|
(system (format "git show HEAD:~a > ~a"
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
source-file
|
2022-12-07 19:17:49 -05:00
|
|
|
(make-pathname html-repo-path source-file))))))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
source-files-list)))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
2022-12-04 15:17:31 -05:00
|
|
|
(define (bail . args)
|
|
|
|
(let-optionals args ((status 1) (msg ""))
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(unless (equal? "" msg) (print msg))
|
|
|
|
(exit status)))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
|
|
|
(define (main args)
|
2022-12-07 19:17:47 -05:00
|
|
|
(let-optionals args ((html-repo-path ""))
|
2022-12-02 16:41:55 -05:00
|
|
|
|
2022-12-07 19:17:47 -05:00
|
|
|
(when (equal? html-repo-path "")
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(bail 1 "please specify a destination directory for html files"))
|
2022-12-04 15:17:31 -05:00
|
|
|
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(unless (in-git-directory?)
|
|
|
|
(bail 1 "woops this isn't a git directory"))
|
2022-12-04 15:17:31 -05:00
|
|
|
|
massive changes incl. support for images, markdown
i started this off by trying to learn more about how scheme does file
i/o. it seems like many of its functions just expect you'll want them to
write to (current-output-port) instead of returning a string. so i
thought, i wonder what it would look like if i tweak these content
generator functions to just (display) their stuff, and
call (with-output-to-file) and apply the html template each time i call
them?
and whew it kindof got away from me
i totally understand if you feel like this is an unpleasant overhaul of
your whole project and don't want to merge this change!
anyway let's see if i can summarize the changes:
- image support!!
- svg image support!! it shows both the svg and its source code!
- markdown support; we now render all .md files instead of showing source
- using string->goodHTML instead of clean-html. turns out, it's a little
annoying, in that it only returns a string if it makes no changes, but
if it does, it returns a list of strings. it expects to be passed to
one of the other functions in the sxml library, so that's what i do.
- moved "wrap the template" outside of various "generate content"
functions
- simple command line use: from any git work-tree OR bare repo, run
repo2html /path/to/www/output/repo-foo-bar and it will create that
directory and use "repo-foo-bar" as the repo name.
- made our example post-receive a bit more robust
- changed env var names to have REPO2HTML_ prefix
- better repo name detection and automatic caching of it in git config
- moved the post-receive-specific logic to avoid generating if we're
not updating HEAD into the post-receive hook itself, along with some
status messages
- checked directory permissions in the hook so it doesn't even attempt
to run repo2html and avoids a crash
2022-12-07 04:00:52 -05:00
|
|
|
(generate-html-files html-repo-path)))
|
2022-12-04 15:17:31 -05:00
|
|
|
|
|
|
|
(main (command-line-arguments))
|