No description
Find a file
pho4cexa 50bbb3686d 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 14:51:23 -05:00
.gitignore lightened shade of the default pink 2022-12-02 16:47:20 -05:00
git-daemon.service first commit 2022-12-02 16:41:55 -05:00
LICENSE added license :) 2022-12-04 00:51:48 -05:00
main.scm massive changes incl. support for images, markdown 2022-12-07 14:51:23 -05:00
Makefile first commit 2022-12-02 16:41:55 -05:00
post-receive massive changes incl. support for images, markdown 2022-12-07 14:51:23 -05:00
README.md removed some out-of-scope sections 2022-12-06 00:07:43 -05:00

repo2html

a post-receive hook that generates an html view of a git repository.

features

  • static html files
  • no background process other than git-daemon
  • default repository view is an html-rendered README.md file

caveats

  • binary file contents are just... shown
  • images don't render
  • directory tree is shown as a flat list of files, so git repositories with many files and directories will look awful
  • no commit log (yet?)
  • no line numbers (yet?)

disclaimer

no one is liable if this software breaks, deletes, corrupts, or ruins anything

requirements

note: if you have chicken scheme installed, then you can install the eggs above by running make dependencies as root.

compilation

chicken scheme runs faster if it's compiled to a binary file. by default, the binary is named repo2html, and is installed in /usr/local/bin.

to compile repo2html into a binary file, follow the steps below:

  1. ensure you're in the repo2html git repository
  2. run make dependencies as root
  3. run make
  4. run make install as root

configuration

you can configure repo2html by changing environment variables in the post-receive hook file.

for details about the environment variables, refer to the list below:

  • GIT_WWW: the web directory where repo2html generates static git repositories. for example, /var/www/git/.
  • GIT_WWW_CLONE_URL: the url that people will use when downloading your git repository. if you have git-daemon set up, then you can prefix the url with git://. otherwise, prefix the url with http://. for example, git://git.example.com. note: avoid slashes at the end of the url.
  • GIT_WWW_TITLE: the text that populates the <title> html tag.
  • GIT_WWW_DESCRIPTION: a string that populates the description meta information about your git repository.
  • GIT_WWW_H1: the text that populates the <h1> html tag.

how it works

TODO

todos

  • ☐ if no README.md file exists in the root directory of the repository, then don't create the "about" nav link. instead, make the files page the index.html
  • ☐ add a "license" nav link if a LICENSE file exists in the root directory of the repository. if no LICENSE file exists, then don't create the "license" nav link
  • ☐ add a "contributors" nav link

hopes

  • ☐ clickable line numbers in source files
  • ☐ render images
  • ☐ make repos with more files and directories less daunting (recursively generate a files list page for each directory in a repo?)
  • ☐ nav link: Releases