From 86ffad6fa449cdd56f895eb8faff3ee72456f4ef Mon Sep 17 00:00:00 2001 From: Tolmachev Igor Date: Tue, 6 Jan 2026 06:14:36 +0900 Subject: Add docker --- Dockerfile | 28 +++ cgit.conf | 4 + cgitrc | 10 + lighttpd.conf | 9 + responsive/cgit.css | 582 +++++++++++++++++++++++++++++++++++++++++++++++++++ responsive/head.html | 1 + 6 files changed, 634 insertions(+) create mode 100644 Dockerfile create mode 100644 cgit.conf create mode 100644 cgitrc create mode 100644 lighttpd.conf create mode 100644 responsive/cgit.css create mode 100644 responsive/head.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..516f38a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM debian:latest AS cgit-build + +RUN apt-get update +RUN apt-get install -y gcc make +RUN apt-get install -y python3 python-is-python3 +RUN apt-get install -y libzip-dev libssl-dev + +WORKDIR /cgit +COPY cgit /cgit +COPY cgit.conf /cgit + +RUN make +RUN make install + +COPY cgitrc /app +COPY responsive/head.html /app/www/static +COPY responsive/cgit.css /app/www/static + +FROM debian:latest AS cgit-run + +RUN apt-get update +RUN apt-get install -y python3 python3-pygments lighttpd + +WORKDIR /app +COPY --from=cgit-build /app /app +COPY lighttpd.conf /app/lighttpd.conf + +CMD ["lighttpd", "-D", "-f", "/app/lighttpd.conf"] diff --git a/cgit.conf b/cgit.conf new file mode 100644 index 0000000..3c35940 --- /dev/null +++ b/cgit.conf @@ -0,0 +1,4 @@ +CGIT_SCRIPT_PATH = /app/www +CGIT_DATA_PATH = /app/www/static +CGIT_CONFIG = /app/cgitrc +filterdir = /app/lib/filters diff --git a/cgitrc b/cgitrc new file mode 100644 index 0000000..99ecefa --- /dev/null +++ b/cgitrc @@ -0,0 +1,10 @@ +css=/static/cgit.css +js=/static/cgit.js +logo=/static/cgit.png +favicon=/static/favicon.ico +head-include=/app/www/static/head.html + +about-filter=/app/lib/filters/about-formatting.sh +source-filter=/app/lib/filters/syntax-highlighting.py + +include=/app/etc/cgitrc diff --git a/lighttpd.conf b/lighttpd.conf new file mode 100644 index 0000000..94eb5fe --- /dev/null +++ b/lighttpd.conf @@ -0,0 +1,9 @@ +server.modules += ( "mod_cgi", "mod_alias", "mod_rewrite" ) + +server.port = 80 +server.document-root = "/app/www" + +$HTTP["url"] !~ "^/static" { + alias.url = ( "" => "/app/www/cgit.cgi" ) + cgi.assign = ( "" => "" ) +} diff --git a/responsive/cgit.css b/responsive/cgit.css new file mode 100644 index 0000000..f9e1b76 --- /dev/null +++ b/responsive/cgit.css @@ -0,0 +1,582 @@ +/* 1. Color scheme */ + +@media (prefers-color-scheme: dark) { + :root { + --color-primary: rgb(255 181 160); + --color-surface-tint: rgb(255 181 160); + --color-on-primary: rgb(86 31 15); + --color-primary-container: rgb(114 53 35); + --color-on-primary-container: rgb(255 219 209); + --color-secondary: rgb(231 189 178); + --color-on-secondary: rgb(68 42 34); + --color-secondary-container: rgb(93 64 55); + --color-on-secondary-container: rgb(255 219 209); + --color-tertiary: rgb(216 197 141); + --color-on-tertiary: rgb(59 47 5); + --color-tertiary-container: rgb(83 70 25); + --color-on-tertiary-container: rgb(245 225 167); + --color-error: rgb(255 180 171); + --color-on-error: rgb(105 0 5); + --color-error-container: rgb(147 0 10); + --color-on-error-container: rgb(255 218 214); + --color-background: rgb(26 17 15); + --color-on-background: rgb(241 223 218); + --color-surface: rgb(26 17 15); + --color-on-surface: rgb(241 223 218); + --color-surface-variant: rgb(83 67 63); + --color-on-surface-variant: rgb(216 194 188); + --color-outline: rgb(160 140 135); + --color-outline-variant: rgb(83 67 63); + --color-shadow: rgb(0 0 0); + --color-scrim: rgb(0 0 0); + --color-inverse-surface: rgb(241 223 218); + --color-inverse-on-surface: rgb(57 46 43); + --color-inverse-primary: rgb(143 76 56); + --color-primary-fixed: rgb(255 219 209); + --color-on-primary-fixed: rgb(58 11 1); + --color-primary-fixed-dim: rgb(255 181 160); + --color-on-primary-fixed-variant: rgb(114 53 35); + --color-secondary-fixed: rgb(255 219 209); + --color-on-secondary-fixed: rgb(44 21 15); + --color-secondary-fixed-dim: rgb(231 189 178); + --color-on-secondary-fixed-variant: rgb(93 64 55); + --color-tertiary-fixed: rgb(245 225 167); + --color-on-tertiary-fixed: rgb(35 27 0); + --color-tertiary-fixed-dim: rgb(216 197 141); + --color-on-tertiary-fixed-variant: rgb(83 70 25); + --color-surface-dim: rgb(26 17 15); + --color-surface-bright: rgb(66 55 52); + --color-surface-container-lowest: rgb(20 12 10); + --color-surface-container-low: rgb(35 25 23); + --color-surface-container: rgb(39 29 27); + --color-surface-container-high: rgb(50 40 37); + --color-surface-container-highest: rgb(61 50 47); + + color-scheme: dark; + } +} + +@media (prefers-color-scheme: light) { + :root { + --color-primary: rgb(143 76 56); + --color-surface-tint: rgb(143 76 56); + --color-on-primary: rgb(255 255 255); + --color-primary-container: rgb(255 219 209); + --color-on-primary-container: rgb(114 53 35); + --color-secondary: rgb(119 87 78); + --color-on-secondary: rgb(255 255 255); + --color-secondary-container: rgb(255 219 209); + --color-on-secondary-container: rgb(93 64 55); + --color-tertiary: rgb(108 93 47); + --color-on-tertiary: rgb(255 255 255); + --color-tertiary-container: rgb(245 225 167); + --color-on-tertiary-container: rgb(83 70 25); + --color-error: rgb(186 26 26); + --color-on-error: rgb(255 255 255); + --color-error-container: rgb(255 218 214); + --color-on-error-container: rgb(147 0 10); + --color-background: rgb(255 248 246); + --color-on-background: rgb(35 25 23); + --color-surface: rgb(255 248 246); + --color-on-surface: rgb(35 25 23); + --color-surface-variant: rgb(245 222 216); + --color-on-surface-variant: rgb(83 67 63); + --color-outline: rgb(133 115 110); + --color-outline-variant: rgb(216 194 188); + --color-shadow: rgb(0 0 0); + --color-scrim: rgb(0 0 0); + --color-inverse-surface: rgb(57 46 43); + --color-inverse-on-surface: rgb(255 237 232); + --color-inverse-primary: rgb(255 181 160); + --color-primary-fixed: rgb(255 219 209); + --color-on-primary-fixed: rgb(58 11 1); + --color-primary-fixed-dim: rgb(255 181 160); + --color-on-primary-fixed-variant: rgb(114 53 35); + --color-secondary-fixed: rgb(255 219 209); + --color-on-secondary-fixed: rgb(44 21 15); + --color-secondary-fixed-dim: rgb(231 189 178); + --color-on-secondary-fixed-variant: rgb(93 64 55); + --color-tertiary-fixed: rgb(245 225 167); + --color-on-tertiary-fixed: rgb(35 27 0); + --color-tertiary-fixed-dim: rgb(216 197 141); + --color-on-tertiary-fixed-variant: rgb(83 70 25); + --color-surface-dim: rgb(232 214 210); + --color-surface-bright: rgb(255 248 246); + --color-surface-container-lowest: rgb(255 255 255); + --color-surface-container-low: rgb(255 241 237); + --color-surface-container: rgb(252 234 229); + --color-surface-container-high: rgb(247 228 224); + --color-surface-container-highest: rgb(241 223 218); + + color-scheme: light; + } +} + +:root { + /* Custom logic for diffs */ + --diff-add-bg: var(--color-tertiary-container); + --diff-add-fg: var(--color-on-tertiary-container); + --diff-del-bg: var(--color-error-container); + --diff-del-fg: var(--color-on-error-container); +} + +/* 2. Global Reset & Body */ +* { + box-sizing: border-box; +} + +body { + font-family: sans-serif; + font-size: 14px; + line-height: 1.5; + color: var(--color-on-background); + background: var(--color-background); + margin: 0; + padding: 0; +} + +div#cgit { + padding: 0; + margin: 0 auto; + max-width: 1200px; + background: var(--color-background); + min-height: 100vh; + display: flex; + flex-direction: column; +} + +a { + color: var(--color-primary); + text-decoration: none; + transition: opacity 0.2s; +} + +a:hover { + text-decoration: underline; + opacity: 0.8; +} + +/* 3. Header Area */ +div#cgit table#header { + width: 100%; + margin-bottom: 0; + background-color: var(--color-surface-container); + color: var(--color-on-surface); + padding: 1rem; + /* Transform table to flex for responsiveness */ + display: flex; + flex-wrap: wrap; + align-items: center; + border-bottom: 1px solid var(--color-outline-variant); +} + +/* Fix for table structure within header */ +div#cgit table#header tbody, +div#cgit table#header tr { + display: contents; +} + +div#cgit table#header td.logo { + display: block; + padding-right: 1rem; +} + +div#cgit table#header td.main { + font-size: 1.5rem; + font-weight: bold; + color: var(--color-on-surface); + display: block; + flex-grow: 1; +} + +div#cgit table#header td.main a { + color: var(--color-on-surface); +} + +div#cgit table#header td.form { + display: block; + text-align: right; + margin-top: 0.5rem; +} + +div#cgit table#header td.sub { + display: block; + width: 100%; + padding-top: 0.25rem; + color: var(--color-outline); + font-size: 0.9rem; + border-top: none; /* Removing legacy border */ +} + +/* Input Elements */ +select, +input, +textarea { + background-color: var(--color-surface-container-high); + color: var(--color-on-surface); + border: 1px solid var(--color-outline); + border-radius: 4px; + padding: 4px 8px; + font-family: inherit; +} + +input[type="submit"] { + background-color: var(--color-primary); + color: var(--color-on-primary); + border: none; + cursor: pointer; + font-weight: 500; + padding: 5px 12px; +} + +input[type="submit"]:hover { + background-color: var(--color-primary-fixed-dim); +} + +/* 4. Tabs Navigation */ +div#cgit table.tabs { + border-bottom: 1px solid var(--color-outline-variant); + border-collapse: collapse; + margin: 0; + width: 100%; + background-color: var(--color-surface); + display: flex; /* Modern layout */ + flex-wrap: wrap; + padding: 0 1rem; +} + +div#cgit table.tabs tbody, +div#cgit table.tabs tr { + display: contents; +} + +div#cgit table.tabs td { + display: block; + padding: 0; +} + +div#cgit table.tabs td a { + display: inline-block; + padding: 0.75rem 1rem; + color: var(--color-on-surface-variant); + font-weight: 500; + border-bottom: 2px solid transparent; +} + +div#cgit table.tabs td a.active { + color: var(--color-primary); + border-bottom: 2px solid var(--color-primary); + background-color: var(--color-surface-container-low); +} + +div#cgit table.tabs td a:hover { + background-color: var(--color-surface-container-high); + text-decoration: none; +} + +div#cgit table.tabs td.form { + flex-grow: 1; + text-align: right; + padding: 0.5rem 0; + display: flex; + justify-content: flex-end; + align-items: center; +} + +div#cgit a.button { + display: inline-block; + padding: 3px 6px; + margin: 0 4px; + background-color: var(--color-secondary-container); + color: var(--color-on-secondary-container); + border-radius: 5px; + font-size: 0.85rem; + font-weight: 500; + text-decoration: none; + transition: + background-color 0.2s, + color 0.2s, + box-shadow 0.2s; +} + +div#cgit a.button:hover { + background-color: var(--color-primary); + color: var(--color-on-primary); + text-decoration: none; + opacity: 1; + box-shadow: 0 2px 4px var(--color-shadow); +} + +/* 5. Content Area */ +div#cgit div.content { + padding: 1.5rem; + flex-grow: 1; +} + +div#cgit div.path { + margin: 0; + padding: 0.5rem 1.5rem; + background-color: var(--color-surface-container-low); + color: var(--color-on-surface); + border-bottom: 1px solid var(--color-outline-variant); + font-family: monospace; +} + +/* 6. Lists and Tables */ +div#cgit table.list { + width: 100%; + border: none; + border-collapse: collapse; + margin-bottom: 1rem; + font-size: 0.95rem; +} + +div#cgit table.list tr { + background: var(--color-surface); + border-bottom: 1px solid var(--color-surface-container-high); +} + +div#cgit table.list tr:nth-child(even) { + background: var(--color-surface-container-lowest); +} + +div#cgit table.list tr:hover { + background: var(--color-surface-container-high); +} + +div#cgit table.list th { + text-align: left; + font-weight: 600; + color: var(--color-primary); + padding: 0.75rem 0.5rem; + border-bottom: 2px solid var(--color-outline-variant); +} + +div#cgit table.list td { + padding: 0.75rem 0.5rem; + vertical-align: middle; +} + +/* Commit Graph columns */ +div#cgit table.list td.commitgraph { + font-family: monospace; + white-space: pre; + color: var(--color-on-surface); +} + +/* 7. Diffs and Code */ +div#cgit table.blob, +div#cgit table.diff, +div#cgit table.ssdiff { + width: 100%; + border: 1px solid var(--color-outline-variant); + border-radius: 4px; + overflow: hidden; + margin-top: 1rem; + background: var(--color-surface-container-lowest); +} + +div#cgit table.blob td.linenumbers, +div#cgit table.ssdiff td.lineno { + border-right: 1px solid var(--color-outline-variant); + background: var(--color-surface-container-high); + text-align: right; + padding: 0 0.5em; +} + +div#cgit table.blob td.linenumbers a, +div#cgit table.ssdiff td.lineno a { + display: inline-block; + width: 100%; + text-decoration: none; + color: var(--color-outline); + padding: 0; +} + +div#cgit table.blob pre, +div#cgit table.diff td, +div#cgit table.ssdiff td { + font-family: monospace; + font-size: 0.9em; + padding: 0 0.5em; + color: var(--color-on-surface); +} + +/* Diff coloring */ +div#cgit table.diff td div.add, +div#cgit table.ssdiff td.add { + background-color: var(--diff-add-bg); + color: var(--diff-add-fg); +} + +div#cgit table.diff td div.del, +div#cgit table.ssdiff td.del { + background-color: var(--diff-del-bg); + color: var(--diff-del-fg); +} + +div#cgit table.diff td div.hunk, +div#cgit table.ssdiff td.hunk { + background-color: var(--color-surface-variant); + color: var(--color-on-surface-variant); + padding: 0.25em 0.5em; +} + +/* 8. Decorations (Tags, Branches) */ +div#cgit a.branch-deco, +div#cgit a.tag-deco, +div#cgit a.remote-deco, +div#cgit a.deco { + display: inline-block; + padding: 2px 6px; + border-radius: 4px; + font-size: 0.8em; + margin-left: 0.5em; + border: none; +} + +div#cgit a.branch-deco { + background-color: var(--color-primary-container); + color: var(--color-on-primary-container); +} + +div#cgit a.tag-deco { + background-color: var(--color-tertiary-container); + color: var(--color-on-tertiary-container); +} + +div#cgit a.remote-deco { + background-color: var(--color-secondary-container); + color: var(--color-on-secondary-container); +} + +/* 9. Commit Info Table */ +div#cgit table.commit-info { + background-color: var(--color-surface-container); + border: 1px solid var(--color-outline-variant); + border-radius: 8px; + padding: 1rem; + width: 100%; + margin-top: 1rem; + border-collapse: separate; + border-spacing: 0 0.5rem; +} + +div#cgit table.commit-info th { + text-align: left; + padding: 0 1rem; + color: var(--color-secondary); +} + +div#cgit table.commit-info td { + padding: 0 1rem; +} + +div#cgit div.commit-subject { + font-size: 1.2rem; + font-weight: bold; + color: var(--color-primary); + margin: 1.5rem 0 0.5rem 0; +} + +div#cgit div.commit-msg { + white-space: pre-wrap; + font-family: monospace; + padding: 1rem; + background: var(--color-surface-container-low); + border-radius: 4px; + color: var(--color-on-surface); +} + +/* 10. Footer */ +div#cgit div.footer { + margin-top: auto; + padding: 2rem 1rem; + text-align: center; + font-size: 0.85rem; + color: var(--color-outline); + border-top: 1px solid var(--color-outline-variant); +} + +div#cgit div.error { + color: var(--color-error); + background: var(--color-error-container); + padding: 1rem; + border-radius: 4px; + margin: 1rem 0; +} + +/* 11. Responsive Adjustments */ +@media only screen and (max-width: 768px) { + div#cgit table#header { + flex-direction: column; + align-items: flex-start; + } + + div#cgit table#header td.logo, + div#cgit table#header td.main, + div#cgit table#header td.form { + width: 100%; + text-align: left; + margin-bottom: 0.5rem; + } + + div#cgit table.tabs { + flex-direction: column; + padding: 0; + } + + div#cgit table.tabs td a { + width: 100%; + border-bottom: 1px solid var(--color-outline-variant); + } + + div#cgit table.tabs td.form { + width: 100%; + justify-content: flex-start; + padding: 1rem; + } + + div#cgit div.content { + padding: 1rem 0.5rem; + overflow-x: auto; /* Enable horizontal scroll for content */ + } + + /* Force tables to scroll on small screens */ + div#cgit table.list, + div#cgit table.blob, + div#cgit table.diff { + white-space: nowrap; + } + + /* Allow wrapping in logs on mobile to prevent extreme width */ + div#cgit table.list td.logmsg { + white-space: normal; + min-width: 200px; + } +} + +/* --- Fix Syntax Highlighting Alignment --- */ + +/* 1. Reset margins and padding added by syntax highlighting */ +div#cgit table.blob td.lines div.highlight { + margin: 0; + padding: 0; + border: none; +} + +/* 2. Force alignment of line height and fonts */ +div#cgit table.blob td.linenumbers pre, +div#cgit table.blob td.lines pre { + font-family: monospace; + font-size: 14px; + line-height: 1.5 !important; + margin-top: 0; +} + +/* 3. Remove impact of first
 */
+div#cgit table.blob td.lines > pre {
+    white-space: normal;
+    margin: 0;
+    padding: 0;
+}
diff --git a/responsive/head.html b/responsive/head.html
new file mode 100644
index 0000000..44dca77
--- /dev/null
+++ b/responsive/head.html
@@ -0,0 +1 @@
+
-- 
cgit v1.2.3