git-repo

Tools for sharing git bare repositories
git clone git://git.meso-star.fr/git-repo.git
Log | Files | Refs | README | LICENSE

commit 06484836f139aef9bede0dd7016df923beb4a1fa
parent 929c9306544cdb042dc49f27b51f37021beaa268
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 29 May 2025 11:58:36 +0200

Add HTML resources: favicon, logo and CSS

By default, these resources are installed in the /usr/local/share/
directory under the git-repo subdirectory. This appears to be the
conventional UNIX path for storing "local application data installed
that can be shared among differente architectures" (GNU/Linux hier(7)),
or in other words "architecture independent files" (OpenBSD hier(7)).
The git post-receive hook model is also installed in this directory

During installation, git-publish is patched with the path where the
resources are installed. It can then access and copy them into the
directory where the HTML pages of published git repositories are
deployed. In this way, the user no longer needs to ensure that a logo,
a favicon and a CSS style are in the WWW directory before publishing the
repository: if this is not the case, git-publish deploys these resources
by default.

Diffstat:
MMakefile | 18+++++++++++++++---
MREADME.md | 2+-
Mgit-publish | 38+++++++++++++++++++++++++++-----------
Alogo.png | 0
Astyle.css | 154+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 197 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile @@ -20,6 +20,7 @@ PREFIX = /usr/local BINPREFIX = $(PREFIX)/bin MANPREFIX = $(PREFIX)/share/man +APPPREFIX = $(PREFIX)/share # Nothing to do default: @@ -30,20 +31,31 @@ install: cp "$$@" "$${prefix}"; \ chmod "$${mode}" "$$@"; \ }; \ - install 755 "$(DESTDIR)$(BINPREFIX)" git-publish; \ install 755 "$(DESTDIR)$(BINPREFIX)" git-repo; \ install 644 "$(DESTDIR)$(MANPREFIX)/man1" git-repo.1; \ install 644 "$(DESTDIR)$(MANPREFIX)/man1" git-publish.1; \ - install 644 "$(DESTDIR)/etc/git-repo" post-receive.in + install 644 "$(DESTDIR)$(APPPREFIX)/git-repo" logo.png; \ + install 644 "$(DESTDIR)$(APPPREFIX)/git-repo" post-receive.in; \ + install 644 "$(DESTDIR)$(APPPREFIX)/git-repo" style.css; \ + install 644 "$(DESTDIR)$(PREFIX)/share/doc/git-repo" COPYING; \ + install 644 "$(DESTDIR)$(PREFIX)/share/doc/git-repo" README.md + sed 's#@RESOURCES_PATH@#$(DESTDIR)$(APPPREFIX)/git-repo#g' \ + git-publish > "$(DESTDIR)$(BINPREFIX)/git-publish" + chmod 755 "$(DESTDIR)$(BINPREFIX)/git-publish" uninstall: rm -f "$(DESTDIR)$(BINPREFIX)/git-publish" rm -f "$(DESTDIR)$(BINPREFIX)/git-repo" rm -f "$(DESTDIR)$(MANPREFIX)/man1/git-repo.1" rm -f "$(DESTDIR)$(MANPREFIX)/man1/git-publish.1" - rm -f "$(DESTDIR)/etc/git-repo/post-receive.in" + rm -f "$(DESTDIR)$(APPPREFIX)/git-repo/logo.png" + rm -f "$(DESTDIR)$(APPPREFIX)/git-repo/post-receive.in" + rm -f "$(DESTDIR)$(APPPREFIX)/git-repo/style.css" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/git-repo/README.md" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/git-repo/COPYING" lint: shellcheck -o all git-publish shellcheck -o all git-repo + mandoc -Wbase -Tlint git-publish.1 || [ $$? -le 1 ]; mandoc -Wbase -Tlint git-repo.1 diff --git a/README.md b/README.md @@ -23,7 +23,7 @@ This program is free software released under the GPL v3+ license: GNU GPL version 3 or later. You are welcome to redistribute them under certain conditions; refer to the COPYING file for details. -### post-receive.in +### post-receive.in & style.css Copyright (c) 2015-2024 Hiltjo Posthuma <hiltjo@codemadness.org> diff --git a/git-publish b/git-publish @@ -17,6 +17,19 @@ set -e +# Use string concatenation to check whether the RESOURCES_PATH +# meta-variable has been substituted. If not, it is assumed that the +# script is not installed and can therefore access resources locally. +# If not, this certainly means that the script has been installed, and +# therefore its resources too. RESOURCES_PATH should therefore define +# the installation path for the script's resources. +# shellcheck disable=SC2050 +if [ "@RESOURCES_PATH@" = '@'"RESOURCES_PATH"'@' ]; then + GIT_PUBLISH_RESOURCES_PATH="." +else + GIT_PUBLISH_RESOURCES_PATH="@RESOURCES_PATH@" +fi + ######################################################################## # Helper functions ######################################################################## @@ -40,11 +53,17 @@ synopsis() check_resources() # path { - if [ ! -e "$1"/favicon.png ] \ - || [ ! -e "$1"/logo.png ] \ - || [ ! -e "$1"/style.css ]; then - >&2 printf '%s: resources are missing\n' "$1" - return 1 + if [ ! -e "$1/favicon.png" ]; then + # Make the favicon from the logo + cp -L "${GIT_PUBLISH_RESOURCES_PATH}/logo.png" "$1/favicon.png" + fi + + if [ ! -e "$1/logo.png" ]; then + cp -L "${GIT_PUBLISH_RESOURCES_PATH}/logo.png" "$1/logo.png" + fi + + if [ ! -e "$1style.css" ]; then + cp -L "${GIT_PUBLISH_RESOURCES_PATH}/style.css" "$1/style.css" fi } @@ -92,6 +111,8 @@ publish_repo() mkdir -p "${repo_www}" # Generate HTML pages for the repository to be published + # Make sure the links are relative to the repository directory to + # avoid problems on the web server when it chroots cd "${repo_www}" stagit -c .cache -u "${base_url}/${repo_name}/" "${repo_git}" ln -sf './log.html' ./index.html @@ -108,12 +129,7 @@ publish_repo() # - repo: git bare repository setup_post_receive_hook() { - # The local template file takes precedence over the installed one - if [ -e "post-receive.in" ]; then - hook="post-receive.in" - else - hook="/etc/git-repo/post-receive.in" - fi + hook="${GIT_PUBLISH_RESOURCES_PATH}/post-receive.in" # Generate the post-receive script sed -e "s#@DIR_GIT@#${dir_git}#g" \ diff --git a/logo.png b/logo.png Binary files differ. diff --git a/style.css b/style.css @@ -0,0 +1,154 @@ +body { + color: #000; + background-color: #fff; + font-family: monospace; +} + +h1, h2, h3, h4, h5, h6 { + font-size: 1em; + margin: 0; +} + +img, h1, h2 { + vertical-align: middle; +} + +img { + border: 0; +} + +a:target { + background-color: #ccc; +} + +a.d, +a.h, +a.i, +a.line { + text-decoration: none; +} + +#blob a { + color: #555; +} + +#blob a:hover { + color: blue; + text-decoration: none; +} + +table thead td { + font-weight: bold; +} + +table td { + padding: 0 0.4em; +} + +#content table td { + vertical-align: top; + white-space: nowrap; +} + +#branches tr:hover td, +#tags tr:hover td, +#index tr:hover td, +#log tr:hover td, +#files tr:hover td { + background-color: #eee; +} + +#index tr td:nth-child(2), +#tags tr td:nth-child(3), +#branches tr td:nth-child(3), +#log tr td:nth-child(2) { + white-space: normal; +} + +td.num { + text-align: right; +} + +.desc { + color: #555; +} + +hr { + border: 0; + border-top: 1px solid #555; + height: 1px; +} + +pre { + font-family: monospace; +} + +pre a.h { + color: #00a; +} + +.A, +span.i, +pre a.i { + color: #070; +} + +.D, +span.d, +pre a.d { + color: #e00; +} + +pre a.h:hover, +pre a.i:hover, +pre a.d:hover { + text-decoration: none; +} + +@media (prefers-color-scheme: dark) { + body { + background-color: #000; + color: #bdbdbd; + } + hr { + border-color: #222; + } + a { + color: #56c8ff; + } + a:target { + background-color: #222; + } + .desc { + color: #aaa; + } + #blob a { + color: #555; + } + #blob a:target { + color: #eee; + } + #blob a:hover { + color: #56c8ff; + } + pre a.h { + color: #00cdcd; + } + .A, + span.i, + pre a.i { + color: #00cd00; + } + .D, + span.d, + pre a.d { + color: #cd0000; + } + #branches tr:hover td, + #tags tr:hover td, + #index tr:hover td, + #log tr:hover td, + #files tr:hover td { + background-color: #111; + } +}