diff options
| author | 2024-11-12 22:26:02 -0500 | |
|---|---|---|
| committer | 2024-11-12 22:36:49 -0500 | |
| commit | 53a0a5473f45d37027af9663638adbf56667e4ca (patch) | |
| tree | 05c6c39678a9005f95c00e0fdf31193657bd4d3d /hosts/denpa/cgit | |
| download | dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.tar.gz dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.tar.bz2 dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.zip | |
Hopefully no leaks
Diffstat (limited to 'hosts/denpa/cgit')
| -rw-r--r-- | hosts/denpa/cgit/cgitrc | 33 | ||||
| -rw-r--r-- | hosts/denpa/cgit/custom.css | 285 | ||||
| -rwxr-xr-x | hosts/denpa/cgit/email-libravatar.py | 38 | ||||
| -rw-r--r-- | hosts/denpa/cgit/readme_in_summary.diff | 152 |
4 files changed, 508 insertions, 0 deletions
diff --git a/hosts/denpa/cgit/cgitrc b/hosts/denpa/cgit/cgitrc new file mode 100644 index 0000000..31e23d8 --- /dev/null +++ b/hosts/denpa/cgit/cgitrc @@ -0,0 +1,33 @@ +enable-http-clone=0 +enable-index-owner=0 +enable-commit-graph=1 +repository-sort=age +branch-sort=age + +logo= +css=/custom.css + +source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.py +email-filter=/usr/local/lib/cgit/filters/email-libravatar.py + +remove-suffix=1 + +virtual-root=/ +clone-url=https://git.akon.city/$CGIT_REPO_URL + +root-title=Akon City Software Inc. +root-desc= + +snapshots=tar.gz tar.bz2 zip + +mimetype.gif=image/gif +mimetype.html=text/html +mimetype.jpg=image/jpeg +mimetype.jpeg=image/jpeg +mimetype.pdf=application/pdf +mimetype.png=image/png +mimetype.svg=image/svg+xml + +readme=./README.html + +scan-path=/mnt/git diff --git a/hosts/denpa/cgit/custom.css b/hosts/denpa/cgit/custom.css new file mode 100644 index 0000000..d55d37f --- /dev/null +++ b/hosts/denpa/cgit/custom.css @@ -0,0 +1,285 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +@import url("cgit.css"); + +/* +div#cgit a.tag-annotated-deco { + color: #000; + margin: 0px 0.5em; + padding: 0px 0.25em; + border: solid 1px #777700; + background: linear-gradient(90deg, rgba(186,148,62,1) 0%, rgba(236,172,32,1) 30%, rgba(186,148,62,1) 49%, rgba(249,244,180,1) 70%); + background: linear-gradient(90deg, rgba(186,148,62,1) 0%, rgba(236,172,32,1) 20%, rgba(186,148,62,1) 39%, rgba(249,244,180,1) 50%, rgba(186,148,62,1) 60%, rgba(236,172,32,1) 80%, rgba(186,148,62,1) 100%); + animation: shine 3s infinite; + background-size: 200%; + background-position: left; + background-repeat: repeat-x; + -webkit-animation-timing-function: linear; + -webkit-animation-duration: 9s; +} + +@keyframes shine { + to{background-position: 200%} +} + +div#cgit span.age-hours { + color: #080; +} + +div#cgit span.age-days { + color: #040; +} + +div#cgit span.age-weeks { + color: #444; +} + +div#cgit span.age-months { + color: #888; +} + +div#cgit span.age-years { + color: #bbb; +} + +div#cgit span.insertions { + color: #080; +} + +div#cgit span.deletions { + color: #800; +} +*/ + +:root { + --background: #fef9fa; + --highlight1: 181, 57, 57; /* #b53939 */ + --highlight2: 130, 137, 69; /* #828945 */ + --highlight3: 221, 182, 123; /* #ddb67b */ + --highlight4: 66, 49, 82; /* #423152 */ + --color1: rgba(var(--highlight1), 0.045); + --color2: rgba(var(--highlight1), 0.09); + --color3: #fef9fa; + --black: #13090c; + --gray0: #393232; + --gray1: #777; + --gray2: #aaa; + --gray: 119, 119, 119; /* #777777 */ +} + +* { + line-height: 1.4em; +} + +body { + background-color: var(--background); +} + +a:hover { + color: rgb(var(--highlight1)) !important; +} + +div#cgit { + margin: auto; + font-family: monospace; + font-size: 11pt; + -moz-tab-size: 4; + tab-size: 4; + background: var(--background); + color: var(--gray0); +} + +div#cgit table.tabs { + border-bottom: solid 2px var(--color1); +} + +div#cgit table.tabs td { + padding: 2px 0.75em; +} + +div#cgit table.tabs td a { + padding: 1px 0.75em; + color: var(--gray1); + font-size: 110%; +} + +div#cgit table.tabs td a.active { + color: var(--gray0); + background: var(--color1); + border-bottom: solid 2px var(--gray2); +} + +div#cgit table#header td.main { + font-size: 2em; +} + +div#cgit table#header td.main a { + color: var(--gray0); +} + +div#cgit table#header td.sub { + border-top: none; +} + +div#cgit table#header td.sub.right { + padding-right: 1em; +} + +div#cgit div.content { + border-bottom: none; + padding: 0em; +} + +div#cgit table.list th a { + color: inherit; +} + +div#cgit table.list tr:nth-child(even) { + background: inherit; +} + +div#cgit table.list tr:nth-child(odd) { + background: var(--color1); +} + +div#cgit table.list tr:hover { + background: var(--color2); +} + +div#cgit table.list tr.nohover { + background: inherit; +} + +div#cgit table.list tr.nohover:hover { + background: inherit; +} + +div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { + background: inherit; +} + +div#cgit table.blob td.linenumbers a:target { + color: goldenrod; + text-decoration: underline; + outline: none; +} + +div#cgit a.deco { + background-color: rgba(var(--highlight1), 0.65); + border: solid 1px var(--black); +} + +div#cgit a.branch-deco { + background-color: rgba(var(--highlight2), 0.65); + border: solid 1px var(--black); +} + +div#cgit a.tag-annotated-deco { +} + +div#cgit div#summary { + max-width: 80ch; + margin: 0.5em; + overflow-wrap: break-word; +} + +div#cgit table.diffstat { + border-collapse: collapse; + border: solid 1px var(--gray2); + background-color: var(--color3); +} + +div#cgit table.diffstat td.graph td.add { + background-color: rgba(var(--highlight2), 0.75); +} + +div#cgit table.diffstat td.graph td.rem { + background-color: rgba(var(--highlight1), 0.75); +} + +div#cgit table.diffstat td.add a { + color: rgba(var(--highlight2), 0.85); +} + +div#cgit table.diffstat td.del a { + color: rgba(var(--highlight1), 0.85); +} + +div#cgit table.diffstat td.upd a { + color: rgba(var(--highlight3), 0.9); +} + +div#cgit table.diff td div.head { + color: var(--gray0); +} + +div#cgit table.diff td div.del { + color: rgba(var(--highlight1), 1.0); +} + +div#cgit table.diff td div.add { + color: rgba(var(--highlight2), 1.0); +} + +div#cgit table.diff td div.hunk { + color: rgba(var(--highlight3), 0.9); +} + +div#cgit div.cgit-panel table { + border-collapse: collapse; + border: solid 1px var(--gray2); + background-color: var(--color3); +} + +div#cgit input, +div#cgit select { + background-color: var(--color3); + border: solid 1px var(--gray2); + border-radius: 0.25em; +} + +div#cgit input.txt { + background-color: var(--color3); +} + +div#cgit div.path { + margin: 0px; + padding: 5px 2em 2px 2em; + color: var(--black); + background-color: var(--background); +} + +div#cgit a { + color: rgba(var(--highlight4), 1.0); +} + +div#cgit a.permalink { + color: inherit; +} + +/* https://git.zx2c4.com/cgit.css:905 */ +div#cgit span.libravatar img.onhover { + display: none; + border: 0.1em solid gray; + padding: 0px; + border-radius: 0.3em; + width: 12em; + height: 12em; +} + +div#cgit span.libravatar img.inline { + width: 1.4em; + height: 1.4em; + margin-right: 0.2em; + vertical-align: bottom; +} + +div#cgit span.libravatar:hover > img.onhover { + display: block; + position: absolute; + margin-left: 1.5em; + background-color: var(--background); + box-shadow: 0.15em 0.15em 0.4em rgba(var(--gray), 0.75); +} diff --git a/hosts/denpa/cgit/email-libravatar.py b/hosts/denpa/cgit/email-libravatar.py new file mode 100755 index 0000000..045ca17 --- /dev/null +++ b/hosts/denpa/cgit/email-libravatar.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +# This script may be used with the email-filter or repo.email-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 ) +# +# It receives an email address on argv[1] and text on stdin. It prints +# to stdout that text prepended by a gravatar at 10pt. + +import sys +import hashlib +import codecs + +email = sys.argv[1].lower().strip() +if email[0] == "<": + email = email[1:] +if email[-1] == ">": + email = email[0:-1] + +page = sys.argv[2] + +sys.stdin = codecs.getreader("utf-8")(sys.stdin.detach()) +sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) + +md5 = hashlib.md5(email.encode()).hexdigest() +text = sys.stdin.read().strip() + +baseurl = "https://seccdn.libravatar.org" + +print(f"<span class='libravatar'><img class='inline' src='{baseurl}/avatar/{md5}?s=32&d=retro'/><img class='onhover' src='{baseurl}/avatar/{md5}?s=192&d=retro'/></span>" + text) diff --git a/hosts/denpa/cgit/readme_in_summary.diff b/hosts/denpa/cgit/readme_in_summary.diff new file mode 100644 index 0000000..33756f9 --- /dev/null +++ b/hosts/denpa/cgit/readme_in_summary.diff @@ -0,0 +1,152 @@ +diff --git a/cmd.c b/cmd.c +index 0eb75b1..be316f4 100644 +--- a/cmd.c ++++ b/cmd.c +@@ -49,7 +49,7 @@ static void about_fn(void) + cgit_redirect(redirect, true); + free(currenturl); + free(redirect); +- } else if (ctx.repo->readme.nr) ++ } else if (0) + cgit_print_repo_readme(ctx.qry.path); + else if (ctx.repo->homepage) + cgit_redirect(ctx.repo->homepage, false); +diff --git a/ui-shared.c b/ui-shared.c +index baea6f2..6b01d08 100644 +--- a/ui-shared.c ++++ b/ui-shared.c +@@ -1078,7 +1078,7 @@ void cgit_print_pageheader(void) + + html("<table class='tabs'><tr><td>\n"); + if (ctx.env.authenticated && ctx.repo) { +- if (ctx.repo->readme.nr) ++ if (0) + reporevlink("about", "about", NULL, + hc("about"), ctx.qry.head, NULL, + NULL); +diff --git a/ui-summary.c b/ui-summary.c +index 947812a..faf943e 100644 +--- a/ui-summary.c ++++ b/ui-summary.c +@@ -40,31 +40,6 @@ static void print_url(const char *url) + html("</a></td></tr>\n"); + } + +-void cgit_print_summary(void) +-{ +- int columns = 3; +- +- if (ctx.repo->enable_log_filecount) +- columns++; +- if (ctx.repo->enable_log_linecount) +- columns++; +- +- cgit_print_layout_start(); +- html("<table summary='repository info' class='list nowrap'>"); +- cgit_print_branches(ctx.cfg.summary_branches); +- htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); +- cgit_print_tags(ctx.cfg.summary_tags); +- if (ctx.cfg.summary_log > 0) { +- htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); +- cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, +- NULL, NULL, 0, 0, 0); +- } +- urls = 0; +- cgit_add_clone_urls(print_url); +- html("</table>"); +- cgit_print_layout_end(); +-} +- + /* The caller must free the return value. */ + static char* append_readme_path(const char *filename, const char *ref, const char *path) + { +@@ -99,25 +74,11 @@ static char* append_readme_path(const char *filename, const char *ref, const cha + return full_path; + } + +-void cgit_print_repo_readme(const char *path) ++static void print_readme_file(const char *path) + { +- char *filename, *ref, *mimetype; ++ char *filename, *ref; + int free_filename = 0; + +- mimetype = get_mimetype_for_filename(path); +- if (mimetype && (!strncmp(mimetype, "image/", 6) || !strncmp(mimetype, "video/", 6))) { +- ctx.page.mimetype = mimetype; +- ctx.page.charset = NULL; +- cgit_print_plain(); +- free(mimetype); +- return; +- } +- free(mimetype); +- +- cgit_print_layout_start(); +- if (ctx.repo->readme.nr == 0) +- goto done; +- + filename = ctx.repo->readme.items[0].string; + ref = ctx.repo->readme.items[0].util; + +@@ -125,7 +86,7 @@ void cgit_print_repo_readme(const char *path) + free_filename = 1; + filename = append_readme_path(filename, ref, path); + if (!filename) +- goto done; ++ return; + } + + /* Print the calculated readme, either from the git repo or from the +@@ -142,6 +103,52 @@ void cgit_print_repo_readme(const char *path) + html("</div>"); + if (free_filename) + free(filename); ++} ++ ++void cgit_print_summary(void) ++{ ++ int columns = 3; ++ ++ if (ctx.repo->enable_log_filecount) ++ columns++; ++ if (ctx.repo->enable_log_linecount) ++ columns++; ++ ++ cgit_print_layout_start(); ++ html("<table summary='repository info' class='list nowrap'>"); ++ cgit_print_branches(ctx.cfg.summary_branches); ++ htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); ++ cgit_print_tags(ctx.cfg.summary_tags); ++ if (ctx.cfg.summary_log > 0) { ++ htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); ++ cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, ++ NULL, NULL, 0, 0, 0); ++ } ++ urls = 0; ++ cgit_add_clone_urls(print_url); ++ html("</table>"); ++ if (ctx.repo->readme.nr) ++ print_readme_file(ctx.qry.path); ++ cgit_print_layout_end(); ++} ++ ++void cgit_print_repo_readme(const char *path) ++{ ++ char *mimetype = get_mimetype_for_filename(path); ++ if (mimetype && (!strncmp(mimetype, "image/", 6) || !strncmp(mimetype, "video/", 6))) { ++ ctx.page.mimetype = mimetype; ++ ctx.page.charset = NULL; ++ cgit_print_plain(); ++ free(mimetype); ++ return; ++ } ++ free(mimetype); ++ ++ cgit_print_layout_start(); ++ if (ctx.repo->readme.nr == 0) ++ goto done; ++ ++ print_readme_file(path); + + done: + cgit_print_layout_end(); |