2022-12-02 16:41:55 -05:00
# repo2html
2022-12-02 17:13:34 -05:00
a post-receive hook that generates an html view of a git repository.
2022-12-02 16:41:55 -05:00
## features
2022-12-04 00:44:52 -05:00
- static html files
- no background process other than git-daemon
- default repository view is an html-rendered README.md file
2022-12-02 16:41:55 -05:00
## caveats
2022-12-04 00:44:52 -05:00
- 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?)
2022-12-02 16:41:55 -05:00
## disclaimer
2022-12-04 00:44:52 -05:00
no one is liable if this software breaks, deletes, corrupts, or ruins anything
2022-12-02 16:41:55 -05:00
## requirements
2022-12-02 16:54:38 -05:00
- [chicken scheme ](https://call-cc.org/ )
- [utf8 egg ](https://wiki.call-cc.org/eggref/5/utf8 )
- [lowdown egg ](https://wiki.call-cc.org/eggref/5/lowdown )
2022-12-04 00:44:52 -05:00
- git
2022-12-02 16:54:38 -05:00
**note**: if you have chicken scheme installed, then you can install the eggs
above by running `sudo make dependencies` .
2022-12-02 16:41:55 -05:00
## quickstart
2022-12-04 00:44:52 -05:00
on your server, run the following commands, changing anything occurs between angled brackets ("< " and ">"):
adduser git
mkdir /var/www/git
chown git:git /var/www/git
cp git-daemon.service /etc/systemd/system/
ufw allow 9418
systemctl enable --now git-daemon.service
2022-12-04 01:30:02 -05:00
su git
cd
mkdir .ssh & & chmod 700 .ssh
touch .ssh/authorized_keys & & chmod 600 .ssh/authorized_keys
add your public ssh key to .ssh/authorized_keys
2022-12-04 00:44:52 -05:00
mkdir projects
clone this repository
cd into this repository
sudo make dependencies
make
sudo make install
edit the post-receive file
cp post-receive < path / to / bare / git / repository > /hooks/
chmod u+x < path / to / bare / git / repository > /hooks/post-receive
then in a git repository on your local machine, run git remote add origin git@< example.com > :~/projects/< repository-name >
git push
2022-12-02 16:41:55 -05:00
## compilation
2022-12-04 01:25:44 -05:00
chicken scheme runs faster if it's compiled to a binary file. by default, the
binary is named `repo2html` , and is added to `/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
2022-12-02 16:41:55 -05:00
2022-12-02 17:34:21 -05:00
## server setup
2022-12-02 16:41:55 -05:00
TODO (git user, ssh, ufw ports, web directory, git-daemon, mkdir /home/git/projects, post-receive hook, systemd service)
## usage
2022-12-04 01:25:44 -05:00
after you've set up your server and set your remote git url on your local
machine, you can use `git push` to push updates to your projects, and the
`post-receive` hook will generate an html version of your git repository.
2022-12-02 16:41:55 -05:00
## configuration
2022-12-04 01:25:44 -05:00
you can configure repo2html by changing environment variables in the `post-receive` hook file.
refer to the list of environment variable names and their descriptions to learn more:
- `GIT_WWW` : the web directory where repo2html generates static git repositories. for example, `/var/www/git/` .
2022-12-04 01:34:19 -05:00
- `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.
2022-12-04 01:25:44 -05:00
- `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.
2022-12-02 16:41:55 -05:00
## todos
2022-12-04 00:58:51 -05:00
- ☐ 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
2022-12-02 16:41:55 -05:00
## hopes
2022-12-02 23:31:54 -05:00
- ☐ 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