From ca3af179dfa822b00eca8caf62bef6c2ceefb649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 15 Jan 2023 12:36:03 +0100 Subject: Add some filters for possible use. --- files/filters/auth-deny-all.lua | 46 +++++++++++++++++++++++++++++++++++++++++ files/filters/highlight.sh | 9 ++++++++ 2 files changed, 55 insertions(+) create mode 100644 files/filters/auth-deny-all.lua create mode 100644 files/filters/highlight.sh diff --git a/files/filters/auth-deny-all.lua b/files/filters/auth-deny-all.lua new file mode 100644 index 0000000..1bf34ce --- /dev/null +++ b/files/filters/auth-deny-all.lua @@ -0,0 +1,46 @@ +-- Filter which denies access to all repos +-- +-- File managed by Puppet + +function authenticate_post() + return 0 +end + +function authenticate_cookie() + return 0 +end + +function body() + html("

Access denied for everyone and everything

") + return 0 +end + +actions["authenticate-post"] = authenticate_post +actions["authenticate-cookie"] = authenticate_cookie +actions["body"] = body + +function filter_open(...) + action = actions[select(1, ...)] + http = {} + http["cookie"] = select(2, ...) + http["method"] = select(3, ...) + http["query"] = select(4, ...) + http["referer"] = select(5, ...) + http["path"] = select(6, ...) + http["host"] = select(7, ...) + http["https"] = select(8, ...) + + cgit = {} + cgit["repo"] = select(9, ...) + cgit["page"] = select(10, ...) + cgit["url"] = select(11, ...) + cgit["login"] = select(12, ...) +end + +-- function filter_close() +-- return action() +-- end +-- +-- function filter_write(str) +-- post = parse_qs(str) +-- end diff --git a/files/filters/highlight.sh b/files/filters/highlight.sh new file mode 100644 index 0000000..75a8ccd --- /dev/null +++ b/files/filters/highlight.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +filename="$1" +extension="${filename##*.}" + +exec highlight --inline-css --force --fragment \ + --enclose-pre --out-format=xhtml \ + --syntax="$extension" \ + "$filename" -- cgit v1.2.3