ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit 0f88121d6783c727632625456947876dc39e1435
parent 88184108217855d456e2eb8282d4f28260940cbe
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 10 Mar 2021 00:34:45 +0100

roles/cgit: syntax-highlighting with highlight
3 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/roles/cgit/files/syntax-highlighting.sh b/roles/cgit/files/syntax-highlighting.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+BASENAME="$1"
+EXTENSION="${BASENAME##*.}"
+
+[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt
+[ -z "${EXTENSION}" ] && EXTENSION=txt
+
+# map Makefile and Makefile.* to .mk
+[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk
+
+exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
diff --git a/roles/cgit/tasks/configure.yml b/roles/cgit/tasks/configure.yml
@@ -22,3 +22,9 @@
     mode: 0644
   when:
     - services.cgit.configFile is defined
+
+- name: "Copy syntax-highlighting.sh to: /usr/local/bin"
+  copy: 
+    src: syntax-highlighting.sh
+    dest: /usr/local/bin/syntax-highlighting.sh
+    mode: 0755
diff --git a/roles/cgit/tasks/install.yml b/roles/cgit/tasks/install.yml
@@ -9,6 +9,7 @@
       - fcgiwrap
       - py3-markdown
       - py3-pygments
+      - highlight
     state: present
   when:
     - ansible_distribution == "Alpine"