diff options
author | Slack Coder <slackcoder@server.ky> | 2024-10-29 14:09:17 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2024-10-29 14:08:39 -0500 |
commit | bfc423e01dc56817fadf010aed9fd780a7e0a8ed (patch) | |
tree | 0645c210ada47e3ee9a00a4a3976d15f1a51fb86 /cgit | |
parent | 2954898f6551cbd2e5b0ed4dae8925d729f741a9 (diff) | |
download | slackbuilds-bfc423e01dc56817fadf010aed9fd780a7e0a8ed.tar.xz |
cgit: Add patched version
Support a 'sponsor-page' tab.
Diffstat (limited to 'cgit')
-rw-r--r-- | cgit/README | 16 | ||||
-rw-r--r-- | cgit/cgit.SlackBuild | 136 | ||||
-rw-r--r-- | cgit/cgit.info | 12 | ||||
-rw-r--r-- | cgit/config/cgit-httpd.conf | 62 | ||||
-rw-r--r-- | cgit/config/cgit-lighttpd.conf | 20 | ||||
-rw-r--r-- | cgit/config/cgit.conf | 2 | ||||
-rw-r--r-- | cgit/config/cgitrc.sample | 29 | ||||
-rw-r--r-- | cgit/config/email-gravatar-sbo-additions.css | 28 | ||||
-rw-r--r-- | cgit/config/email-gravatar-sbo.lua | 26 | ||||
-rw-r--r-- | cgit/config/email-libravatar-korg-additions.css | 28 | ||||
-rw-r--r-- | cgit/config/email-libravatar-korg.lua | 15 | ||||
-rw-r--r-- | cgit/patch/0001-UI-Add-support-for-project-sponsor-page.patch | 108 | ||||
-rw-r--r-- | cgit/slack-desc | 19 |
13 files changed, 501 insertions, 0 deletions
diff --git a/cgit/README b/cgit/README new file mode 100644 index 0000000..c9b0e46 --- /dev/null +++ b/cgit/README @@ -0,0 +1,16 @@ +cgit is a web interface (cgi) for git repositories, written in C. + +The folder /var/cache/cgit, must be owned by your webserver user. + +A sample /etc/cgitrc (you must provide one) is in the docs folder, +and so are some example configuration files for apache and lighttpd. + +luacrypto or lua-md5 are optional dependencies (for avatars support), +but first you have to build this against lua (use lua, *NOT* lua52 +or lua53). + +If you want to use the email-libravatar-korg.lua filter or the +email-gravatar-sbo.lua one, have a look also to the suggested css +additions (in the docs folder). + +This version is patched to support the repository tab 'sponsor-page'. diff --git a/cgit/cgit.SlackBuild b/cgit/cgit.SlackBuild new file mode 100644 index 0000000..4e192b1 --- /dev/null +++ b/cgit/cgit.SlackBuild @@ -0,0 +1,136 @@ +#!/bin/bash + +# Slackware build script for cgit +# Copyright 2013-2020 Matteo Bernardini <ponce@slackbuilds.org>, Pisa, Italy +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +PRGNAM=cgit +VERSION=${VERSION:-1.2.3} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +DOCROOT=${DOCROOT:-/var/www} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +CGIT_VERSION=${CGIT_VERSION:-v$VERSION} +GIT_VERSION=${GIT_VERSION:-2.26.2} + +DOCS="cgitrc.5.txt COPYING README $CWD/config/cgitrc.sample \ + $CWD/config/cgit-lighttpd.conf $CWD/config/cgit-httpd.conf \ + $CWD/config/email-libravatar-korg-additions.css \ + $CWD/config/email-gravatar-sbo-additions.css" + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/v$VERSION.tar.gz || tar xvf $CWD/$PRGNAM-$VERSION.tar.?z* +cd $PRGNAM-$VERSION +chown -R root:root . +find -L . \ +\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +# prepare sources +sed -i Makefile \ + -e "s|-g -Wall -Igit|-Wall ${SLKCFLAGS} -Igit|" \ + -e "s|\/lib$|/lib${LIBDIRSUFFIX}|" \ + -e "s|(libdir)|(prefix)/share|" \ + -e "s|/usr/local|/usr|" || exit 1 +sed -e "s|@DOCROOT@|$DOCROOT|g" $CWD/config/cgit.conf > cgit.conf +echo "CGIT_VERSION = $CGIT_VERSION" >> cgit.conf + +# extract the git tarball +rm -fR git +tar xvf $CWD/git-$GIT_VERSION.tar.?z* +mv git-* git + +for p in $CWD/patch/*.patch; do + echo "applying patch $p" + patch -p1 <"$p" +done + +make +make install DESTDIR=$PKG + +find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +# install additionals lua scripts +install -m 0644 -D $CWD/config/email-libravatar-korg.lua \ + $PKG/usr/share/cgit/filters/email-libravatar-korg.lua +install -m 0644 -D $CWD/config/email-gravatar-sbo.lua \ + $PKG/usr/share/cgit/filters/email-gravatar-sbo.lua + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +install -m0644 -oroot $DOCS $PKG/usr/doc/$PRGNAM-$VERSION +sed -i "s|@DOCROOT@|$DOCROOT|g" $PKG/usr/doc/$PRGNAM-$VERSION/* +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +# prepare the cache dir: default permissions are for the apache user and group +mkdir -p $PKG/var/cache/cgit +chown 80:80 $PKG/var/cache/cgit +chmod 775 $PKG/var/cache/cgit + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/cgit/cgit.info b/cgit/cgit.info new file mode 100644 index 0000000..1c62402 --- /dev/null +++ b/cgit/cgit.info @@ -0,0 +1,12 @@ +PRGNAM="cgit" +VERSION="1.2.3" +HOMEPAGE="https://git.zx2c4.com/cgit/about/" +DOWNLOAD="https://git.zx2c4.com/cgit/snapshot/cgit-1.2.3.tar.xz \ + https://www.kernel.org/pub/software/scm/git/git-2.26.2.tar.xz" +MD5SUM="2d44ca575a8770fae48139c18dac6986 \ + f9a832256032e711973dd7be4981ab4c" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="Matteo Bernardini" +EMAIL="ponce@slackbuilds.org" diff --git a/cgit/config/cgit-httpd.conf b/cgit/config/cgit-httpd.conf new file mode 100644 index 0000000..4b757ea --- /dev/null +++ b/cgit/config/cgit-httpd.conf @@ -0,0 +1,62 @@ +# Sample folder and virtual host configurations for httpd. +# edit, move it to /etc/httpd/extra and include it in +# /etc/httpd/httpd.conf with a line +# +# Include /etc/httpd/extra/cgit.conf +# +# uncomment also the line +# +# AddHandler cgi-script .cgi +# +# and enable mod_cgi (or mod_cgid, depending on your apache +# configuration) + +## Version 1: cgit in a /cgit subdirectory of the main host +## This will need the following 3 lines in your /etc/cgitrc +## +## virtual-root=/cgit/ +## css=/static/cgit.css +## logo=/static/cgit.png +## +#Alias /static/cgit.css "@DOCROOT@/cgi-bin/cgit.css" +#Alias /static/cgit.png "@DOCROOT@/cgi-bin/cgit.png" +#ScriptAlias /cgit/ "@DOCROOT@/cgi-bin/cgit.cgi/" +#RedirectMatch ^/cgit$ /cgit/ +#<Directory "@DOCROOT@/cgi-bin/"> +# AllowOverride None +# Options ExecCGI FollowSymlinks +# Require all granted +#</Directory> + +# Version 2: cgit as a handler to whole vhost +# Thanks to Robby Workman for this elegant example +<VirtualHost *:80> + ServerName cgit.yourdomain.ltd + + Options FollowSymlinks + + SetEnv CGIT_CONFIG /etc/cgitrc + + DocumentRoot @DOCROOT@/cgi-bin + + <Directory @DOCROOT@/cgi-bin> + AllowOverride None + Require all granted + DirectoryIndex cgit.cgi + </Directory> + + Alias /cgit.css @DOCROOT@/cgi-bin/cgit.css + Alias /cgit.png @DOCROOT@/cgi-bin/cgit.png + Alias /favicon.ico @DOCROOT@/cgi-bin/favicon.ico + Alias /robots.txt @DOCROOT@/cgi-bin/robots.txt + Alias / @DOCROOT@/cgi-bin/cgit.cgi/ + + <Location /> + Options ExecCGI + Require all granted + </Location> + + <Files cgit.cgi> + SetHandler cgi-script + </Files> +</VirtualHost> diff --git a/cgit/config/cgit-lighttpd.conf b/cgit/config/cgit-lighttpd.conf new file mode 100644 index 0000000..ce7ccce --- /dev/null +++ b/cgit/config/cgit-lighttpd.conf @@ -0,0 +1,20 @@ +# sample virtual host configuration for lighttpd. +# edit, move to /etc/lighttpd/ and include it in /etc/lighttpd/lighttpd.conf +# with a line +# +# include "cgit-lighttpd.conf" + +$HTTP["host"] == "cgit.my.domain" { + alias.url = ( + "/static/" => "@DOCROOT@/cgi-bin/", + "/cgit.cgi" => "@DOCROOT@/cgi-bin/cgit.cgi", + ) + url.rewrite-once = ( + "^/static/.*$" => "$0", + "^/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2", + ) + cgi.assign = ( + "@DOCROOT@/cgi-bin/cgit.cgi" => "", + ) +} + diff --git a/cgit/config/cgit.conf b/cgit/config/cgit.conf new file mode 100644 index 0000000..a569414 --- /dev/null +++ b/cgit/config/cgit.conf @@ -0,0 +1,2 @@ +CGIT_SCRIPT_PATH = @DOCROOT@/cgi-bin +CACHE_ROOT = /var/cache/cgit diff --git a/cgit/config/cgitrc.sample b/cgit/config/cgitrc.sample new file mode 100644 index 0000000..31d7708 --- /dev/null +++ b/cgit/config/cgitrc.sample @@ -0,0 +1,29 @@ +# sample /etc/cgitrc file: two repos are defined +# you can see a demo here http://cgit.ponce.cc/ +# For more options, see cgitrc.5.txt in the docs folder + +root-title=ponce's repository browser +root-desc=a fast interface to these git repositories +virtual-root=/ +snapshots=tar.gz +branch-sort=age +# for this to work you have to build cgit against lua +# and install luacrypto too. +# you wull have also to add email-gravatar-sbo-additions.css +# at the bottom of your installed cgit.css +email-filter=lua:/usr/share/cgit/filters/email-gravatar-sbo.lua + +#css=/cgit.css +#logo=/cgit.png + +# repository specific data +repo.url=slackbuilds +repo.path=/path/to/repo/.git +repo.desc=slackbuilds.org fork for slackware-current +repo.owner=my.address _at_ my.isp +# the default branch here is set to current (default if omitted is master) +repo.defbranch=current +repo.clone-url=git://github.com/Ponce/slackbuilds.git + +# if you need to display other repositories you can more config blocks +# like the one above diff --git a/cgit/config/email-gravatar-sbo-additions.css b/cgit/config/email-gravatar-sbo-additions.css new file mode 100644 index 0000000..f7dbc32 --- /dev/null +++ b/cgit/config/email-gravatar-sbo-additions.css @@ -0,0 +1,28 @@ +div#cgit span.gravatar img.onhover { + display: none; + border: 1px solid gray; + padding: 0px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + width: 128px; + height: 128px; +} + +div#cgit span.gravatar img.inline { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + width: 13px; + height: 13px; + margin-right: 0.2em; + opacity: 0.8; +} + +div#cgit span.gravatar:hover > img.onhover { + display: block; + position: absolute; + margin-left: 1.5em; + background-color: #eeeeee; + box-shadow: 5px 5px 3px #bbb; +} diff --git a/cgit/config/email-gravatar-sbo.lua b/cgit/config/email-gravatar-sbo.lua new file mode 100644 index 0000000..0b8cb17 --- /dev/null +++ b/cgit/config/email-gravatar-sbo.lua @@ -0,0 +1,26 @@ +-- This script may be used with the email-filter or repo.email-filter settings in cgitrc. +-- It adds gravatar icons to author names. It is designed to be used with the lua: +-- prefix in filters. It takes some part from the kernel.org's one. +-- +-- Requirements: +-- luacrypto >= 0.3 +-- <http://mkottman.github.io/luacrypto/> +-- + +local crypto = require("crypto") + +function filter_open(email, page) + buffer = "" + md5 = crypto.digest("md5", email:sub(2, -2):lower()) +end + +function filter_close() + html("<span class='gravatar'><img class='inline' src='//www.gravatar.com/avatar/" .. md5 .. "?s=13&d=retro' /><img class='onhover' src='//www.gravatar.com/avatar/" .. md5 .. "?s=128&d=retro' /></span> " .. buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. str +end + + diff --git a/cgit/config/email-libravatar-korg-additions.css b/cgit/config/email-libravatar-korg-additions.css new file mode 100644 index 0000000..e44d052 --- /dev/null +++ b/cgit/config/email-libravatar-korg-additions.css @@ -0,0 +1,28 @@ +div#cgit span.libravatar img.onhover { + display: none; + border: 1px solid gray; + padding: 0px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + width: 128px; + height: 128px; +} + +div#cgit span.libravatar img.inline { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + width: 13px; + height: 13px; + margin-right: 0.2em; + opacity: 0.4; +} + +div#cgit span.libravatar:hover > img.onhover { + display: block; + position: absolute; + margin-left: 1.5em; + background-color: #eeeeee; + box-shadow: 5px 5px 3px #bbb; +} diff --git a/cgit/config/email-libravatar-korg.lua b/cgit/config/email-libravatar-korg.lua new file mode 100644 index 0000000..2d67991 --- /dev/null +++ b/cgit/config/email-libravatar-korg.lua @@ -0,0 +1,15 @@ +local md5 = require("md5") + +function filter_open(email, page) + buffer = "" + hexdigest = md5.sumhexa(email:sub(2, -2):lower()) +end + +function filter_close() + html("<span class='libravatar'><img class='inline' src='//seccdn.libravatar.org/avatar/" .. hexdigest .. "?s=13&d=retro' /><img class='onhover' src='//seccdn.libravatar.org/avatar/" .. hexdigest .. "?s=128&d=retro' /></span>" .. buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. str +end diff --git a/cgit/patch/0001-UI-Add-support-for-project-sponsor-page.patch b/cgit/patch/0001-UI-Add-support-for-project-sponsor-page.patch new file mode 100644 index 0000000..21a3622 --- /dev/null +++ b/cgit/patch/0001-UI-Add-support-for-project-sponsor-page.patch @@ -0,0 +1,108 @@ +From a6cb50a01bcd2b45c44336cc85f2a3d5d602a856 Mon Sep 17 00:00:00 2001 +From: Slack Coder <slackcoder@server.ky> +Date: Tue, 29 Oct 2024 11:43:48 -0500 +Subject: [PATCH] UI: Add support for project sponsor page + +Add an extra configuration parameter repo.sponsor-page to link to a project's +sponsorship page. +--- + cgit.c | 4 ++++ + cgit.h | 1 + + cgitrc.5.txt | 3 +++ + scan-tree.c | 2 ++ + shared.c | 1 + + ui-shared.c | 5 +++++ + 6 files changed, 16 insertions(+) + +diff --git a/cgit.c b/cgit.c +index c4320f0..e19b9c1 100644 +--- a/cgit.c ++++ b/cgit.c +@@ -54,6 +54,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va + repo->owner = xstrdup(value); + else if (!strcmp(name, "homepage")) + repo->homepage = xstrdup(value); ++ else if (!strcmp(name, "sponsor-page")) ++ repo->sponsor_page = xstrdup(value); + else if (!strcmp(name, "defbranch")) + repo->defbranch = xstrdup(value); + else if (!strcmp(name, "extra-head-content")) +@@ -814,6 +816,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo) + fprintf(f, "repo.section=%s\n", repo->section); + if (repo->homepage) + fprintf(f, "repo.homepage=%s\n", repo->homepage); ++ if (repo->sponsor_page) ++ fprintf(f, "repo.sponsor-page=%s\n", repo->sponsor_page); + if (repo->clone_url) + fprintf(f, "repo.clone-url=%s\n", repo->clone_url); + fprintf(f, "repo.enable-blame=%d\n", +diff --git a/cgit.h b/cgit.h +index 7ec46b4..0136ea6 100644 +--- a/cgit.h ++++ b/cgit.h +@@ -85,6 +85,7 @@ struct cgit_repo { + char *extra_head_content; + char *owner; + char *homepage; ++ char *sponsor_page; + char *defbranch; + char *module_link; + struct string_list readme; +diff --git a/cgitrc.5.txt b/cgitrc.5.txt +index 33a6a8c..d1429c5 100644 +--- a/cgitrc.5.txt ++++ b/cgitrc.5.txt +@@ -528,6 +528,9 @@ repo.hide:: + repo.homepage:: + The value to show as repository homepage. Default value: none. + ++repo.sponsor-page:: ++ The value to show as repository sponsor page. Default value: none. ++ + repo.ignore:: + Flag which, when set to "1", ignores the repository. The repository + is not shown in the index and cannot be accessed by providing a direct +diff --git a/scan-tree.c b/scan-tree.c +index 6a2f65a..bdd3e70 100644 +--- a/scan-tree.c ++++ b/scan-tree.c +@@ -66,6 +66,8 @@ static int gitconfig_config(const char *key, const char *value, void *cb) + config_fn(repo, "section", value); + else if (!strcmp(key, "gitweb.homepage")) + config_fn(repo, "homepage", value); ++ else if (!strcmp(key, "gitweb.sponsor-page")) ++ config_fn(repo, "sponsor-page", value); + else if (skip_prefix(key, "cgit.", &name)) + config_fn(repo, name, value); + +diff --git a/shared.c b/shared.c +index 8115469..099a3b9 100644 +--- a/shared.c ++++ b/shared.c +@@ -56,6 +56,7 @@ struct cgit_repo *cgit_add_repo(const char *url) + ret->extra_head_content = NULL; + ret->owner = NULL; + ret->homepage = NULL; ++ ret->sponsor_page = NULL; + ret->section = ctx.cfg.section; + ret->snapshots = ctx.cfg.snapshots; + ret->enable_blame = ctx.cfg.enable_blame; +diff --git a/ui-shared.c b/ui-shared.c +index d2358f2..4d2d94e 100644 +--- a/ui-shared.c ++++ b/ui-shared.c +@@ -1060,6 +1060,11 @@ void cgit_print_pageheader(void) + html_attr(ctx.repo->homepage); + html("'>homepage</a>"); + } ++ if (ctx.repo->sponsor_page) { ++ html("<a href='"); ++ html_attr(ctx.repo->sponsor_page); ++ html("'>sponsor</a>"); ++ } + html("</td><td class='form'>"); + html("<form class='right' method='get' action='"); + if (ctx.cfg.virtual_root) { +-- +2.46.2 + diff --git a/cgit/slack-desc b/cgit/slack-desc new file mode 100644 index 0000000..c9b4091 --- /dev/null +++ b/cgit/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +cgit: cgit (web frontend for git repositories) +cgit: +cgit: cgit is a web interface (cgi) for git repositories, written in C. +cgit: +cgit: Homepage: https://git.zx2c4.com/cgit/about/ +cgit: +cgit: +cgit: +cgit: +cgit: +cgit: |