aboutsummaryrefslogtreecommitdiff
path: root/roles/cgit/files/image
diff options
context:
space:
mode:
Diffstat (limited to 'roles/cgit/files/image')
-rw-r--r--roles/cgit/files/image/Caddyfile13
-rw-r--r--roles/cgit/files/image/Dockerfile12
-rwxr-xr-xroles/cgit/files/image/start.sh4
-rw-r--r--roles/cgit/files/image/syntax-highlighting.py55
-rw-r--r--roles/cgit/files/image/theme.css172
-rw-r--r--roles/cgit/files/image/theme.html1
6 files changed, 257 insertions, 0 deletions
diff --git a/roles/cgit/files/image/Caddyfile b/roles/cgit/files/image/Caddyfile
new file mode 100644
index 0000000..35a29b8
--- /dev/null
+++ b/roles/cgit/files/image/Caddyfile
@@ -0,0 +1,13 @@
+:80 {
+ @assets path /cgit.css /cgit.png /favicon.ico /theme.css /theme.html
+ handle @assets {
+ root * /usr/share/cgit
+ file_server
+ }
+
+ reverse_proxy unix//run/fcgiwrap.socket {
+ transport fastcgi {
+ env SCRIPT_FILENAME /var/www/cgi-bin/cgit
+ }
+ }
+}
diff --git a/roles/cgit/files/image/Dockerfile b/roles/cgit/files/image/Dockerfile
new file mode 100644
index 0000000..894e68a
--- /dev/null
+++ b/roles/cgit/files/image/Dockerfile
@@ -0,0 +1,12 @@
+FROM docker.io/fedora:41
+
+RUN dnf install cgit caddy fcgiwrap openssh-server python3-pygments -y
+COPY Caddyfile /etc/caddy/Caddyfile
+COPY start.sh start.sh
+RUN mkdir /usr/lib/cgit -p
+COPY theme.css /usr/share/cgit/theme.css
+COPY theme.html /usr/share/cgit/theme.html
+COPY syntax-highlighting.py /usr/lib/cgit/syntax-highlighting.py
+RUN chmod 777 /usr/lib/cgit/syntax-highlighting.py
+RUN adduser -m git
+CMD ["./start.sh"]
diff --git a/roles/cgit/files/image/start.sh b/roles/cgit/files/image/start.sh
new file mode 100755
index 0000000..96a279b
--- /dev/null
+++ b/roles/cgit/files/image/start.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+/usr/sbin/fcgiwrap -s unix:/run/fcgiwrap.socket &
+caddy run --config /etc/caddy/Caddyfile
+
diff --git a/roles/cgit/files/image/syntax-highlighting.py b/roles/cgit/files/image/syntax-highlighting.py
new file mode 100644
index 0000000..e912594
--- /dev/null
+++ b/roles/cgit/files/image/syntax-highlighting.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+
+# This script uses Pygments and Python3. You must have both installed
+# for this to work.
+#
+# http://pygments.org/
+# http://python.org/
+#
+# It may be used with the source-filter or repo.source-filter settings
+# in cgitrc.
+#
+# 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 )
+
+
+import sys
+import io
+from pygments import highlight
+from pygments.util import ClassNotFound
+from pygments.lexers import TextLexer
+from pygments.lexers import guess_lexer
+from pygments.lexers import guess_lexer_for_filename
+from pygments.formatters import HtmlFormatter
+
+
+sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace')
+sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
+data = sys.stdin.read()
+filename = sys.argv[1]
+formatter = HtmlFormatter(style='pastie', nobackground=True)
+
+try:
+ lexer = guess_lexer_for_filename(filename, data)
+except ClassNotFound:
+ # check if there is any shebang
+ if data[0:2] == '#!':
+ lexer = guess_lexer(data)
+ else:
+ lexer = TextLexer()
+except TypeError:
+ lexer = TextLexer()
+
+# highlight! :-)
+# printout pygments' css definitions as well
+sys.stdout.write('<style>')
+sys.stdout.write(formatter.get_style_defs('.highlight'))
+sys.stdout.write('</style>')
+sys.stdout.write(highlight(data, lexer, formatter, outfile=None))
diff --git a/roles/cgit/files/image/theme.css b/roles/cgit/files/image/theme.css
new file mode 100644
index 0000000..54357b1
--- /dev/null
+++ b/roles/cgit/files/image/theme.css
@@ -0,0 +1,172 @@
+:root {
+ --bg_h: #1d2021;
+ --bg: #282828;
+ --bg_s: #32302f;
+ --bg1: #3c3836;
+ --bg2: #504945;
+ --bg3: #665c54;
+ --bg4: #7c6f64;
+
+ --fg: #fbf1c7;
+ --fg1: #ebdbb2;
+ --fg2: #d5c4a1;
+ --fg3: #bdae93;
+ --fg4: #a89984;
+
+ --red: #fb4934;
+ --green: #b8bb26;
+ --yellow: #fabd2f;
+ --blue: #83a598;
+ --purple: #d3869b;
+ --aqua: #8ec07c;
+ --gray: #928374;
+ --orange: #fe8019;
+
+ --red-dim: #cc2412;
+ --green-dim: #98971a;
+ --yellow-dim: #d79921;
+ --blue-dim: #458588;
+ --purple-dim: #b16286;
+ --aqua-dim: #689d6a;
+ --gray-dim: #a89984;
+ --orange-dim: #d65d0e;
+}
+
+body, #cgit, .path, div#cgit table.blob td.hashes,
+div#cgit table.blob td.lines, div#cgit div.cgit-panel table,
+div#cgit table.diffstat {
+ background: var(--bg) !important;
+ color: var(--fg) !important;
+ border: none
+}
+
+a {
+ color: var(--fg) !important;
+ text-decoration: underline !important;
+}
+
+select, input {
+ border: none;
+ background: var(--bg2);
+ color: var(--fg);
+}
+
+/**************/
+/*** TABLES ***/
+/**************/
+div#cgit table.tabs td a.active {
+ background: var(--bg) !important;
+ color: var(--yellow) !important;
+}
+
+div#cgit table.tabs, div#cgit div.content,
+div#cgit table#header td.sub {
+ border: none;
+}
+
+div#cgit table.list tr.nohover,
+div#cgit table.list tr:nth-child(2n) {
+ background: var(--bg) !important;
+}
+
+div#cgit table.list tr:nth-child(2n+1) {
+ background: var(--bg_s) !important;
+}
+
+div#cgit table.list tr:hover:not(.nohover) {
+ background: var(--bg1) !important;
+}
+
+/************/
+/*** CODE ***/
+/************/
+div#cgit table.blob td.linenumbers,
+div#cgit table.blob {
+ border-color: var(--gray);
+}
+
+div#cgit table.blob td.linenumbers a {
+ color: var(--gray) !important;
+ text-decoration: none !important;
+}
+
+.markdown-body code, .markdown-body tt,
+.markdown-body .highlight pre, .markdown-body pre {
+ background: var(--bg1) !important;
+}
+
+/************/
+/*** AGES ***/
+/************/
+.age-hours {
+ color: var(--aqua) !important;
+}
+
+.age-days {
+ color: var(--aqua-dim) !important;
+}
+
+.age-weeks {
+ color: var(--fg) !important;
+}
+
+.age-months {
+ color: var(--fg2) !important;
+}
+
+.age-years {
+ color: var(--fg4) !important;
+}
+
+/******************/
+/*** DECORATORS ***/
+/******************/
+div#cgit a.branch-deco {
+ background: var(--aqua);
+ border: none;
+ color: var(--bg) !important;
+}
+
+div#cgit a.deco {
+ background: var(--yellow);
+ border: none;
+ color: var(--bg) !important;
+}
+
+div#cgit a.tag-deco {
+ background: var(--gray);
+ border: none;
+ color: var(--bg) !important;
+}
+
+/************/
+/*** DIFF ***/
+/************/
+div#cgit table.diff td div.hunk {
+ color: var(--blue);
+}
+
+div#cgit table.diff td div.del {
+ color: var(--red);
+}
+
+div#cgit table.diff td div.add {
+ color: var(--green);
+}
+
+div#cgit table.diff td div.ctx {
+ color: var(--gray);
+}
+
+div#cgit table.diff td div.head {
+ color: var(--fg);
+}
+
+div#cgit table.diffstat td.graph td.add {
+ background: var(--green);
+}
+
+div#cgit table.diffstat td.graph td.rem {
+ background: var(--red);
+}
+
diff --git a/roles/cgit/files/image/theme.html b/roles/cgit/files/image/theme.html
new file mode 100644
index 0000000..f95b5d1
--- /dev/null
+++ b/roles/cgit/files/image/theme.html
@@ -0,0 +1 @@
+<link rel="stylesheet" type="text/css" href="/theme.css">