diff options
author | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
commit | 8cf813ff033bbc98a7dd40db6ac11e2e35c7e997 (patch) | |
tree | a451059194cbd4ba90993ebdaced4749448ec4df /cgit | |
download | asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.tar.gz asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.zip |
initial commit
Diffstat (limited to 'cgit')
-rwxr-xr-x | cgit/css.sh | 34 | ||||
-rw-r--r-- | cgit/header.html | 1 | ||||
-rwxr-xr-x | cgit/hide.sh | 11 | ||||
-rwxr-xr-x | cgit/new.sh | 19 | ||||
-rw-r--r-- | cgit/patch.css | 5 | ||||
-rw-r--r-- | cgit/private | 20 | ||||
-rw-r--r-- | cgit/public | 24 | ||||
-rw-r--r-- | cgit/sync.py | 21 | ||||
-rwxr-xr-x | cgit/unhide.sh | 11 |
9 files changed, 146 insertions, 0 deletions
diff --git a/cgit/css.sh b/cgit/css.sh new file mode 100755 index 0000000..b0fd633 --- /dev/null +++ b/cgit/css.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +test -d cgit/css && rm -r cgit/css +mkdir cgit/css + +function compile { + local variant=$1 + local css=$2 + curl -L "https://github.com/ArmandPhilippot/coldark-bat/raw/master/Coldark-$variant.tmTheme" \ + | MODE=theme cgit-syntect - cgit/css/$css.css cgit/css/scopes + sed -i 's/background-color: .*//' cgit/css/$css.css # we don't actually want that +} + +compile Cold light +compile Dark dark + +curl https://git.kernel.org/cgit-data/cgit.css \ + | tail -n+2 \ + | sed 's/font-family: .* monospace/font-family: monospace/' \ + | sed -n '/Style definition file/q;p' \ + > cgit/css/kernel.css + +{ + echo '/* adapted from https://git.kernel.org/cgit-data/cgit.css */' + cat cgit/css/kernel.css + cat cgit/css/light.css + echo "@media only all and (prefers-color-scheme: dark) {" + cat cgit/css/dark.css + echo "}" + cat cgit/patch.css +} | prettier --parser css > cgit/css/style.css + +# rm -r cgit/css diff --git a/cgit/header.html b/cgit/header.html new file mode 100644 index 0000000..c9f6673 --- /dev/null +++ b/cgit/header.html @@ -0,0 +1 @@ +<a href="/priv" id="visibility">%</a> diff --git a/cgit/hide.sh b/cgit/hide.sh new file mode 100755 index 0000000..e0b0fba --- /dev/null +++ b/cgit/hide.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# shellcheck disable=SC2086 +set -e + +if [ -z "$1" ]; then + echo missing name + exit 1 +fi + +set -x +ssh git@asylum rm $1.git/git-daemon-export-ok diff --git a/cgit/new.sh b/cgit/new.sh new file mode 100755 index 0000000..25f11a1 --- /dev/null +++ b/cgit/new.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# shellcheck disable=SC2086,SC2162 +set -e + +if [ -z "$1" ]; then + echo missing name + exit 1 +fi + +read -n1 -p "Make public? " public +echo + +set -x +ssh git@asylum mkdir $1.git '&&' cd $1.git '&&' git init --bare +ssh -t git@asylum rm $1.git/description '&&' micro $1.git/description + +if [ $public = y ]; then + ssh git@asylum touch $1.git/git-daemon-export-ok +fi diff --git a/cgit/patch.css b/cgit/patch.css new file mode 100644 index 0000000..9a28e0d --- /dev/null +++ b/cgit/patch.css @@ -0,0 +1,5 @@ +#visibility { + position: absolute; + right: 1em; + text-decoration: none; +} \ No newline at end of file diff --git a/cgit/private b/cgit/private new file mode 100644 index 0000000..b2e9f73 --- /dev/null +++ b/cgit/private @@ -0,0 +1,20 @@ +# shellcheck disable=all # this isn't a shell file, dingus + +about-filter=/usr/bin/cgit-about-filter.sh +clone-url=git@asylum:$CGIT_REPO_URL +css=/style.css +enable-blame=1 +enable-git-config=1 +enable-index-owner=0 +enable-log-filecount=1 +enable-log-linecount=1 +header=/etc/cgit/private-header.html +logo-link=https://git.causal.agency/cgit-pink/about/ +readme=:README.md +root-desc=private git repositories +snapshots=tar.gz zip +source-filter=/usr/bin/cgit-syntect +virtual-root=/priv + +remove-suffix=1 +scan-path=/srv/git diff --git a/cgit/public b/cgit/public new file mode 100644 index 0000000..d6633de --- /dev/null +++ b/cgit/public @@ -0,0 +1,24 @@ +# shellcheck disable=all # this isn't a shell file, dingus + +about-filter=/usr/bin/cgit-about-filter.sh +clone-url=https://$HTTP_HOST/$CGIT_REPO_URL git@asylum:$CGIT_REPO_URL +css=/style.css +enable-blame=1 +enable-git-config=1 +enable-index-owner=0 +enable-log-filecount=1 +enable-log-linecount=1 +header=/etc/cgit/public-header.html +logo-link=https://git.causal.agency/cgit-pink/about/ +readme=:README.md +root-desc=personal git repositories +snapshots=tar.gz zip +source-filter=/usr/bin/cgit-syntect +virtual-root=/ + +cache-root=/srv/git/.cache +cache-size=1M + +remove-suffix=1 +strict-export=git-daemon-export-ok +scan-path=/srv/git diff --git a/cgit/sync.py b/cgit/sync.py new file mode 100644 index 0000000..506c811 --- /dev/null +++ b/cgit/sync.py @@ -0,0 +1,21 @@ +from commia.prelude import * +from commia.ssh import scp, ssh_args +from commia.util import with_written + +run_check( + [*ssh_args(), "sh", "-c", "cat > /usr/bin/cgit-about-filter.sh"], + input=b"#!/bin/sh\nmd2html", # discard arguments +) +run_check([*ssh_args(), "chmod", "+x", "/usr/bin/cgit-about-filter.sh"]) +scp("cgit/public", "asylum:/etc/cgit/public") +scp("cgit/private", "asylum:/etc/cgit/private") +if Path("cgit/css").exists(): + scp("cgit/css/style.css", "asylum:/usr/share/webapps/cgit/style.css") + scp("cgit/css/scopes", "asylum:/usr/share/cgit-syntect/scopes") + +for sym, vis in [("🗝", "public"), ("⛯", "private")]: + with_written( + f"<a href=/{'priv' if vis == 'public' else ''} id=visibility>{sym}</a>", + lambda path: scp(path, f"asylum:/etc/cgit/{vis}-header.html"), + ) + run([*ssh_args(), "chmod", "+r", f"/etc/cgit/{vis}-header.html"]) diff --git a/cgit/unhide.sh b/cgit/unhide.sh new file mode 100755 index 0000000..06fda05 --- /dev/null +++ b/cgit/unhide.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# shellcheck disable=SC2086 +set -e + +if [ -z "$1" ]; then + echo missing name + exit 1 +fi + +set -x +ssh git@asylum touch $1.git/git-daemon-export-ok |