diff options
Diffstat (limited to 'roles/jails/22_forge/files')
| -rw-r--r-- | roles/jails/22_forge/files/about-formatting.sh | 29 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/cgit.css | 465 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/delete | 11 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/describe | 11 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/help | 11 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/ls | 4 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/new | 12 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/rename | 15 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/head-include.html | 1 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/md2html | 24 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/syntax-highlighting.sh | 12 |
11 files changed, 595 insertions, 0 deletions
diff --git a/roles/jails/22_forge/files/about-formatting.sh b/roles/jails/22_forge/files/about-formatting.sh new file mode 100644 index 0000000..c330aad --- /dev/null +++ b/roles/jails/22_forge/files/about-formatting.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# This may be used with the about-filter or repo.about-filter setting in cgitrc. +# It passes formatting of about pages to differing programs, depending on the usage. + +# Markdown support requires python and markdown-python. +# RestructuredText support requires python and docutils. +# Man page support requires groff. + +# The following environment variables can be used to retrieve the configuration +# of the repository for which this script is called: +# CGIT_REPO_URL ( = repo.url setting ) +# CGIT_REPO_NAME ( = repo.name setting ) +# CGIT_REPO_PATH ( = repo.path setting ) +# CGIT_REPO_OWNER ( = repo.owner setting ) +# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) +# CGIT_REPO_SECTION ( = section setting ) +# CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) + +export PATH=$PATH:/usr/local/bin + +cd "$(dirname $0)/html-converters/" +case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in + *.markdown|*.mdown|*.md|*.mkd) exec ./md2html; ;; + *.rst) exec ./rst2html; ;; + *.[1-9]) exec ./man2html; ;; + *.htm|*.html) exec cat; ;; + *.txt|*) exec ./txt2html; ;; +esac diff --git a/roles/jails/22_forge/files/cgit.css b/roles/jails/22_forge/files/cgit.css new file mode 100644 index 0000000..37edafc --- /dev/null +++ b/roles/jails/22_forge/files/cgit.css @@ -0,0 +1,465 @@ +#header { + header { + font-weight: bold; + font-size: var(--font-size); + } + width: 100%; + td { + padding: 0; + } + td a{ + margin-right: 5px; + } + th { + text-align: left; + } + .main::before { + margin-right: 8px; + content: "►"; + } +} + +:root { + --bg-color: #1b1f29; + --bg-light-color: #2b2f39; + --color: #ffffff; + --light-color: #eff1f8; + --border: #eff1f8; + --color-link: #5da9e9; + --red: #ff6666; + --green: #55bb55; + --blue: #6666FF; + --yellow: #AAAA22; + --orange: #BB8811; + --light-red: #551111; + --light-green: #115511; + --light-blue: #bbbbff; + --light-yellow: #555511; + + --font-size: 14px; +} + +html { + background-color: var(--bg-color); + color: var(--color); + font-family: monospace; + font-size: var(--font-size); +} + +div#cgit { + padding: 2em; + + margin-left: auto; + margin-right: auto; + max-width: 1200px; +} + +div#summary img { + max-width: 100%; +} + +/* unvisited link */ +a:link, a:visited, a:hover, a:active { + color: var(--color-link); +} + +a.ls-dir:last-of-type::after { + content: "/" +} +table.list td > .ls-dir { + color: var(--light-blue); +} + +div#cgit a { + text-decoration: none +} +div#cgit a:hover:not(.button) { + text-decoration: underline +} + +table.tabs td a.active { + background-color: var(--color-link); + color: var(--bg-color); +} + +.tabs td.form, .tabs td a { + padding: 2px 5px 2px 5px; +} + +table.list tr:not(.nohover):nth-child(even) { + background-color: var(--bg-light-color); +} + +table.list td > a { + color: var(--color); +} + +table.list td a:hover { + color: var(--color-link); +} + +.left { + text-align: left; +} + +.right { + text-align: right; +} + +table.list { + width: 100%; + border: 1px solid var(--border); + margin-bottom: 5px; +} + +.button { + border: 1px solid var(--border); + padding: 3px; + margin: 3px; + text-decoration: none; +} + +a.button:hover { + border-width: 1px; + border-color: var(--color-link); + transition: 0.2s; +} + +table.list tr td{ + padding: 3px 5px 5px 3px; +} + +td.linenumbers { + border-right: 1px solid var(--border); +} + +table.blob, table.diff { + width: 100%; + max-width: 100%; + background-color: var(--bg-light-color); + border-top: 1px solid var(--border); + overflow: scroll; + display: block; + white-space: pre; +} + +table.tabs { + margin-bottom: 5px; + width: 100%; + max-width: 100%; + background-color: var(--bg-light-color); + border: 1px solid var(--border); +} + +.linenumbers a { + text-decoration: none; +} + +div.content { + max-width: 100%; + width: 100%; + overflow: scroll; + display: block; +} + +table.tabs a.active { + display: inline +} +table.tabs .form { + white-space: nowrap; + text-align: right; +} + +/*Tree*/ +.ls-mode { + color: var(--light-color); +} + +/*DIFF*/ +.del { + color: var(--red) +} +.add { + color: var(--green) +} +.hunk { + color: var(--blue) +} +.ctx { + color: var(--light-color) +} +.head { + font-weight: bold; +} +div.content table.diffstat { + width: auto; + display: table; + background-color: var(--bg-light-color); + border: 1px solid var(--border); +} +td.graph td.add { + background-color: var(--green) +} + +td.graph td.rem { + background-color: var(--red) +} + +span.insertions { + color: var(--green) +} + +span.deletions { + color: var(--red) +} + +td.graph td { + height: 7px; +} + +table.diffstat td.mode { + white-space: pre; +} + +td.graph { + width: 350px; + border-collapse: collapse; +} + +.diffstat-header { + font-weight: bold; +} +table.diffstat td.add a { + color: var(--green); +} +table.diffstat td.del a { + color: var(--red); +} + +table.ssdiff td.changed { + background-color: var(--yellow) +} +table.ssdiff td.changed_dark { + background-color: var(--light-yellow) +} +table.ssdiff td.del { + background-color: var(--red); + color: var(--color); +} +table.ssdiff td.del_dark { + background-color: var(--light-red); + color: black; +} +table.ssdiff td.add { + background-color: var(--green); + color: var(--color); +} +table.ssdiff td.add_dark { + background-color: var(--light-green); + color: black; +} +table.ssdiff td.hunk { + background-color: var(--blue); + color: var(--color); + border-top: 2px solid var(--border); + border-bottom: 2px solid var(--border); +} + +table.ssdiff { + border-collapse: collapse +} + +table.ssdiff td { + border-left: 1px solid var(--border); + border-right: 1px solid var(--border); +} + +table.ssdiff td.space { + border: none; + div { + min-height: 3em + } +} + +table.ssdiff td.foot { + border-bottom: 1px solid var(--border); +} + +table.ssdiff td.head { + border-top: 1px solid var(--border); +} + +/*Top*/ +div#cgit div.cgit-panel table { + border: 1px solid var(--border); + background-color: var(--bg-light-color); +} + +div#cgit div.cgit-panel { + float: right; + margin-top: 0.5em; +} + +a.deco { + color: var(--red); + border: 2px solid var(--red); + padding: 0px 2px; + margin: 0px 2px; + text-decoration: none; + background-color: var(--bg-light-color); +} + +a.tag-deco { + color: var(--yellow); + border: 2px solid var(--yellow); + padding: 0px 2px; + margin: 0px 2px; + text-decoration: none; + background-color: var(--bg-light-color); +} + +a.remote-deco { + color: var(--light-blue); + border: 2px solid var(--light-blue); + padding: 0px 2px; + margin: 0px 2px; + text-decoration: none; + background-color: var(--bg-light-color); +} + +a.tag-annotated-deco { + color: var(--orange); + border: 2px solid var(--orange); + padding: 0px 2px; + margin: 0px 2px; + text-decoration: none; + background-color: var(--bg-light-color); +} + +a.branch-deco { + color: var(--green); + border: 2px solid var(--green); + padding: 0px 2px; + margin: 0px 2px; + text-decoration: none; + background-color: var(--bg-light-color); +} + +.commit-subject { + font-size: var(--font-size); + font-weight: bold; + margin: 1.5em 0em 0.5em 0em; +} + +div.diffstat-header { + padding-top: 1em; +} + +/*Stats*/ +table.stats td, +table.stats th { + border: 2px solid var(--border) +} + +td.commitgraph { + white-space: pre; + .column1 { + color: var(--red); + } + .column2 { + color: var(--green); + } + .column3 { + color: var(--blue); + } + .column4 { + color: var(--light-red); + } + .column5 { + color: var(--light-green); + } + .column6 { + color: var(--light-blue); + } +} + +@media (max-width: 767.98px) { + table[summary="tree listing"] { + th:nth-child(1), + th:nth-child(3), + tr > .ls-mode, + tr > .ls-size { + display: none; + color: red; + } + } + table:has(td.commitgraph) { + tr:not(.nohover-highlight) td:nth-last-child(-n+2), + th:nth-last-child(-n+2), + td:nth-child(1), + th:nth-child(1) { + display: none; + } + } + table.tabs { + display: block; + overflow: scroll; + .form { + margin-left: 100px; + margin-right: 0px; + width: 100% + } + } + div#cgit { + padding: 0px; + } + + div#cgit div.cgit-panel { + float: unset; + } +} + +input, textarea, button, select { + border-radius: 0px; + -webkit-appearance: none; + -webkit-border-radius: 0px; + padding: 4px 10px; + border: none; + font-family: monospace; + font-size: var(--font-size); + height: 24px; +} + +select { + background-image: url("data:image/svg+xml;utf8,<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24' height='24' viewBox='0 0 24 24'><path fill='%23444' d='M7.406 7.828l4.594 4.594 4.594-4.594 1.406 1.406-6 6-6-6z'></path></svg>"); + background-position: 100% 0%; + background-repeat: no-repeat; + padding-right: 20px; +} + +.footer { + margin-top: 40px; +} + +.logo { + display: none; +} + +#header tr:nth-of-type(1) td:nth-of-type(3) { + text-align: right; +} + +#header { + margin-bottom: 20px; + -webkit-border-vertical-spacing: 0; + -webkit-border-horizontal-spacing: 0; +} + +#header tr { + height: 24px; +} + +#summary { + background-color: var(--bg-light-color); + padding: 8px 8px 16px; +} diff --git a/roles/jails/22_forge/files/git-shell-commands/delete b/roles/jails/22_forge/files/git-shell-commands/delete new file mode 100644 index 0000000..1c1ce0d --- /dev/null +++ b/roles/jails/22_forge/files/git-shell-commands/delete @@ -0,0 +1,11 @@ +#!/bin/sh +if [ -z "$1" ]; then + echo "Usage: delete [REPO_NAME]" + exit 1 +fi +if [ ! -d "$1.git" ]; then + echo "Repository $1 does not exist" + exit 1 +fi +rm -rf "$1.git" +echo "Deleted repository $1" diff --git a/roles/jails/22_forge/files/git-shell-commands/describe b/roles/jails/22_forge/files/git-shell-commands/describe new file mode 100644 index 0000000..b5b0451 --- /dev/null +++ b/roles/jails/22_forge/files/git-shell-commands/describe @@ -0,0 +1,11 @@ +#!/bin/sh +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: describe [REPO_NAME] [DESCRIPTION]" + exit 1 +fi +if [ ! -d "$1.git" ]; then + echo "Repository $1 does not exist" + exit 1 +fi +echo "$2" > "$1.git/description" +echo "Updated description for $1" diff --git a/roles/jails/22_forge/files/git-shell-commands/help b/roles/jails/22_forge/files/git-shell-commands/help new file mode 100644 index 0000000..fd0690d --- /dev/null +++ b/roles/jails/22_forge/files/git-shell-commands/help @@ -0,0 +1,11 @@ +#!/bin/sh +cat <<EOF +Available commands: + + new [REPO_NAME] - create a new bare repository + ls - list repositories + describe [REPO_NAME] [DESCRIPTION] - set repository description + rename [OLD_NAME] [NEW_NAME] - rename a repository + delete [REPO_NAME] - delete a repository + +EOF diff --git a/roles/jails/22_forge/files/git-shell-commands/ls b/roles/jails/22_forge/files/git-shell-commands/ls new file mode 100644 index 0000000..ef5d3e5 --- /dev/null +++ b/roles/jails/22_forge/files/git-shell-commands/ls @@ -0,0 +1,4 @@ +#!/bin/sh +find . -maxdepth 1 -type d -name "*.git" | while read repo; do + basename "$repo" .git +done | sort diff --git a/roles/jails/22_forge/files/git-shell-commands/new b/roles/jails/22_forge/files/git-shell-commands/new new file mode 100644 index 0000000..ba67bc4 --- /dev/null +++ b/roles/jails/22_forge/files/git-shell-commands/new @@ -0,0 +1,12 @@ +#!/bin/sh +if [ -z "$1" ]; then + echo "Usage: new [REPO_NAME]" + exit 1 +fi +if [ -d "$1.git" ]; then + echo "Repository $1 already exists" + exit 1 +fi +git init --bare "$1.git" +echo "$1" > "$1.git/description" +echo "Created repository $1" diff --git a/roles/jails/22_forge/files/git-shell-commands/rename b/roles/jails/22_forge/files/git-shell-commands/rename new file mode 100644 index 0000000..2d1f73e --- /dev/null +++ b/roles/jails/22_forge/files/git-shell-commands/rename @@ -0,0 +1,15 @@ +#!/bin/sh +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: rename [OLD_NAME] [NEW_NAME]" + exit 1 +fi +if [ ! -d "$1.git" ]; then + echo "Repository $1 does not exist" + exit 1 +fi +if [ -d "$2.git" ]; then + echo "Repository $2 already exists" + exit 1 +fi +mv "$1.git" "$2.git" +echo "Renamed $1 to $2" diff --git a/roles/jails/22_forge/files/head-include.html b/roles/jails/22_forge/files/head-include.html new file mode 100644 index 0000000..4231c1b --- /dev/null +++ b/roles/jails/22_forge/files/head-include.html @@ -0,0 +1 @@ +<meta name="viewport" content="width=device-width, initial-scale=1.0"> diff --git a/roles/jails/22_forge/files/md2html b/roles/jails/22_forge/files/md2html new file mode 100644 index 0000000..4f1b76e --- /dev/null +++ b/roles/jails/22_forge/files/md2html @@ -0,0 +1,24 @@ +#!/usr/local/bin/python3.12 +import markdown +import sys +import io +from pygments.formatters import HtmlFormatter +from markdown.extensions.toc import TocExtension +sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') +sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') + +sys.stdout.write("<div class='markdown-body'>") +sys.stdout.flush() +# Note: you may want to run this through bleach for sanitization +markdown.markdownFromFile( + output_format="html5", + extensions=[ + "markdown.extensions.fenced_code", + "markdown.extensions.codehilite", + "markdown.extensions.tables", + "markdown.extensions.sane_lists", + TocExtension(anchorlink=True)], + extension_configs={ + "markdown.extensions.codehilite":{"css_class":"highlight"}} +) +sys.stdout.write("</div>") diff --git a/roles/jails/22_forge/files/syntax-highlighting.sh b/roles/jails/22_forge/files/syntax-highlighting.sh new file mode 100644 index 0000000..f2b9e22 --- /dev/null +++ b/roles/jails/22_forge/files/syntax-highlighting.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +PATH=$PATH:/usr/local/bin + +BASENAME="$1" +EXTENSION="${BASENAME##*.}" + +[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt +[ -z "${EXTENSION}" ] && EXTENSION=txt +[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk + +highlight --force -f -I --inline-css -s night -O xhtml -S "$EXTENSION" |
