From b394434a89f25fe74aa2c43f376454921216ad80 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 15 Apr 2020 16:20:30 +0000 Subject: sys/atuin: add custom cgit CSS --- sys/atuin.nix | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 122 insertions(+), 11 deletions(-) (limited to 'sys') diff --git a/sys/atuin.nix b/sys/atuin.nix index c281722a4836..acf2c1972e78 100644 --- a/sys/atuin.nix +++ b/sys/atuin.nix @@ -158,17 +158,21 @@ "git.qyliss.net" = { root = "${pkgs.cgit}/cgit"; - locations."@cgit".extraConfig = '' - ${overrideFastcgiParams { - CGIT_CONFIG = cgitConfig; - SCRIPT_FILENAME = "$document_root/cgit.cgi"; - PATH_INFO = "$uri"; - QUERY_STRING = "$args"; - HTTP_HOST = "$server_name"; - }} - - fastcgi_pass unix:/run/fcgiwrap.sock; - ''; + locations = { + "= /cgit.css".alias = cgitCss.outPath; + + "@cgit".extraConfig = '' + ${overrideFastcgiParams { + CGIT_CONFIG = cgitConfig; + SCRIPT_FILENAME = "$document_root/cgit.cgi"; + PATH_INFO = "$uri"; + QUERY_STRING = "$args"; + HTTP_HOST = "$server_name"; + }} + + fastcgi_pass unix:/run/fcgiwrap.sock; + ''; + }; extraConfig = '' try_files $uri @cgit; @@ -178,6 +182,7 @@ cgitConfig = pkgs.writeText "cgit.conf" '' clone-prefix=https://git.qyliss.net + css=/cgit.css enable-blame=1 enable-commit-graph=1 enable-follow-links=1 @@ -223,6 +228,112 @@ REDIRECT_STATUS = "200"; } // params)); + cgitCss = pkgs.runCommand "cgit-extra.css" { + licenseHeader = '' + /* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2 as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * See . + */ + + ''; + + # Adapted from + # , + # distributed as a Larger Work under a Secondary License, + # as permitted by the terms of the + # Mozilla Public License Version 2.0. + extraCss = '' + * { line-height: 1.25em; } + + article { + font-family: sans-serif; + max-width: 70ch; + margin-left: auto; + margin-right: auto; + } + + div#cgit { + margin: auto; + font-family: monospace; + -moz-tab-size: 4; + tab-size: 4; + display: table; + } + + div#cgit table#header { + margin-left: auto; + margin-right: auto; + } + div#cgit table#header td.logo { + display: none; + } + div#cgit table#header td.main { + font-size: 1em; + font-weight: bold; + } + div#cgit table#header td.sub { + border-top: none; + } + div#cgit table.tabs { + margin-left: auto; + margin-right: auto; + border-bottom: none; + } + div#cgit div.content { + border-bottom: none; + min-width: 108ch; + } + div#cgit div.content div#summary { + display: table; + margin-left: auto; + margin-right: auto; + } + div#cgit table.list { + margin-left: auto; + margin-right: auto; + } + div#cgit table.list th a { + color: inherit; + } + div#cgit table.list tr:nth-child(even) { + background: inherit; + } + div#cgit table.list tr:hover { + background: inherit; + } + div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { + background: inherit; + } + div#cgit table.list td:last-child { + width: 0; + } + div#cgit div.footer { + font-size: 1em; + margin-top: 0; + } + + div#cgit table.blob td.linenumbers:nth-last-child(3) { + display: none; + } + + div#cgit table.blob td.linenumbers a:target { + color: goldenrod; + text-decoration: underline; + outline: none; + } + ''; + passAsFile = [ "licenseHeader" "extraCss" ]; + } '' + cat $licenseHeaderPath ${pkgs.cgit}/cgit/cgit.css $extraCssPath > $out + ''; in lib.mapAttrs ( _: { forceSSL ? true, enableACME ? true, ... } @ args: -- cgit 1.4.1