diff options
Diffstat (limited to 'hosts/station/cgit')
| -rw-r--r-- | hosts/station/cgit/cgitrc | 35 | ||||
| -rw-r--r-- | hosts/station/cgit/custom.css | 431 | ||||
| -rwxr-xr-x | hosts/station/cgit/email-libravatar.py | 38 | ||||
| -rw-r--r-- | hosts/station/cgit/readme_in_summary_no_about.diff | 154 |
4 files changed, 658 insertions, 0 deletions
diff --git a/hosts/station/cgit/cgitrc b/hosts/station/cgit/cgitrc new file mode 100644 index 0000000..1dc4158 --- /dev/null +++ b/hosts/station/cgit/cgitrc @@ -0,0 +1,35 @@ +enable-http-clone=0 +enable-index-owner=0 +enable-commit-graph=1 +repository-sort=age +branch-sort=age + +robots=noindex, nofollow + +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.git + +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=/var/git/ diff --git a/hosts/station/cgit/custom.css b/hosts/station/cgit/custom.css new file mode 100644 index 0000000..2349906 --- /dev/null +++ b/hosts/station/cgit/custom.css @@ -0,0 +1,431 @@ +/* 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"); + +/* @TODO: Create new palette type. Add/Delete/Modifiy (Green/Red/Yellow) + 2-3 Accent colors. + * Then fill out pygments colors. + * */ +:root { + --background: #ffffff; + --black: #000000; + --gray: #808080; + --accent1: #d9d8d1; + --accent2: #edece6; + --accent3: #f6f6f0; + --green: #5bd154; + --red: #d95988; + --yellow: #f1ed73; + --blue: #51a2be; +} + +body { + background-color: var(--background); +} + +/* Readme Formatting */ + +h2 { + border-bottom: 1px solid var(--accent1); +} + +h1, h2 { + margin: 1.0em 0em 0.30em 0em; +} + +h3, h4, h5 { + margin: 0.8em 0em 0.10em 0em; +} + +pre { + margin: 0.50em 0em; +} + +p { + margin: 0.4em 0em; +} + +ul { + padding-left: 1.25rem; +} + +td.tableblock { + border: 1px solid #dedede; +} + +table tr td { + padding: .1em .25em; +} + +/* Code Blocks */ + +.listingblock, +code { + font-family: monospace; + font-size: 10pt; + background-color: var(--accent3); + background-size: cover; +} + +.listingblock { + text-wrap: stable; + word-break: break-all; + display: inline-block; + border: solid 1px var(--accent1); + margin: 0.35em 0em; + padding: 0em 0.4em !important; +} + +p code { + padding: 0em 0.1em; +} + +/* Animated Tag */ + +div#cgit a.tag-annotated-deco { + color: var(--black); + margin: 0px 0.5em; + padding: 0px 0.25em; + border: solid 1px var(--black); + background: linear-gradient(90deg, #eebab3 0%, #f7afab 12%, #eebab3 37%, #ffe5dc 50%, #eebab3 62%, #f7afab 79%, #eebab3 100%); + animation: shine 3.45s infinite; + background-size: 200%; + background-position: left; + background-repeat: repeat-x; + -webkit-animation-timing-function: linear; + -webkit-animation-duration: 3.45s; +} + +div#cgit a:hover.tag-annotated-deco { + color: var(--black) !important; +} + +@keyframes shine { + 0% {background-position:-100%;} + 100% {background-position:100%;} +} + +/* Cgit Overrides */ + +div#cgit { + margin: auto; + font-size: 10pt; + -moz-tab-size: 4; + tab-size: 4; + background: var(--background); +} + +div#cgit table.tabs { + border-bottom: solid 2px var(--accent3); +} + +div#cgit table.tabs td { + padding: 2px 0.75em; +} + +div#cgit table.tabs td a { + padding: 1px 0.75em; + color: var(--gray); + font-size: 110%; +} + +div#cgit table.tabs td a.active { + color: var(--black); + background: var(--background); + border-bottom: solid 2px var(--gray); +} + +div#cgit table#header { + margin-bottom: -1em; +} + +div#cgit table#header td.main { + font-size: 2em; +} + +div#cgit table#header td.main a { + color: var(--black); +} + +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 > div.content { + padding: 1.25em; +} + +div#cgit table.list { + max-width: 100ch; +} + +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(--accent3); +} + +div#cgit table.list tr:hover { + background: var(--accent2); +} + +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 a.deco { + background-color: var(--red); + border: solid 1px var(--black); +} + +div#cgit a:hover.deco { + color: var(--black) !important; +} + +div#cgit a.branch-deco { + background-color: var(--green); + border: solid 1px var(--black); +} + +div#cgit a:hover.branch-deco { + color: var(--black) !important; +} + +div#cgit div#summary { + max-width: 100ch; + margin: 0.5em; + overflow-wrap: break-word; +} + +div#cgit table.diffstat { + border-collapse: collapse; + border: solid 1px var(--black); + background-color: var(--accent3); +} + +div#cgit div.diffstat-header a { + color: var(--black); +} + +div#cgit table.diffstat td.graph td.add { + background-color: var(--green); +} + +div#cgit table.diffstat td.graph td.rem { + background-color: var(--red); +} + +div#cgit table.diffstat td.add a { + color: var(--green); +} + +div#cgit table.diffstat td.del a { + color: var(--red); +} + +div#cgit table.diffstat td.upd a { + 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.hunk { + color: var(--gray); +} + +div#cgit div.cgit-panel table { + border-collapse: collapse; + border: solid 1px var(--black); + background-color: var(--accent3); +} + +div#cgit input, +div#cgit select { + border: solid 1px var(--black); + background-color: var(--accent3); + border-radius: 0.25em; +} + +div#cgit input.txt { + background-color: var(--accent3); +} + +div#cgit div.path { + margin: 0px; + padding: 5px 2em 2px 2em; + color: var(--black); + background-color: var(--background); +} + +div#cgit a { + color: var(--blue); +} + +div#cgit a:hover { + color: var(--gray) !important; +} + +div#cgit a.permalink { + color: inherit; +} + +div#cgit table.list td a.ls-dir { + color: var(--blue); +} + +/* +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; +} +*/ + +/* https://git.zx2c4.com/cgit.css:905 */ +div#cgit span.libravatar img.onhover { + display: none; + border: solid 1px var(--black); + padding: 0em; + border-radius: 3px; + width: 12em; + height: 12em; +} + +div#cgit span.libravatar img.inline { + width: 1.3em; + height: 1.3em; + margin-right: 0.2em; + border-radius: 3px; + 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 var(--black); +} + +pre.pygments .hll { background-color: #ffffcc } +pre.pygments { background: #f8f8f8; } +pre.pygments .tok-c { color: #3D7B7B; font-style: italic } /* Comment */ +pre.pygments .tok-err { border: 1px solid #FF0000 } /* Error */ +pre.pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */ +pre.pygments .tok-o { color: #666666 } /* Operator */ +pre.pygments .tok-ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ +pre.pygments .tok-cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ +pre.pygments .tok-cp { color: #9C6500 } /* Comment.Preproc */ +pre.pygments .tok-cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ +pre.pygments .tok-c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ +pre.pygments .tok-cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ +pre.pygments .tok-gd { color: #A00000 } /* Generic.Deleted */ +pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */ +pre.pygments .tok-ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ +pre.pygments .tok-gr { color: #E40000 } /* Generic.Error */ +pre.pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */ +pre.pygments .tok-gi { color: #008400 } /* Generic.Inserted */ +pre.pygments .tok-go { color: #717171 } /* Generic.Output */ +pre.pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +pre.pygments .tok-gs { font-weight: bold } /* Generic.Strong */ +pre.pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +pre.pygments .tok-gt { color: #0044DD } /* Generic.Traceback */ +pre.pygments .tok-kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +pre.pygments .tok-kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +pre.pygments .tok-kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +pre.pygments .tok-kp { color: #008000 } /* Keyword.Pseudo */ +pre.pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +pre.pygments .tok-kt { color: #B00040 } /* Keyword.Type */ +pre.pygments .tok-m { color: #666666 } /* Literal.Number */ +pre.pygments .tok-s { color: #BA2121 } /* Literal.String */ +pre.pygments .tok-na { color: #687822 } /* Name.Attribute */ +pre.pygments .tok-nb { color: #008000 } /* Name.Builtin */ +pre.pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */ +pre.pygments .tok-no { color: #880000 } /* Name.Constant */ +pre.pygments .tok-nd { color: #AA22FF } /* Name.Decorator */ +pre.pygments .tok-ni { color: #717171; font-weight: bold } /* Name.Entity */ +pre.pygments .tok-ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ +pre.pygments .tok-nf { color: #0000FF } /* Name.Function */ +pre.pygments .tok-nl { color: #767600 } /* Name.Label */ +pre.pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +pre.pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */ +pre.pygments .tok-nv { color: #19177C } /* Name.Variable */ +pre.pygments .tok-ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +pre.pygments .tok-w { color: #bbbbbb } /* Text.Whitespace */ +pre.pygments .tok-mb { color: #666666 } /* Literal.Number.Bin */ +pre.pygments .tok-mf { color: #666666 } /* Literal.Number.Float */ +pre.pygments .tok-mh { color: #666666 } /* Literal.Number.Hex */ +pre.pygments .tok-mi { color: #666666 } /* Literal.Number.Integer */ +pre.pygments .tok-mo { color: #666666 } /* Literal.Number.Oct */ +pre.pygments .tok-sa { color: #BA2121 } /* Literal.String.Affix */ +pre.pygments .tok-sb { color: #BA2121 } /* Literal.String.Backtick */ +pre.pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */ +pre.pygments .tok-dl { color: #BA2121 } /* Literal.String.Delimiter */ +pre.pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +pre.pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */ +pre.pygments .tok-se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ +pre.pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */ +pre.pygments .tok-si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ +pre.pygments .tok-sx { color: #008000 } /* Literal.String.Other */ +pre.pygments .tok-sr { color: #A45A77 } /* Literal.String.Regex */ +pre.pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */ +pre.pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */ +pre.pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */ +pre.pygments .tok-fm { color: #0000FF } /* Name.Function.Magic */ +pre.pygments .tok-vc { color: #19177C } /* Name.Variable.Class */ +pre.pygments .tok-vg { color: #19177C } /* Name.Variable.Global */ +pre.pygments .tok-vi { color: #19177C } /* Name.Variable.Instance */ +pre.pygments .tok-vm { color: #19177C } /* Name.Variable.Magic */ +pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/hosts/station/cgit/email-libravatar.py b/hosts/station/cgit/email-libravatar.py new file mode 100755 index 0000000..045ca17 --- /dev/null +++ b/hosts/station/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/station/cgit/readme_in_summary_no_about.diff b/hosts/station/cgit/readme_in_summary_no_about.diff new file mode 100644 index 0000000..73267e0 --- /dev/null +++ b/hosts/station/cgit/readme_in_summary_no_about.diff @@ -0,0 +1,154 @@ +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 6fae72d..c5b609a 100644 +--- a/ui-shared.c ++++ b/ui-shared.c +@@ -1082,7 +1082,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..23c07aa 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,54 @@ 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; ++ ++ 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(); |