Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adélie Infrastructure
Container Services
Commits
855beb63
Commit
855beb63
authored
Jun 11, 2022
by
Zach van Rijn
Browse files
cgit.themanaworld.org: new service.
parent
a4715c49
Changes
9
Hide whitespace changes
Inline
Side-by-side
cgit.themanaworld.org/.dockerignore
0 → 100644
View file @
855beb63
data/
cgit.themanaworld.org/.gitignore
0 → 100644
View file @
855beb63
data/
cgit.themanaworld.org/Dockerfile
0 → 100644
View file @
855beb63
# FIXME: 'edge' is for Python 3.10 (temporary)
FROM
alpine:edge
MAINTAINER
Zach van Rijn <me@zv.io>
RUN
apk update
&&
apk upgrade
&&
apk add
\
bzip2 gcc git
gzip
lighttpd make musl-dev musl-libintl openssl-dev py3-pygments
tar
xz zip zlib-dev
RUN
git clone https://git.zx2c4.com/cgit
\
&&
cd
cgit
\
&&
git checkout 5258c297ba6fb604ae1415fbc19a3fe42457e49e
\
&&
git submodule update
--init
--recursive
\
&&
make
-j
$(
nproc
)
NO_REGEX
=
NeedsStartEnd
NO_LUA
=
1
install
\
&&
cd
..
\
&&
rm
-fr
cgit
COPY
cgitrc /etc/cgitrc
COPY
lighttpd.conf /etc/lighttpd/lighttpd.conf
COPY
pygments.py /usr/local/lib/cgit/filters/syntax-highlighting.py
ENTRYPOINT
/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
cgit.themanaworld.org/README
0 → 100644
View file @
855beb63
overview
--------
This repository contains the code and configuration required to
run 'cgit', a lightweight (limited use) repository mirror:
* https://cgit.themanaworld.org/
The authoritative source control system is GitLab:
* https://git.themanaworld.org/
limitations
-----------
At present, there may be a maximum of 100 (per GitLab API)
projects in the group. Pagination support will need to be added
if we go over this limit.
important
---------
Use the provided script(s) to clone/synchronize repositories; it
will delete directories that are no longer present on the server:
$ ./update
After this has been done once, you can launch the service.
It is recommended to place this on a 15-minute cron job interval.
building
--------
To build the container image:
$ docker-compose build
Configuration files (e.g. 'lighttpd.conf' and 'cgitrc') are baked
into the container image; please rebuild and respawn if updated.
running
-------
To spawn a container from the image, or to take it down:
$ docker-compose up -d
$ docker-compose down
As configured, this will serve HTTP on port 9030. This should be
subsequently proxied to the outside world, not exposed directly.
maintenance
-----------
Upstream cgit commit hash is defined in the 'Dockerfile'.
Please remember to clean up old images.
license
-------
MIT
cgit.themanaworld.org/cgitrc
0 → 100644
View file @
855beb63
# the order of these options is somewhat important, don't ask me why
root-title=The Mana World
root-desc=The Mana World project. Please visit https://git.themanaworld.org/ for GitLab.
virtual-root=/
css=/cgit.css
logo=https://avatars.githubusercontent.com/u/1402939?s=96&v=4
favicon=https://git.themanaworld.org/uploads/-/system/appearance/favicon/1/favicon.ico
#clone-url=https://git.themanaworld.org/$CGIT_REPO_URL.git https://cgit.themanaworld.org/$CGIT_REPO_URL git@git.themanaworld.org:/$CGIT_REPO_URL.git
clone-url=https://git.themanaworld.org/$CGIT_REPO_URL.git https://cgit.themanaworld.org/$CGIT_REPO_URL
remove-suffix=1
source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.py
snapshots=tar.bz2 tar.gz tar.xz zip
enable-blame=1
enable-log-filecount=1
enable-log-linecount=1
scan-path=/data
enable-http-clone=1
cache-size=0
enable-index-owner=0
enable-git-config=1
max-blob-size=1000
max-repodesc-length=1024
cgit.themanaworld.org/docker-compose.yml
0 → 100644
View file @
855beb63
version
:
"
3.6"
services
:
cgit-themanaworld-org
:
build
:
.
ports
:
-
"
10030:80"
volumes
:
-
'
./data:/data'
cgit.themanaworld.org/lighttpd.conf
0 → 100644
View file @
855beb63
server
.
modules
= (
"mod_cgi"
,
"mod_rewrite"
,
)
include
"mime-types.conf"
server
.
username
=
"lighttpd"
server
.
groupname
=
"lighttpd"
server
.
document
-
root
=
"/var/www/htdocs/cgit"
server
.
pid
-
file
=
"/run/lighttpd.pid"
server
.
indexfiles
= (
"cgit.cgi"
)
server
.
follow
-
symlink
=
"enable"
static
-
file
.
exclude
-
extensions
= (
".cgi"
)
$
HTTP
[
"url"
] =~
"^/"
{
cgi
.
assign
= (
"cgit.cgi"
=>
""
)
mimetype
.
assign
= (
".css"
=>
"text/css"
,
".txt"
=>
"text/plain"
)
url
.
rewrite
-
once
= (
"^/robots.txt"
=>
"/robots.txt"
,
"^/cgit\.(css|png)"
=>
"$0"
,
"^/.+"
=>
"/cgit.cgi$0"
)
}
cgit.themanaworld.org/pygments.py
0 → 100755
View file @
855beb63
#!/usr/bin/env python3
# This script uses Pygments and Python3. You must have both installed
# for this to work.
#
# http://pygments.org/
# http://python.org/
#
# It may be used with the source-filter or repo.source-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 )
import
sys
import
io
import
pygments.lexers
from
pygments
import
highlight
from
pygments.lexers
import
guess_lexer
from
pygments.lexers
import
guess_lexer_for_filename
from
pygments.util
import
ClassNotFound
from
pygments.formatters
import
HtmlFormatter
sys
.
stdin
=
io
.
TextIOWrapper
(
sys
.
stdin
.
buffer
,
encoding
=
'utf-8'
,
errors
=
'replace'
)
sys
.
stdout
=
io
.
TextIOWrapper
(
sys
.
stdout
.
buffer
,
encoding
=
'utf-8'
,
errors
=
'replace'
)
data
=
sys
.
stdin
.
read
()
filename
=
sys
.
argv
[
1
]
formatter
=
HtmlFormatter
(
style
=
'pastie'
,
nobackground
=
True
)
try
:
lexer
=
guess_lexer_for_filename
(
filename
,
data
)
except
ClassNotFound
:
# requires Python >= 3.10
match
filename
:
case
"APKBUILD"
:
lexer
=
pygments
.
lexers
.
shell
.
BashLexer
()
case
_
:
lexer
=
guess_lexer
(
data
)
except
TypeError
:
lexer
=
TextLexer
()
# highlight! :-)
# printout pygments' css definitions as well
sys
.
stdout
.
write
(
'<style>'
)
sys
.
stdout
.
write
(
formatter
.
get_style_defs
(
'.highlight'
))
sys
.
stdout
.
write
(
'</style>'
)
sys
.
stdout
.
write
(
highlight
(
data
,
lexer
,
formatter
,
outfile
=
None
))
cgit.themanaworld.org/update
0 → 100755
View file @
855beb63
#!/bin/sh -e
set
-x
# depends: curl, jq
HERE
=
"
$(
dirname
$(
readlink
-f
${
0
}
))
"
;
DATA
=
"
${
HERE
}
/data"
;
GLAB
=
https://git.themanaworld.org
;
KEEP
=
"
$(
mktemp
)
"
;
HAVE
=
"
$(
mktemp
)
"
;
mkdir
-p
"
${
DATA
}
"
;
##
# sync GROUP
#
# Pulls repository URL and description for injection.
#
sync
()
{
##
# Cache GitLab API server response (JSON) as pre-parsed CSV data.
# TODO: support pagination (API supports max 100 results per page).
#
curl
-s
${
GLAB
}
/api/v4/projects?per_page
=
100
\
| jq
-r
'.[] | .http_url_to_repo + "%" + (.description | gsub("[\\r\\n\\t]+"; " "))'
>
"
${
KEEP
}
"
;
##
# Clone, pull, and/or update descriptions for current repositories.
#
while
read
k
;
do
(
repo
=
"
${
k
%\%*
}
"
;
name
=
"
${
repo
#https
://git.themanaworld.org/
}
"
;
desc
=
"
${
k
#*\%
}
"
;
case
"
${
name
}
"
in
ml/api.git
)
continue
;
;;
esac
cd
"
${
DATA
}
"
;
##
# Core data.
#
if
!
test
-d
${
name
%.*
}
;
then
mkdir
-p
${
name
%.*
}
;
git clone
--mirror
${
repo
}
${
name
%.*
}
/.git
;
git
-C
${
name
%.*
}
config remote.origin.fetch +refs/heads/
*
:refs/heads/
*
;
git
-C
${
name
%.*
}
config
--add
remote.origin.fetch +refs/tags/
*
:refs/tags/
*
;
else
git
-C
${
name
%.*
}
remote update
--prune
;
fi
##
# Write repository description from GitLab API for cgit to read.
#
printf
>
${
name
%.*
}
/.git/description
"%s"
"
${
desc
}
"
;
##
# Pack all refs beforehand to ensure they are all visible to cgit in this way.
# Delete '.git/refs/' directory contents (cgit uses 'packed-refs' when empty).
# Find time of latest commit to any branch, and set 'packed-refs' mtime to it.
#
git
-C
${
name
%.*
}
pack-refs
--all
;
find
${
name
%.*
}
/.git/refs
-type
f
-delete
;
when
=
$(
git
-C
${
name
%.*
}
--no-pager
branch
-al
\
|
sed
-e
's/*//g'
\
|
while
read
b
;
do
git
-C
${
name
%.*
}
--no-pager
log
-1
--format
=
%cd
--date
=
unix
${
b
}
;
done
\
|
sort
-nr
\
|
head
-n
1
\
)
;
touch
--date
=
@
${
when
}
${
name
%.*
}
/.git/packed-refs
;
)
done
<
"
${
KEEP
}
"
;
}
sync
;
rm
"
${
KEEP
}
"
;
rm
"
${
HAVE
}
"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment