diff options
feat: nicen up the repo for estrogen.zone
-rw-r--r-- | Containerfile | 31 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | compose.yml | 6 | ||||
-rw-r--r-- | image/Caddyfile | 4 | ||||
-rw-r--r-- | image/cgitrc | 138 | ||||
-rw-r--r-- | image/filters/email-libravatar.lua | 56 | ||||
-rw-r--r-- | image/filters/syntax-highlighting.sh (renamed from image/syntax-highlighting.sh) | 0 | ||||
-rw-r--r-- | stylua.toml | 3 |
8 files changed, 148 insertions, 92 deletions
diff --git a/Containerfile b/Containerfile index 77e15ce..613e9b8 100644 --- a/Containerfile +++ b/Containerfile @@ -5,20 +5,20 @@ WORKDIR /root # Funny lil packages RUN apk upgrade --no-cache && \ apk add --no-cache \ - git openssh \ - python3 py3-pygments \ - py3-markdown \ - libintl musl-libintl \ - zlib \ - caddy \ - cgit gitolite \ - openssl \ - dumb-init \ - fcgiwrap \ - sudo zsh openrc \ - libcap \ - lzip \ - lua5.3 lua5.3-ossl + git openssh \ + python3 py3-pygments \ + py3-markdown \ + libintl musl-libintl \ + zlib \ + caddy \ + cgit gitolite \ + openssl \ + dumb-init \ + fcgiwrap \ + sudo zsh openrc \ + libcap \ + lzip \ + lua5.3 lua5.3-ossl ADD image/prepare-container.sh /usr/local/bin/prepare-container.sh ADD image/fcgiwrap-launcher /usr/local/bin/fcgiwrap-launcher @@ -70,7 +70,8 @@ RUN echo -ne 'about-filter=/usr/lib/cgit/filters/about-formatting.sh\n' >> /etc/ FROM with-fmt AS with-highlighting RUN apk add --no-cache highlight -ADD image/syntax-highlighting.sh /usr/lib/cgit/filters/syntax-highlighting-uwu.sh +ADD image/filters/syntax-highlighting.sh /usr/lib/cgit/filters/extra/syntax-highlighting.sh +ADD image/filters/email-libravatar.lua /usr/lib/cgit/filters/extra/email-libravatar.lua RUN chmod +x /usr/lib/cgit/filters/syntax-highlighting-uwu.sh RUN echo -ne 'source-filter=/usr/lib/cgit/filters/syntax-highlighting-uwu.sh\n' >> /etc/cgitrc.default @@ -2,6 +2,8 @@ this is a fork of [github.com:gregjbs/docker-gitolite-cgit](https://github.com/gregjbs/docker-gitolite-cgit), with [substantial differences to upstream](#comparison-to-upstream) ([patch](https://github.com/gregjbs/docker-gitolite-cgit/compare/main...dmpmem:cgit-oci:master)) +it is built for [git.estrogen.zone](https://git.estrogen.zone) and is focused around it. + ## installation 1. copy .env.example to .env diff --git a/compose.yml b/compose.yml index d5996f5..a10ed22 100644 --- a/compose.yml +++ b/compose.yml @@ -7,6 +7,11 @@ services: volumes: - cgit_ssh:/etc/ssh:rw - ./cgit/repos:/var/lib/git:rw + - ./cgit/zshhist:/root/.zsh_history:rw + # Copy these directories from the container first, then uncomment to modify things: + # - ./cgit/caddy:/etc/caddy:ro + # - ./cgit/html-converters:/usr/lib/cgit/filters/html-converters:ro + # - ./cgit/extra-filters:/usr/lib/cgit/filters/extra:ro ports: - 127.0.0.1:18080:80 - 127.0.0.1:12222:22 @@ -15,4 +20,3 @@ services: volumes: cgit_ssh: - cgit_repos: diff --git a/image/Caddyfile b/image/Caddyfile index ab89e8e..56f89a0 100644 --- a/image/Caddyfile +++ b/image/Caddyfile @@ -1,3 +1,7 @@ +{ + admin off +} + http:// { route { root * /var/lib/git/static diff --git a/image/cgitrc b/image/cgitrc index 3dfcc8a..61a5944 100644 --- a/image/cgitrc +++ b/image/cgitrc @@ -1,93 +1,71 @@ +# +# cgit config +# see https://man.archlinux.org/man/cgitrc.5 +# + # Enable caching of up to 1000 output entries cache-size=1000 -# Specify some default clone prefixes -clone-prefix=https://git.mydomain.com/git ssh://git@git.mydomain.com +# The clone prefixes, used to show the user where to clone from +clone-prefix=https://git.estrogen.zone ssh://git@git.estrogen.zone -# Specify the css url -css=/cgit.css - -# Show extra links for each repository on the index page -enable-index-links=1 +# Use /cgit.css or https://git.estrogen.zone/cgit-assets.git/plain/cgit.css if you don't have this repo available +css=/cgit-assets.git/plain/cgit.css -# Show number of affected files per commit on the log pages -enable-log-filecount=1 - -# Show number of added/removed lines per commit on the log pages -enable-log-linecount=1 - -# Enable ASCII art commit history graph on the log pages -enable-commit-graph=1 +# Specify your own icon's URL here +logo=/cgit.png # Add a cgit favicon #favicon=/favicon.ico -# Use a custom logo -logo=/cgit.png +# Allow http transport git clone +enable-http-clone=1 + +# Use git configuration files +enable-git-config=1 -# Enable statistics per week, month and quarter +# The maximum duration of the stats tab max-stats=month -# Set the title and heading of the repository index page -root-title=Welcome ! +# Enable the commit graph +enable-commit-graph=1 -# Set a subheading for the repository index page -root-desc=Some information... +# Log should specify counts +enable-log-linecount=1 +enable-log-filecount=1 -# Include some more info about foobar.com on the index page -#root-readme=/var/www/htdocs/about.html +# Show extra links for each repository on the index page +enable-index-links=1 -# Allow download of tar.gz, tar.bz2, tar.lz and zip-files -snapshots=tar.gz tar.bz2 tar.lz zip +# Enable blame page and create links to it from tree page +enable-blame=1 -# Show libravatar -email-filter=lua:/usr/lib/cgit/filters/email-libravatar.lua +# The title of the root +root-title=git.estrogen.zone +# The description rendered under it +root-desc=uhhh idk -robots=noindex, nofollow -enable-git-config=1 -#source-filter=/opt/highlight.sh -source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.py +# Include some more info about git.estrogen.zone on the index page +#root-readme=/var/www/htdocs/about.html +# if you do not want that webcrawler (like google) index your site +robots=index, nofollow -## -## Search for these files in the root of the default branch of repositories -## for coming up with the about page: -## -readme=:README.md -readme=:readme.md -readme=:README.mkd -readme=:readme.mkd readme=:README.rst readme=:readme.rst -readme=:README.html -readme=:readme.html -readme=:README.htm -readme=:readme.htm -readme=:README.txt -readme=:readme.txt +readme=:README.md +readme=:readme.md readme=:README readme=:readme -readme=:INSTALL.md -readme=:install.md -readme=:INSTALL.mkd -readme=:install.mkd -readme=:INSTALL.rst -readme=:install.rst -readme=:INSTALL.html -readme=:install.html -readme=:INSTALL.htm -readme=:install.htm -readme=:INSTALL.txt -readme=:install.txt -readme=:INSTALL -readme=:install - -about-filter=/usr/local/lib/cgit/filters/about-formatting.sh +#readme=:README.html -## -### List of common mimetypes -### +# if cgit messes up links, use a virtual-root. For example, cgit.example.org/ has this value: +virtual-root=/ + +# Allow download of tar.gz, tar.bz2, tar.lz and zip-files +snapshots=tar.lz tar.gz tar.bz2 zip +# Specify mime types mimetype.git=image/git mimetype.html=text/html mimetype.jpg=image/jpeg @@ -100,11 +78,26 @@ mimetype.js=text/javascript mimetype.css=text/css mimetype.ascii=text/vnd.ascii-art # text/plain is used to prevent XSS -mimetype.html=text/plain+nothtml +mimetype.html=text/plain +# Show libravatar - assumes you're using an avatar handler that handles this properly +email-filter=lua:/usr/lib/cgit/filters/extra/email-libravatar.lua +# If you prefer upstream's: +# email-filter=lua:/usr/lib/cgit/filters/email-libravatar.lua + +# TODO: Create commit filter +# commit-filter=exec:/usr/lib/cgit/filters/extra/commit.sh + +# Handle the about pages +about-filter=/usr/lib/cgit/filters/about-formatting.sh +# Handle syntax highlighting +source-filter=/usr/lib/cgit/filters/syntax-highlighting-uwu.sh + +project-list=/var/lib/git/projects.list +scan-path=/var/lib/git/repositories ## -## List of repositories. +## List of repositories, if you don't wish to use scanning (I RECOMMEND STRONGLY USING SCANNING!!). ## PS: Any repositories listed when repo.group is unset will not be ## displayed under a group heading ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos') @@ -113,17 +106,10 @@ mimetype.html=text/plain+nothtml ## #### -section=my repo - +# section=my repo +# #repo.url=testing #repo.path=/var/lib/git/testing.git #repo.desc=Testing repo created by Gitolite #repo.owner=admin@mynetwork.com # - - - -# Auto scan -scan-path=/var/lib/git/repositories - - diff --git a/image/filters/email-libravatar.lua b/image/filters/email-libravatar.lua new file mode 100644 index 0000000..5e8554e --- /dev/null +++ b/image/filters/email-libravatar.lua @@ -0,0 +1,56 @@ +-- This script may be used with the email-filter or repo.email-filter settings in cgitrc. +-- It adds libravatar icons to author names. It is designed to be used with the lua: +-- prefix in filters. +-- +-- Requirements: +-- luaossl +-- <http://25thandclement.com/~william/projects/luaossl.html> +-- + +local digest = require('openssl.digest') + +function sha256_hex(input) + local b = digest.new('sha256'):final(input) + local x = '' + for i = 1, #b do + x = x .. string.format('%.2x', string.byte(b, i)) + end + return x +end + +function filter_open(email, page) + buffer = '' + sha256 = sha256_hex(email:sub(2, -2):lower()) +end + +function filter_close() + baseurl = not os.getenv('FORCE_HTTP') and 'https://seccdn.libravatar.org/' or 'http://cdn.libravatar.org/' + local url = baseurl .. 'avatar/' .. sha256 .. '?d=retro&s=' + local rng = tostring(math.random(0, 10000000)) + -- very bad email obfuscation + html( + '<a class=\'e-' + .. sha256 + .. '\' id=\'e-' + .. rng + .. '\'><span class="libravatar-avatar"><img src=\'' + .. url + .. '128\' class="always-visible" alt=\'Libravatar\' /><img src=\'' + .. url + .. '1024\' class=\'on-hover\' alt=\'Large Libravatar\' /></span> ' + .. buffer:gsub('@', '<span class="theattening"></span>'):gsub('%.', '<span class="thedottening"></span>') + .. '</a>' + .. ( + math.random(0, 1000) < 777 + and '<script id="j-' .. rng .. '">(()=>{const _=' .. (math.random(0, 100) > 50 and 'setTimeout' or 'setInterval') .. '(()=>{const a=document.querySelector(\'#e-' .. rng .. '.e-' .. sha256 .. '\');a.removeAttribute(\'id\');const b = a.querySelector(".theattening");if(b){b.outerHTML+="<span style=\'display:inline-flex;flex-direction:row-reverse;width:0;height:0;opacity:0;\'><span>a</span><span>t</span></span>";a.querySelector(".thedottening").outerHTML=String.fromCharCode(("http://").charCodeAt(5) - 1);};document.querySelector("#j-' .. rng .. '").remove();try{clearInterval(_);}catch(e){}},' .. tostring( + math.random(0, 1000) + ) .. ')})()</script>' + or '' + ) + ) + return 0 +end + +function filter_write(str) + buffer = buffer .. str +end diff --git a/image/syntax-highlighting.sh b/image/filters/syntax-highlighting.sh index 88f59bf..88f59bf 100644 --- a/image/syntax-highlighting.sh +++ b/image/filters/syntax-highlighting.sh diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..327dfa6 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,3 @@ +indent_width = 2 +indent_type = "Spaces" +quote_style = "ForceSingle" |