From f1196ed37bdac83ad34b895d23864caad75ad668 Mon Sep 17 00:00:00 2001
From: 53hornet <atc@53hor.net>
Date: Mon, 17 Jan 2022 23:14:29 -0500
Subject: feat: add and support pretty permalinks

---
 usr/local/etc/cgitrc                       | 4 +++-
 usr/local/etc/lighttpd/conf.d/rewrite.conf | 4 ++++
 usr/local/etc/lighttpd/lighttpd.conf       | 6 ++++--
 3 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 usr/local/etc/lighttpd/conf.d/rewrite.conf

(limited to 'usr/local/etc')

diff --git a/usr/local/etc/cgitrc b/usr/local/etc/cgitrc
index d1686fe..c93c5b1 100644
--- a/usr/local/etc/cgitrc
+++ b/usr/local/etc/cgitrc
@@ -3,10 +3,12 @@ logo=https://www.53hor.net/assets/53hornet.svg
 css=https://www.53hor.net/includes/cgit.css
 root-title=index : git.53hor.net
 root-desc=The source code repositories of Adam Carpenter (53hornet)
+virtual-root=/
+repository-sort=age
 logo-link=/
 enable-blame=1
 enable-commit-graph=1
-clone-url=http://$HTTP_HOST$SCRIPT_NAME/$CGIT_REPO_URL
+clone-url=https://$HTTP_HOST/$CGIT_REPO_URL
 enable-http-clone=1
 snapshots=tar.xz zip
 remove-suffix=1
diff --git a/usr/local/etc/lighttpd/conf.d/rewrite.conf b/usr/local/etc/lighttpd/conf.d/rewrite.conf
new file mode 100644
index 0000000..f1ba97f
--- /dev/null
+++ b/usr/local/etc/lighttpd/conf.d/rewrite.conf
@@ -0,0 +1,4 @@
+server.modules += ( "mod_rewrite" )
+url.rewrite-once = (
+        "^/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2",
+)
diff --git a/usr/local/etc/lighttpd/lighttpd.conf b/usr/local/etc/lighttpd/lighttpd.conf
index 277ac25..b7e3272 100644
--- a/usr/local/etc/lighttpd/lighttpd.conf
+++ b/usr/local/etc/lighttpd/lighttpd.conf
@@ -2,11 +2,13 @@ var.log_root = "/var/log/lighttpd"
 include "conf.d/access_log.conf"
 include "conf.d/mime.conf"
 include "conf.d/cgi.conf"
-index-file.names += ("cgit.cgi")
+include "conf.d/rewrite.conf"
+index-file.names = ("cgit.cgi")
+server.name = "git.53hor.net"
 server.document-root = "/usr/local/www/cgit"
 server.errorlog = log_root + "/error.log"
 server.breakagelog = log_root + "/breakage.log"
 server.network-backend = "sendfile"
 server.port = 80
-server.username	= "www"
+server.username = "www"
 server.groupname = "www"
-- 
cgit v1.2.3