pub / stagit-scripts

Building src.jayvii.de with stagit
git clone https://src.jayvii.de/pub/stagit-scripts.git
Home | Log | Files | Exports | Refs | README | RSS

commit aae53642cf512ee70b78634cca828869cc170bef
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sun, 19 Sep 2021 21:35:11 +0200

initial set of scripts and assets

Diffstat:
Aassets/favicon.png | 0
Aassets/index.css | 43+++++++++++++++++++++++++++++++++++++++++++
Aassets/style.css | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/git_create_repo.sh | 40++++++++++++++++++++++++++++++++++++++++
Abin/git_post_push.sh | 7+++++++
Abin/git_set_clone_url.sh | 8++++++++
Abin/git_update_index_html.sh | 13+++++++++++++
Abin/git_update_repo.sh | 17+++++++++++++++++
Abin/git_update_repo_html.sh | 23+++++++++++++++++++++++
Abin/git_watcher.sh | 7+++++++
Afavicon.png | 2++
Aindex.html | 23+++++++++++++++++++++++
Alogo.png | 2++
Astyle.css | 2++
14 files changed, 317 insertions(+), 0 deletions(-)

diff --git a/assets/favicon.png b/assets/favicon.png Binary files differ. diff --git a/assets/index.css b/assets/index.css @@ -0,0 +1,43 @@ +/* Dark Mode: Default */ +:root { + --fg1: #f8f8f2; + --bg1: #1d1e26; + --bg2: #000000CC; + --hl1: #ff80bf; + --hl2: #fffc81; +} + +/* Bright Mode */ +@media (prefers-color-scheme: light) { + :root { + --fg1: #1d1e26; + --bg1: #f8f8f2; + --bg2: #000000CC; + } +} + +address { + display: none; +} +body { + background-color: var(--bg1); + color: var(--fg1); +} +table { + background-color: var(--bg2); + border-radius: 5px; + color: var(--fg1); + margin-left: auto; + margin-right: auto; +} + +a { + color: var(--hl1); + padding: 5px; + border-radius: 5px; +} + +a:hover, a:active { + color: var(--hl2); +} + diff --git a/assets/style.css b/assets/style.css @@ -0,0 +1,130 @@ +/* Dark Mode: Default */ +:root { + --fg1: #f8f8f2; + --bg1: #1d1e26; + --bg2: #000000CC; + --hl1: #ff80bf; + --hl2: #fffc81; +} + +/* Bright Mode */ +@media (prefers-color-scheme: light) { + :root { + --fg1: #1d1e26; + --bg1: #f8f8f2; + --bg2: #000000CC; + } +} + +body { + font-family: monospace; + font-size: 1.25em; + color: var(--fg1); + background-color: var(--bg1); +} +img { + border: 0; +} + +h1, h2, h3, h4, h5, h6 { + font-size: 1.5em; + margin: 0; +} + +img, h1, h2 { + vertical-align: middle; +} + +a:target { + background-color: var(--bg2); +} + +a.d, +a.h, +a.i, +a.line { + text-decoration: none; +} + +#blob a { + color: var(--hl1); + border-right: 3px solid #aaa; + padding: 0 5px 0 0; +} + +#blob a:hover { + color: var(--hl1); + text-decoration: none; +} + +table thead td { + font-weight: bold; +} + +table td { + padding: 0 0.4em; +} + +#content table td { + white-space: nowrap; + vertical-align: top; +} + +#branches tr:hover td, +#tags tr:hover td, +#index tr:hover td, +#log tr:hover td, +#files tr:hover td { + background-color: var(--bg2); +} + +#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: var(--hl2); +} + +hr { + border: 0; + border-top: 3px solid var(--hl1); + height: 3px; +} + +#content hr { + display: none; +} + +pre { + font-family: monospace; +} + +pre a.h { + color: var(--hl1); +} + +.A, +span.i, +pre a.i { + color: var(--hl2); +} + +.D, +span.d, +pre a.d { + color: var(--hl2); +} + +pre a.h:hover, +pre a.i:hover, +pre a.d:hover { + text-decoration: none; +} diff --git a/bin/git_create_repo.sh b/bin/git_create_repo.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +# $1 - HTML Root +# $2 - priv/pub +# $3 - repo name +# $4 - description +# $5 - prot + domain: https://git.example.com + +# Create Folders +mkdir -p "${1}/${2}/${3}/" +mkdir -p "${1}/${2}/${3}.git/" + +# Git-Repository +cd "${1}/${2}/${3}.git" + +# create bare branch +git init --bare + +# Set default branch to "main" +echo "ref: refs/heads/main" > HEAD + +# Add description +echo "$4" > description + +# Add Clone URL +printf "${5}/${2}/${3}.git" > "${1}/${2}/${3}.git/url" + +# Add Hooks +PUH_FILE="${1}/${2}/${3}.git/hooks/post-update" +touch "$PUH_FILE" +chmod +x "$PUH_FILE" +echo "#!/usr/bin/env sh" >> "$PUH_FILE" +echo "exec ~/bin/git_post_push.sh \"${1}\" \"${2}\" \"${3}\"" >> "$PUH_FILE" + +# make branch cloneable via http(s) +git update-server-info + +if [ $(whoami) != "git" ]; then + chown git:www-data -R "../${3}.git" +fi diff --git a/bin/git_post_push.sh b/bin/git_post_push.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +. $HOME/bin/git_update_repo.sh "${1}" "${2}" "${3}" +sleep 1 +. $HOME/bin/git_update_repo_html.sh "${1}" "${2}" "${3}" +sleep 1 +. $HOME/bin/git_update_index_html.sh "${1}" "${2}" diff --git a/bin/git_set_clone_url.sh b/bin/git_set_clone_url.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +# $1 - HTML Root +# $2 - pub/priv +# $3 - prot + domain: https://git.example.com +# $4 - repo name + +printf "${3}/${2}/${4}.git" > "${1}/${2}/${4}.git/url" diff --git a/bin/git_update_index_html.sh b/bin/git_update_index_html.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# $1 - HTML Root +# $2 - priv/pub + +REPOS=$(find "${1}"/"${2}" -maxdepth 1 | grep -E "\.git$" | sed -e 's/\s/\\ /g') + +stagit-index $REPOS > "${1}/${2}/index.html" + +# linking assets +ln -sf "${1}/assets/style.css" "${1}/${2}/style.css" +ln -sf "${1}/assets/favicon.png" "${1}/${2}/favicon.png" +ln -sf "${1}/assets/favicon.png" "${1}/${2}/logo.png" diff --git a/bin/git_update_repo.sh b/bin/git_update_repo.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +# $1 - HTML Root +# $2 - priv/pub +# $3 - repo name + +# Git-Repository +cd "${1}/${2}/${3}.git" + +# make branch cloneable via http(s) +git update-server-info + +# set correct permissions +if [ $(whoami) != "git" ]; then + chown git:www-data -R "${1}/${2}/${3}.git" +fi + diff --git a/bin/git_update_repo_html.sh b/bin/git_update_repo_html.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +# $1 - HTML Root +# $2 - priv/pub +# $3 - repo name + +# HTML Viewer +cd "${1}/${2}/${3}" + +# build HTML +stagit "${1}/${2}/${3}.git" +mkdir -p "${1}/${2}/${3}/files" + +if [ -z $(find "${1}/${2}/${3}/files/" -type f -name "README*.html") ]; then + ln -sf "${1}/${2}/${3}/log.html" "${1}/${2}/${3}/index.html" +else + ln -sf "${1}/${2}/${3}/files/README*.html" "${1}/${2}/${3}/index.html" +fi + +# link assets +ln -sf "${1}/assets/style.css" "${1}/${2}/${3}/style.css" +ln -sf "${1}/assets/favicon.png" "${1}/${2}/${3}/favicon.png" +ln -sf "${1}/assets/favicon.png" "${1}/${2}/${3}/logo.png" diff --git a/bin/git_watcher.sh b/bin/git_watcher.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +while true; do + inotifywait -e modify,create,delete -r "${1}" && \ +<some command to execute when a file event is recorded> + +done diff --git a/favicon.png b/favicon.png @@ -0,0 +1 @@ +assets/favicon.png +\ No newline at end of file diff --git a/index.html b/index.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<meta name="viewport" content="width=device-width, initial-scale=1" /> +<title>Repositories</title> +<link rel="icon" type="image/png" href="favicon.png" /> +<link rel="stylesheet" type="text/css" href="style.css" /> +</head> +<body> +<table> +<tr><td><img src="logo.png" alt="" width="32" height="32" /></td> +<td><span class="desc">Repositories</span></td></tr><tr><td></td><td> +</td></tr> +</table> +<hr/> +<div id="content"> +<p>This section is non-public! You are probably looking for the public section.</p> +<p>If you are not being redirected now, please click <a href="/pub/">HERE</a>.</p> +</div> +</body> +<meta http-equiv="Refresh" content="0; url='/pub/'" /> +</html> diff --git a/logo.png b/logo.png @@ -0,0 +1 @@ +assets/favicon.png +\ No newline at end of file diff --git a/style.css b/style.css @@ -0,0 +1 @@ +assets/style.css +\ No newline at end of file